mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-06-08 00:23:03 +00:00
Prefast Fixes (#12952)
**Description**: Fixes these TSA issues (no actual bugs fixed, but just changing code to make TSA happy) To fix 1944982 and 1944973 I changed DeleteOnUnloadPtr to not use 'new' and to just use placement new to go into a fixed buffer. This required changing the rocm usage of it also (probably a separate TSA bug on that one that I don't have) 1944982 Ryan Hill [prefast:Warning]: C26426 (in onnxruntime/core/providers/cuda/tensor/cast_op.cc) Global initializer calls a non-constexpr function 'operator new' (i.22). 1944973 Ryan Hill [prefast:Warning]: C26426 (in onnxruntime/core/providers/cuda/cuda_execution_provider_info.cc) Global initializer calls a non-constexpr function 'operator new' (i.22). 1944929 Ryan Hill [prefast:Warning]: C26436 (in onnxruntime/core/providers/cuda/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:
parent
82786baed1
commit
81a4efee6c
4 changed files with 17 additions and 17 deletions
|
|
@ -27,18 +27,16 @@ constexpr const char* kCudnnConv1dPadToNc1d = "cudnn_conv1d_pad_to_nc1d";
|
|||
} // namespace provider_option_names
|
||||
} // namespace cuda
|
||||
|
||||
namespace {
|
||||
const DeleteOnUnloadPtr<EnumNameMapping<OrtCudnnConvAlgoSearch>> ort_cudnn_conv_algo_search_mapping = new EnumNameMapping<OrtCudnnConvAlgoSearch>{
|
||||
const EnumNameMapping<OrtCudnnConvAlgoSearch> ort_cudnn_conv_algo_search_mapping{
|
||||
{OrtCudnnConvAlgoSearchExhaustive, "EXHAUSTIVE"},
|
||||
{OrtCudnnConvAlgoSearchHeuristic, "HEURISTIC"},
|
||||
{OrtCudnnConvAlgoSearchDefault, "DEFAULT"},
|
||||
};
|
||||
|
||||
const DeleteOnUnloadPtr<EnumNameMapping<ArenaExtendStrategy>> arena_extend_strategy_mapping = new EnumNameMapping<ArenaExtendStrategy>{
|
||||
const EnumNameMapping<ArenaExtendStrategy> arena_extend_strategy_mapping{
|
||||
{ArenaExtendStrategy::kNextPowerOfTwo, "kNextPowerOfTwo"},
|
||||
{ArenaExtendStrategy::kSameAsRequested, "kSameAsRequested"},
|
||||
};
|
||||
} // namespace
|
||||
|
||||
CUDAExecutionProviderInfo CUDAExecutionProviderInfo::FromProviderOptions(const ProviderOptions& options) {
|
||||
CUDAExecutionProviderInfo info{};
|
||||
|
|
@ -86,10 +84,10 @@ CUDAExecutionProviderInfo CUDAExecutionProviderInfo::FromProviderOptions(const P
|
|||
.AddAssignmentToReference(cuda::provider_option_names::kMemLimit, info.gpu_mem_limit)
|
||||
.AddAssignmentToEnumReference(
|
||||
cuda::provider_option_names::kArenaExtendStrategy,
|
||||
*arena_extend_strategy_mapping, info.arena_extend_strategy)
|
||||
arena_extend_strategy_mapping, info.arena_extend_strategy)
|
||||
.AddAssignmentToEnumReference(
|
||||
cuda::provider_option_names::kCudnnConvAlgoSearch,
|
||||
*ort_cudnn_conv_algo_search_mapping, info.cudnn_conv_algo_search)
|
||||
ort_cudnn_conv_algo_search_mapping, info.cudnn_conv_algo_search)
|
||||
.AddAssignmentToReference(cuda::provider_option_names::kDoCopyInDefaultStream, info.do_copy_in_default_stream)
|
||||
.AddAssignmentToReference(cuda::provider_option_names::kCudnnConvUseMaxWorkspace, info.cudnn_conv_use_max_workspace)
|
||||
.AddAssignmentToReference(cuda::provider_option_names::kEnableCudaGraph, info.enable_cuda_graph)
|
||||
|
|
@ -109,9 +107,9 @@ ProviderOptions CUDAExecutionProviderInfo::ToProviderOptions(const CUDAExecution
|
|||
{cuda::provider_option_names::kGpuExternalFree, MakeStringWithClassicLocale(reinterpret_cast<size_t>(info.external_allocator_info.free))},
|
||||
{cuda::provider_option_names::kGpuExternalEmptyCache, MakeStringWithClassicLocale(reinterpret_cast<size_t>(info.external_allocator_info.empty_cache))},
|
||||
{cuda::provider_option_names::kArenaExtendStrategy,
|
||||
EnumToName(*arena_extend_strategy_mapping, info.arena_extend_strategy)},
|
||||
EnumToName(arena_extend_strategy_mapping, info.arena_extend_strategy)},
|
||||
{cuda::provider_option_names::kCudnnConvAlgoSearch,
|
||||
EnumToName(*ort_cudnn_conv_algo_search_mapping, info.cudnn_conv_algo_search)},
|
||||
EnumToName(ort_cudnn_conv_algo_search_mapping, info.cudnn_conv_algo_search)},
|
||||
{cuda::provider_option_names::kDoCopyInDefaultStream, MakeStringWithClassicLocale(info.do_copy_in_default_stream)},
|
||||
{cuda::provider_option_names::kCudnnConvUseMaxWorkspace, MakeStringWithClassicLocale(info.cudnn_conv_use_max_workspace)},
|
||||
{cuda::provider_option_names::kEnableCudaGraph, MakeStringWithClassicLocale(info.enable_cuda_graph)},
|
||||
|
|
@ -125,8 +123,8 @@ ProviderOptions CUDAExecutionProviderInfo::ToProviderOptions(const OrtCUDAProvid
|
|||
const ProviderOptions options{
|
||||
{cuda::provider_option_names::kDeviceId, MakeStringWithClassicLocale(info.device_id)},
|
||||
{cuda::provider_option_names::kMemLimit, MakeStringWithClassicLocale(info.gpu_mem_limit)},
|
||||
{cuda::provider_option_names::kArenaExtendStrategy, EnumToName(*arena_extend_strategy_mapping, info.arena_extend_strategy)},
|
||||
{cuda::provider_option_names::kCudnnConvAlgoSearch, EnumToName(*ort_cudnn_conv_algo_search_mapping, info.cudnn_conv_algo_search)},
|
||||
{cuda::provider_option_names::kArenaExtendStrategy, EnumToName(arena_extend_strategy_mapping, info.arena_extend_strategy)},
|
||||
{cuda::provider_option_names::kCudnnConvAlgoSearch, EnumToName(ort_cudnn_conv_algo_search_mapping, info.cudnn_conv_algo_search)},
|
||||
{cuda::provider_option_names::kDoCopyInDefaultStream, MakeStringWithClassicLocale(info.do_copy_in_default_stream)},
|
||||
{cuda::provider_option_names::kCudnnConvUseMaxWorkspace, MakeStringWithClassicLocale(info.cudnn_conv_use_max_workspace)},
|
||||
{cuda::provider_option_names::kCudnnConv1dPadToNc1d, MakeStringWithClassicLocale(info.cudnn_conv1d_pad_to_nc1d)}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ class NvtxRangeCreator;
|
|||
}
|
||||
|
||||
struct ProviderInfo_CUDA {
|
||||
virtual ~ProviderInfo_CUDA() {} // This is declared due to a TSA warning, the only instantiation of this class is a global variable of automatic storage.
|
||||
|
||||
virtual OrtStatus* SetCurrentGpuDeviceId(_In_ int device_id) = 0;
|
||||
virtual OrtStatus* GetCurrentGpuDeviceId(_In_ int* device_id) = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ using namespace onnxruntime::common;
|
|||
namespace onnxruntime {
|
||||
namespace cuda {
|
||||
|
||||
const DeleteOnUnloadPtr<std::vector<MLDataType>> castOpTypeConstraints = new std::vector<MLDataType> {
|
||||
const std::vector<MLDataType> castOpTypeConstraints{
|
||||
DataTypeImpl::GetTensorType<MLFloat16>(),
|
||||
DataTypeImpl::GetTensorType<BFloat16>(),
|
||||
DataTypeImpl::GetTensorType<float>(),
|
||||
|
|
@ -34,7 +34,7 @@ const DeleteOnUnloadPtr<std::vector<MLDataType>> castOpTypeConstraints = new std
|
|||
kCudaExecutionProvider, \
|
||||
(*KernelDefBuilder::Create()) \
|
||||
.TypeConstraint("T1", DataTypeImpl::GetTensorType<T>()) \
|
||||
.TypeConstraint("T2", *castOpTypeConstraints), \
|
||||
.TypeConstraint("T2", castOpTypeConstraints), \
|
||||
Cast<T>); \
|
||||
ONNX_OPERATOR_VERSIONED_TYPED_KERNEL_EX( \
|
||||
Cast, \
|
||||
|
|
@ -44,7 +44,7 @@ const DeleteOnUnloadPtr<std::vector<MLDataType>> castOpTypeConstraints = new std
|
|||
kCudaExecutionProvider, \
|
||||
(*KernelDefBuilder::Create()) \
|
||||
.TypeConstraint("T1", DataTypeImpl::GetTensorType<T>()) \
|
||||
.TypeConstraint("T2", *castOpTypeConstraints), \
|
||||
.TypeConstraint("T2", castOpTypeConstraints), \
|
||||
Cast<T>); \
|
||||
ONNX_OPERATOR_TYPED_KERNEL_EX( \
|
||||
Cast, \
|
||||
|
|
@ -54,7 +54,7 @@ const DeleteOnUnloadPtr<std::vector<MLDataType>> castOpTypeConstraints = new std
|
|||
kCudaExecutionProvider, \
|
||||
(*KernelDefBuilder::Create()) \
|
||||
.TypeConstraint("T1", DataTypeImpl::GetTensorType<T>()) \
|
||||
.TypeConstraint("T2", *castOpTypeConstraints), \
|
||||
.TypeConstraint("T2", castOpTypeConstraints), \
|
||||
Cast<T>);
|
||||
|
||||
template <typename SrcT>
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ constexpr const char* kMiopenConvUseMaxWorkspace = "miopen_conv_use_max_workspac
|
|||
} // namespace rocm
|
||||
|
||||
namespace {
|
||||
const DeleteOnUnloadPtr<EnumNameMapping<ArenaExtendStrategy>> arena_extend_strategy_mapping = new EnumNameMapping<ArenaExtendStrategy>{
|
||||
const EnumNameMapping<ArenaExtendStrategy> arena_extend_strategy_mapping{
|
||||
{ArenaExtendStrategy::kNextPowerOfTwo, "kNextPowerOfTwo"},
|
||||
{ArenaExtendStrategy::kSameAsRequested, "kSameAsRequested"},
|
||||
};
|
||||
|
|
@ -77,7 +77,7 @@ ROCMExecutionProviderInfo ROCMExecutionProviderInfo::FromProviderOptions(const P
|
|||
.AddAssignmentToReference(rocm::provider_option_names::kMemLimit, info.gpu_mem_limit)
|
||||
.AddAssignmentToEnumReference(
|
||||
rocm::provider_option_names::kArenaExtendStrategy,
|
||||
*arena_extend_strategy_mapping, info.arena_extend_strategy)
|
||||
arena_extend_strategy_mapping, info.arena_extend_strategy)
|
||||
.AddAssignmentToReference(rocm::provider_option_names::kMiopenConvExhaustiveSearch, info.miopen_conv_exhaustive_search)
|
||||
.AddAssignmentToReference(rocm::provider_option_names::kDoCopyInDefaultStream, info.do_copy_in_default_stream)
|
||||
.AddAssignmentToReference(rocm::provider_option_names::kMiopenConvUseMaxWorkspace, info.miopen_conv_use_max_workspace)
|
||||
|
|
@ -96,7 +96,7 @@ ProviderOptions ROCMExecutionProviderInfo::ToProviderOptions(const ROCMExecution
|
|||
{rocm::provider_option_names::kGpuExternalFree, MakeStringWithClassicLocale(reinterpret_cast<size_t>(info.external_allocator_info.free))},
|
||||
{rocm::provider_option_names::kGpuExternalEmptyCache, MakeStringWithClassicLocale(reinterpret_cast<size_t>(info.external_allocator_info.empty_cache))},
|
||||
{rocm::provider_option_names::kArenaExtendStrategy,
|
||||
EnumToName(*arena_extend_strategy_mapping, info.arena_extend_strategy)},
|
||||
EnumToName(arena_extend_strategy_mapping, info.arena_extend_strategy)},
|
||||
{rocm::provider_option_names::kMiopenConvExhaustiveSearch, MakeStringWithClassicLocale(info.miopen_conv_exhaustive_search)},
|
||||
{rocm::provider_option_names::kDoCopyInDefaultStream, MakeStringWithClassicLocale(info.do_copy_in_default_stream)},
|
||||
{rocm::provider_option_names::kMiopenConvUseMaxWorkspace, MakeStringWithClassicLocale(info.miopen_conv_use_max_workspace)},
|
||||
|
|
|
|||
Loading…
Reference in a new issue