Fix/Suppress some VC static analyzer warnings (#12713)

This commit is contained in:
Hariharan Seshadri 2022-08-24 23:39:40 -07:00 committed by GitHub
parent dee2fdffb0
commit cde504ebbf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 4 deletions

View file

@ -3,6 +3,15 @@
#include "conv_transpose.h"
// To suppress FP static analyzer warnings:
// https://msdata.visualstudio.com/Vienna/_workitems/edit/1944928 and
// https://msdata.visualstudio.com/Vienna/_workitems/edit/1944950
#ifdef _WIN32
#pragma warning(push)
#pragma warning(disable : 26110)
#pragma warning(disable : 26117)
#endif
namespace onnxruntime {
namespace cuda {
@ -206,3 +215,7 @@ Status ConvTranspose<T>::DoConvTranspose(OpKernelContext* context, bool dynamic_
} // namespace cuda
} // namespace onnxruntime
#ifdef _WIN32
#pragma warning(pop)
#endif

View file

@ -249,7 +249,7 @@ Status CudnnRnnBase<T>::ComputeInternal(OpKernelContext* ctx) const {
size_t workspace_bytes;
CUDNN_RETURN_IF_ERROR(cudnnGetRNNWorkspaceSize(CudnnHandle(), rnn_desc, gsl::narrow_cast<int>(seq_length), x_desc.data(), &workspace_bytes));
auto workspace_cuda = GetScratchBuffer<void>(workspace_bytes);
int32_t zero_seq_count = 0;
int64_t zero_seq_count = 0;
std::vector<int32_t> zero_seq_index_cache(batch_size, 0);
int64_t zero_seq_index_cache_size = 0;
@ -291,7 +291,7 @@ Status CudnnRnnBase<T>::ComputeInternal(OpKernelContext* ctx) const {
if (zero_seq_count && num_directions_ > 1) {
zero_seq_index_cache_size = zero_seq_count * num_directions_;
zero_seq_index_cache.resize(zero_seq_index_cache_size);
for (int i = 0; i < zero_seq_count; ++i) {
for (int64_t i = 0; i < zero_seq_count; ++i) {
zero_seq_index_cache[zero_seq_count + i] = static_cast<int32_t>(batch_size + zero_seq_index_cache[i]);
}
}

View file

@ -24,7 +24,7 @@ enum RNN_Input_Index {
};
// Onnx RNN/GRU/LSTM only support 1 layer
const int RNN_NUM_LAYERS = 1;
constexpr int RNN_NUM_LAYERS = 1;
class CudnnRNN {
public:

View file

@ -2012,7 +2012,10 @@ TEST(CApiTest, TestConfigureCUDAProviderOptions) {
char* cuda_options_str = nullptr;
ASSERT_TRUE(api.GetCUDAProviderOptionsAsString(rel_cuda_options.get(), allocator, &cuda_options_str) == nullptr);
std::string s(cuda_options_str, strnlen(cuda_options_str, 2048));
std::string s;
if (cuda_options_str != nullptr) {
s = std::string(cuda_options_str, strnlen(cuda_options_str, 2048));
}
ASSERT_TRUE(s.find("device_id=0") != std::string::npos);
ASSERT_TRUE(s.find("gpu_mem_limit=1024") != std::string::npos);
ASSERT_TRUE(s.find("arena_extend_strategy=kSameAsRequested") != std::string::npos);