Skip to content

Commit bde4fbe

Browse files
authored
Change gsl::byte to std::byte (#23872)
To be compatible with the latest GSL library. Without this fix we will get: ``` onnxruntime\core\providers\cpu\controlflow\loop.cc(247): error C4996: 'gsl::byte': Use std::byte instead. ```
1 parent 30c6825 commit bde4fbe

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

onnxruntime/core/providers/cpu/controlflow/loop.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ static Status ConcatenateCpuOutput(void* /*stream*/,
244244

245245
// we can't easily use a C++ template for the tensor element type,
246246
// so use a span for some protection but work in bytes
247-
gsl::span<gsl::byte> output_span = gsl::make_span<gsl::byte>(static_cast<gsl::byte*>(output),
247+
gsl::span<std::byte> output_span = gsl::make_span<std::byte>(static_cast<std::byte*>(output),
248248
output_size_in_bytes);
249249

250250
for (size_t i = 0, num_iterations = per_iteration_output.size(); i < num_iterations; ++i) {
@@ -257,7 +257,7 @@ static Status ConcatenateCpuOutput(void* /*stream*/,
257257
" Expected:", per_iteration_shape, " Got:", iteration_data.Shape());
258258
}
259259

260-
auto src = gsl::make_span<const gsl::byte>(static_cast<const gsl::byte*>(iteration_data.DataRaw()),
260+
auto src = gsl::make_span<const std::byte>(static_cast<const std::byte*>(iteration_data.DataRaw()),
261261
bytes_per_iteration);
262262
auto dst = output_span.subspan(i * bytes_per_iteration, bytes_per_iteration);
263263
gsl::copy(src, dst);

onnxruntime/core/providers/cuda/controlflow/loop.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ static Status ConcatenateGpuOutput(void* stream, std::vector<OrtValue>& per_iter
8484
CUDA_RETURN_IF_ERROR(cudaMemcpyAsync(cur_output, iteration_data.DataRaw(), bytes_per_iteration,
8585
cudaMemcpyDeviceToDevice, static_cast<cudaStream_t>(stream)));
8686

87-
cur_output = static_cast<void*>((static_cast<gsl::byte*>(cur_output) + bytes_per_iteration));
87+
cur_output = static_cast<void*>((static_cast<std::byte*>(cur_output) + bytes_per_iteration));
8888
}
8989

90-
ORT_ENFORCE(static_cast<gsl::byte*>(cur_output) - static_cast<gsl::byte*>(output) == output_size_in_bytes,
90+
ORT_ENFORCE(static_cast<std::byte*>(cur_output) - static_cast<std::byte*>(output) == output_size_in_bytes,
9191
"Concatenation did not fill output buffer as expected.");
9292

9393
return Status::OK();

onnxruntime/test/providers/base_tester.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ static std::unique_ptr<SparseTensor> MakeSparseTensor(MLDataType data_type, cons
174174
return p_tensor;
175175
}
176176

177-
void BaseTester::CopyDataToTensor(gsl::span<const gsl::byte> data, Tensor& dst) {
177+
void BaseTester::CopyDataToTensor(gsl::span<const std::byte> data, Tensor& dst) {
178178
ORT_ENFORCE(dst.SizeInBytes() >= data.size_bytes(), "Not enough space in the destination tensor");
179179
memcpy(dst.MutableDataRaw(), data.data(), data.size_bytes());
180180
}
@@ -203,7 +203,7 @@ void BaseTester::AddSparseCooTensorData(std::vector<Data>& data,
203203
MLDataType data_type,
204204
const char* name,
205205
gsl::span<const int64_t> dims,
206-
gsl::span<const gsl::byte> values,
206+
gsl::span<const std::byte> values,
207207
gsl::span<const int64_t> indices,
208208
const ValidateOutputParams& check_params,
209209
const std::vector<std::string>* dim_params) {
@@ -247,7 +247,7 @@ void BaseTester::AddSparseCsrTensorData(std::vector<Data>& data,
247247
MLDataType data_type,
248248
const char* name,
249249
gsl::span<const int64_t> dims,
250-
gsl::span<const gsl::byte> values,
250+
gsl::span<const std::byte> values,
251251
gsl::span<const int64_t> inner_indices,
252252
gsl::span<const int64_t> outer_indices,
253253
const ValidateOutputParams& check_params,

onnxruntime/test/providers/base_tester.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ class BaseTester {
868868
void AddShapeToTensorData(NodeArg& node_arg, gsl::span<const int64_t> dims,
869869
const std::vector<std::string>* dim_params);
870870

871-
void CopyDataToTensor(gsl::span<const gsl::byte> data, Tensor& dst);
871+
void CopyDataToTensor(gsl::span<const std::byte> data, Tensor& dst);
872872

873873
#if !defined(DISABLE_SPARSE_TENSORS)
874874
NodeArg MakeSparseNodeArg(int32_t dtype, const char* name,
@@ -879,7 +879,7 @@ class BaseTester {
879879
MLDataType data_type,
880880
const char* name,
881881
gsl::span<const int64_t> dims,
882-
gsl::span<const gsl::byte> values,
882+
gsl::span<const std::byte> values,
883883
gsl::span<const int64_t> indices,
884884
const ValidateOutputParams& check_params,
885885
const std::vector<std::string>* dim_params = nullptr);
@@ -895,7 +895,7 @@ class BaseTester {
895895
MLDataType data_type,
896896
const char* name,
897897
gsl::span<const int64_t> dims,
898-
gsl::span<const gsl::byte> values,
898+
gsl::span<const std::byte> values,
899899
gsl::span<const int64_t> inner_indices,
900900
gsl::span<const int64_t> outer_indices,
901901
const ValidateOutputParams& check_params,

0 commit comments

Comments
 (0)