Skip to content

Commit

Permalink
Allow disable exceptions to work with ort-extensions (microsoft#16536)
Browse files Browse the repository at this point in the history
  • Loading branch information
baijumeswani committed Jun 30, 2023
1 parent 0051497 commit 5b3447b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 5b3447b

Please sign in to comment.