From dc0f7b8f825a2601ad3835836a840b7dceb33b3f Mon Sep 17 00:00:00 2001 From: Guoyu Wang <62914304+gwang-msft@users.noreply.github.com> Date: Thu, 12 Nov 2020 09:12:13 -0800 Subject: [PATCH] Remove onnxruntime_session_options_config_keys.h from c_api (#5772) * Remove seesion config keys header from c_api * remove copy session config header in release package * Keep the session option config header in the package --- include/onnxruntime/core/session/onnxruntime_c_api.h | 3 +-- onnxruntime/core/framework/session_state.cc | 1 + onnxruntime/core/session/inference_session.cc | 1 + onnxruntime/test/framework/inference_session_test.cc | 1 + onnxruntime/test/framework/ort_model_only_test.cc | 2 +- onnxruntime/test/framework/session_state_test.cc | 5 +++-- onnxruntime/test/onnx/main.cc | 4 ++-- onnxruntime/test/perftest/ort_test_session.cc | 6 +++--- onnxruntime/test/shared_lib/test_inference.cc | 3 ++- 9 files changed, 15 insertions(+), 11 deletions(-) diff --git a/include/onnxruntime/core/session/onnxruntime_c_api.h b/include/onnxruntime/core/session/onnxruntime_c_api.h index 32487aca1a..ad3a83b875 100644 --- a/include/onnxruntime/core/session/onnxruntime_c_api.h +++ b/include/onnxruntime/core/session/onnxruntime_c_api.h @@ -5,7 +5,6 @@ #include #include #include -#include "onnxruntime_session_options_config_keys.h" // This value is used in structures passed to ORT so that a newer version of ORT will still work with them #define ORT_API_VERSION 5 @@ -1084,7 +1083,7 @@ struct OrtApi { * Creates a custom environment with global threadpools and logger that will be shared across sessions. * Use this in conjunction with DisablePerSessionThreads API or else the session will use * its own thread pools. - * + * * \param out should be freed by `OrtReleaseEnv` after use */ ORT_API2_STATUS(CreateEnvWithCustomLoggerAndGlobalThreadPools, OrtLoggingFunction logging_function, _In_opt_ void* logger_param, OrtLoggingLevel logging_level, diff --git a/onnxruntime/core/framework/session_state.cc b/onnxruntime/core/framework/session_state.cc index 8a64b31bb7..9f932710ed 100644 --- a/onnxruntime/core/framework/session_state.cc +++ b/onnxruntime/core/framework/session_state.cc @@ -15,6 +15,7 @@ #include "core/framework/session_state_utils.h" #include "core/framework/utils.h" #include "core/providers/cpu/controlflow/utils.h" +#include "core/session/onnxruntime_session_options_config_keys.h" using namespace ::onnxruntime::common; using namespace ::onnxruntime::experimental; diff --git a/onnxruntime/core/session/inference_session.cc b/onnxruntime/core/session/inference_session.cc index 3777a97daa..0b70fab0b6 100644 --- a/onnxruntime/core/session/inference_session.cc +++ b/onnxruntime/core/session/inference_session.cc @@ -46,6 +46,7 @@ #include "core/session/environment.h" #include "core/session/IOBinding.h" #include "core/session/inference_session_utils.h" +#include "core/session/onnxruntime_session_options_config_keys.h" #include "core/util/protobuf_parsing_utils.h" #include "core/util/thread_utils.h" diff --git a/onnxruntime/test/framework/inference_session_test.cc b/onnxruntime/test/framework/inference_session_test.cc index 50ee050863..fbc7982c43 100644 --- a/onnxruntime/test/framework/inference_session_test.cc +++ b/onnxruntime/test/framework/inference_session_test.cc @@ -36,6 +36,7 @@ #include "core/session/IOBinding.h" #include "core/session/device_allocator.h" #include "core/session/allocator_impl.h" +#include "core/session/onnxruntime_session_options_config_keys.h" #include "dummy_provider.h" #include "test_utils.h" #include "test/capturing_sink.h" diff --git a/onnxruntime/test/framework/ort_model_only_test.cc b/onnxruntime/test/framework/ort_model_only_test.cc index 02c68d9c14..7eda4b4323 100644 --- a/onnxruntime/test/framework/ort_model_only_test.cc +++ b/onnxruntime/test/framework/ort_model_only_test.cc @@ -8,6 +8,7 @@ #include "core/framework/tensorprotoutils.h" #include "core/graph/onnx_protobuf.h" #include "core/session/inference_session.h" +#include "core/session/onnxruntime_session_options_config_keys.h" #include "core/graph/model.h" #include "test/test_environment.h" #include "test_utils.h" @@ -237,7 +238,6 @@ static void DumpOrtModelAsJson(const std::string& model_uri) { } */ - TEST(OrtModelOnlyTests, SerializeToOrtFormat) { const std::basic_string ort_file = ORT_TSTR("ort_github_issue_4031.onnx.ort"); SaveAndCompareModels("testdata/ort_github_issue_4031.onnx", ort_file); diff --git a/onnxruntime/test/framework/session_state_test.cc b/onnxruntime/test/framework/session_state_test.cc index 0d16253421..6c49d3d1ab 100644 --- a/onnxruntime/test/framework/session_state_test.cc +++ b/onnxruntime/test/framework/session_state_test.cc @@ -3,6 +3,7 @@ #include +#include "asserts.h" #include "core/framework/execution_providers.h" #include "core/framework/graph_partitioner.h" #include "core/framework/kernel_registry.h" @@ -12,9 +13,9 @@ #include "core/graph/graph_viewer.h" #include "core/graph/model.h" #include "core/graph/op.h" -#include "core/util/thread_utils.h" #include "core/providers/cpu/cpu_execution_provider.h" -#include "asserts.h" +#include "core/session/onnxruntime_session_options_config_keys.h" +#include "core/util/thread_utils.h" #include "gtest/gtest.h" #include "test/test_environment.h" diff --git a/onnxruntime/test/onnx/main.cc b/onnxruntime/test/onnx/main.cc index 0f5c5039a5..78d5eb7dbc 100644 --- a/onnxruntime/test/onnx/main.cc +++ b/onnxruntime/test/onnx/main.cc @@ -19,6 +19,7 @@ #include "core/session/onnxruntime_cxx_api.h" #include "core/optimizer/graph_transformer_level.h" #include "core/framework/session_options.h" +#include "core/session/onnxruntime_session_options_config_keys.h" using namespace onnxruntime; @@ -287,8 +288,7 @@ int real_main(int argc, char* argv[], Ort::Env& env) { double per_sample_tolerance = 1e-3; // when cuda is enabled, set it to a larger value for resolving random MNIST test failure // when openvino is enabled, set it to a larger value for resolving MNIST accuracy mismatch - double relative_per_sample_tolerance = enable_cuda ? 0.017 : enable_openvino ? 0.009 - : 1e-3; + double relative_per_sample_tolerance = enable_cuda ? 0.017 : enable_openvino ? 0.009 : 1e-3; Ort::SessionOptions sf; diff --git a/onnxruntime/test/perftest/ort_test_session.cc b/onnxruntime/test/perftest/ort_test_session.cc index b2cd4796e6..5dbd396439 100644 --- a/onnxruntime/test/perftest/ort_test_session.cc +++ b/onnxruntime/test/perftest/ort_test_session.cc @@ -1,5 +1,6 @@ #include "ort_test_session.h" #include +#include "core/session/onnxruntime_session_options_config_keys.h" #include #include "providers.h" #include "TestCase.h" @@ -51,9 +52,8 @@ OnnxRuntimeTestSession::OnnxRuntimeTestSession(Ort::Env& env, std::random_device static_cast(performance_test_config.run_config.cudnn_conv_algo), std::numeric_limits::max(), 0, - !performance_test_config.run_config.do_cuda_copy_in_separate_stream - }; - Ort::ThrowOnError(session_options.OrtSessionOptionsAppendExecutionProvider_CUDA(session_options, &cuda_options)); + !performance_test_config.run_config.do_cuda_copy_in_separate_stream}; + Ort::ThrowOnError(session_options.OrtSessionOptionsAppendExecutionProvider_CUDA(session_options, &cuda_options)); #else ORT_THROW("CUDA is not supported in this build\n"); #endif diff --git a/onnxruntime/test/shared_lib/test_inference.cc b/onnxruntime/test/shared_lib/test_inference.cc index e2d38d17b6..4525896a2a 100644 --- a/onnxruntime/test/shared_lib/test_inference.cc +++ b/onnxruntime/test/shared_lib/test_inference.cc @@ -4,6 +4,7 @@ #include #include "core/session/onnxruntime_c_api.h" #include "core/session/onnxruntime_cxx_api.h" +#include "core/session/onnxruntime_session_options_config_keys.h" #include "core/graph/constants.h" #include "providers.h" #include @@ -839,7 +840,7 @@ TEST(CApiTest, create_tensor_with_data_bfloat16) { TEST(CApiTest, access_tensor_data_elements) { /** * Create a 2x3 data blob that looks like: - * + * * 0 1 2 * 3 4 5 */