Fix prefast warning 11263 (#14508)

### Description
<!-- Describe your changes. -->
https://dev.azure.com/aiinfra/ONNX%20Runtime/_workitems/edit/11263/


### Motivation and Context
<!-- - Why is this change required? What problem does it solve?
- If it fixes an open issue, please link to the issue here. -->
This commit is contained in:
Ye Wang 2023-02-01 10:45:48 -08:00 committed by GitHub
parent 3cc81460e0
commit bc8686d365
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -140,8 +140,9 @@ Status Sample(AllocatorPtr& allocator,
// Multinomial sampling
gsl::span<float>& d_sampled = sampling_state->d_sampled;
gsl::span<float>& h_sampled_all = sampling_state->h_sampled_all;
size_t sample_offset = (static_cast<size_t>(step) - 1) * static_cast<size_t>(parameters->batch_size);
CUDA_RETURN_IF_ERROR(cudaMemcpyAsync(d_sampled.data(),
h_sampled_all.data() + (step - 1) * parameters->batch_size,
h_sampled_all.data() + sample_offset,
sizeof(float) * parameters->batch_size,
cudaMemcpyHostToDevice,
cuda_stream));