diff --git a/include/onnxruntime/core/session/onnxruntime_c_api.h b/include/onnxruntime/core/session/onnxruntime_c_api.h index cb2a995754..e41f664873 100644 --- a/include/onnxruntime/core/session/onnxruntime_c_api.h +++ b/include/onnxruntime/core/session/onnxruntime_c_api.h @@ -1090,13 +1090,11 @@ struct OrtApi { ORT_API2_STATUS(CreateEnvWithCustomLoggerAndGlobalThreadPools, OrtLoggingFunction logging_function, _In_opt_ void* logger_param, OrtLoggingLevel logging_level, _In_ const char* logid, _In_ const struct OrtThreadingOptions* tp_options, _Outptr_ OrtEnv** out); -#ifdef USE_CUDA /** * Append CUDA execution provider */ ORT_API2_STATUS(OrtSessionOptionsAppendExecutionProvider_CUDA, _In_ OrtSessionOptions* options, _In_ OrtCUDAProviderOptions* cuda_options); -#endif // USE_CUDA /** * Use this API to configure the global thread pool options to be used in the call to CreateEnvWithGlobalThreadPools. diff --git a/include/onnxruntime/core/session/onnxruntime_cxx_api.h b/include/onnxruntime/core/session/onnxruntime_cxx_api.h index 128792ec2e..81307933e8 100644 --- a/include/onnxruntime/core/session/onnxruntime_cxx_api.h +++ b/include/onnxruntime/core/session/onnxruntime_cxx_api.h @@ -251,9 +251,8 @@ struct SessionOptions : Base { SessionOptions& AddConfigEntry(const char* config_key, const char* config_value); SessionOptions& AddInitializer(const char* name, const OrtValue* ort_val); -#ifdef USE_CUDA OrtStatus* OrtSessionOptionsAppendExecutionProvider_CUDA(OrtSessionOptions* options, OrtCUDAProviderOptions* cuda_options); -#endif + }; struct ModelMetadata : Base { diff --git a/include/onnxruntime/core/session/onnxruntime_cxx_inline.h b/include/onnxruntime/core/session/onnxruntime_cxx_inline.h index 4eb3e30a24..e0fe933d9d 100644 --- a/include/onnxruntime/core/session/onnxruntime_cxx_inline.h +++ b/include/onnxruntime/core/session/onnxruntime_cxx_inline.h @@ -477,12 +477,10 @@ inline SessionOptions& SessionOptions::AddInitializer(const char* name, const Or return *this; } - #ifdef USE_CUDA inline OrtStatus* SessionOptions::OrtSessionOptionsAppendExecutionProvider_CUDA(OrtSessionOptions * options, OrtCUDAProviderOptions * cuda_options) { - ThrowOnError(GetApi().OrtSessionOptionsAppendExecutionProvider_CUDA(options, cuda_options)); - return nullptr; + ThrowOnError(GetApi().OrtSessionOptionsAppendExecutionProvider_CUDA(options, cuda_options)); + return nullptr; } -#endif inline Session::Session(Env& env, const ORTCHAR_T* model_path, const SessionOptions& options) { ThrowOnError(GetApi().CreateSession(env, model_path, options, &p_)); diff --git a/onnxruntime/core/providers/cuda/cuda_provider_factory.cc b/onnxruntime/core/providers/cuda/cuda_provider_factory.cc index c12ae89cf0..60649511ee 100644 --- a/onnxruntime/core/providers/cuda/cuda_provider_factory.cc +++ b/onnxruntime/core/providers/cuda/cuda_provider_factory.cc @@ -68,5 +68,6 @@ ORT_API_STATUS_IMPL(OrtApis::OrtSessionOptionsAppendExecutionProvider_CUDA, cuda_options->cudnn_conv_algo_search, cuda_options->cuda_mem_limit, static_cast(cuda_options->arena_extend_strategy), cuda_options->do_copy_in_default_stream)); + return nullptr; } diff --git a/onnxruntime/core/providers/cuda/symbols.txt b/onnxruntime/core/providers/cuda/symbols.txt index 157b3c3ae5..4f9b14e967 100644 --- a/onnxruntime/core/providers/cuda/symbols.txt +++ b/onnxruntime/core/providers/cuda/symbols.txt @@ -1 +1 @@ -OrtSessionOptionsAppendExecutionProvider_CUDA \ No newline at end of file +OrtSessionOptionsAppendExecutionProvider_CUDA diff --git a/onnxruntime/core/session/onnxruntime_c_api.cc b/onnxruntime/core/session/onnxruntime_c_api.cc index 2b755b3242..872c5c39e9 100644 --- a/onnxruntime/core/session/onnxruntime_c_api.cc +++ b/onnxruntime/core/session/onnxruntime_c_api.cc @@ -14,6 +14,7 @@ #include #include +#include "core/common/common.h" #include "core/common/logging/logging.h" #include "core/common/status.h" #include "core/common/safeint.h" @@ -1805,6 +1806,15 @@ ORT_API_STATUS_IMPL(OrtApis::SessionGetProfilingStartTimeNs, _In_ const OrtSessi // End support for non-tensor types +#ifndef USE_CUDA +ORT_API_STATUS_IMPL(OrtApis::OrtSessionOptionsAppendExecutionProvider_CUDA, + _In_ OrtSessionOptions* options, _In_ OrtCUDAProviderOptions* cuda_options){ + ORT_UNUSED_PARAMETER(options); + ORT_UNUSED_PARAMETER(cuda_options); + return CreateStatus(ORT_FAIL, "CUDA execution provider is not enabled."); +} +#endif + static constexpr OrtApiBase ort_api_base = { &OrtApis::GetApi, &OrtApis::GetVersionString, @@ -2031,9 +2041,7 @@ static constexpr OrtApi ort_api_1_to_6 = { // Version 6 - In development, feel free to add/remove/rearrange here &OrtApis::AddInitializer, &OrtApis::CreateEnvWithCustomLoggerAndGlobalThreadPools, -#ifdef USE_CUDA &OrtApis::OrtSessionOptionsAppendExecutionProvider_CUDA, -#endif &OrtApis::SetGlobalDenormalAsZero, };