Prefast warning fixes (#15175)

### Description
transpose.cc:
Arithmetic overflow: Using operator '-' on a 4 byte value and then
casting the result to a 8 byte value. Cast the value to the wider type
before calling operator '-' to avoid overflow (io.2).

cuda_provider_factory.cc:
The type 'struct onnxruntime::ProviderInfo_CUDA_Impl' with a virtual
function needs either public virtual or protected non-virtual destructor
(c.35).
This commit is contained in:
Ryan Hill 2023-03-28 21:36:03 -07:00 committed by GitHub
parent f752bb9973
commit 659118f939
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View file

@ -52,7 +52,8 @@ std::unique_ptr<IExecutionProvider> CUDAProviderFactory::CreateProvider() {
return std::make_unique<CUDAExecutionProvider>(info_);
}
struct ProviderInfo_CUDA_Impl : ProviderInfo_CUDA {
struct ProviderInfo_CUDA_Impl final : ProviderInfo_CUDA {
OrtStatus* SetCurrentGpuDeviceId(_In_ int device_id) override {
int num_devices;
auto cuda_err = ::cudaGetDeviceCount(&num_devices);

View file

@ -162,7 +162,7 @@ Status Transpose::DoTranspose(const cudaDeviceProp& prop,
new_input_dims[prev] *= new_input_dims[curr];
new_input_dims[curr] = 1;
for (auto j = static_cast<int32_t>(curr + 1); j < new_rank; j++) {
new_input_dims[j - 1] = new_input_dims[j];
new_input_dims[static_cast<ptrdiff_t>(j) - 1] = new_input_dims[j];
}
new_input_dims[new_rank - 1] = 1;