Allow disable exceptions to work with ort-extensions (#16536)

This commit is contained in:
Baiju Meswani 2023-06-29 18:24:33 -07:00 committed by GitHub
parent 0051497055
commit 5b3447beef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View file

@ -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
}
}

View file

@ -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;
}