From 5b3447beef68e050e5cb880426d72dbab26d4763 Mon Sep 17 00:00:00 2001 From: Baiju Meswani Date: Thu, 29 Jun 2023 18:24:33 -0700 Subject: [PATCH] Allow disable exceptions to work with ort-extensions (#16536) --- .../custom_op_get_const_input_test_library/custom_op.cc | 5 +++++ .../custom_op_get_const_input_test_library/custom_op_lib.cc | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/onnxruntime/test/testdata/custom_op_get_const_input_test_library/custom_op.cc b/onnxruntime/test/testdata/custom_op_get_const_input_test_library/custom_op.cc index 4968127c2d..08d8bf38d4 100644 --- a/onnxruntime/test/testdata/custom_op_get_const_input_test_library/custom_op.cc +++ b/onnxruntime/test/testdata/custom_op_get_const_input_test_library/custom_op.cc @@ -5,7 +5,12 @@ void simple_assert(const bool cond, const std::string& text) { if (!cond) { +#ifndef ORT_NO_EXCEPTIONS throw std::runtime_error(text); +#else + std::cerr << text << std::endl; + std::terminate(); +#endif } } diff --git a/onnxruntime/test/testdata/custom_op_get_const_input_test_library/custom_op_lib.cc b/onnxruntime/test/testdata/custom_op_get_const_input_test_library/custom_op_lib.cc index 34b33a2bdc..2964e19c76 100644 --- a/onnxruntime/test/testdata/custom_op_get_const_input_test_library/custom_op_lib.cc +++ b/onnxruntime/test/testdata/custom_op_get_const_input_test_library/custom_op_lib.cc @@ -25,17 +25,21 @@ OrtStatus* ORT_API_CALL RegisterCustomOps(OrtSessionOptions* options, const OrtA OrtStatus* result = nullptr; +#ifndef ORT_NO_EXCEPTIONS try { +#endif Ort::CustomOpDomain domain{c_OpDomain}; domain.Add(&c_CustomOp); session_options.Add(domain); AddOrtCustomOpDomainToContainer(std::move(domain)); +#ifndef ORT_NO_EXCEPTIONS } catch (const std::exception& e) { Ort::Status status{e}; result = status.release(); } +#endif return result; }