Prevent OOM
This commit is contained in:
@@ -540,7 +540,7 @@ namespace ANSCENTER {
|
||||
") returned null — the DLL may be corrupt.");
|
||||
|
||||
s_ort_api = api;
|
||||
Ort::Global<void>::api_ = api;
|
||||
Ort::InitApi(api);
|
||||
|
||||
std::cout << "[EPLoader] ORT loaded successfully." << std::endl;
|
||||
std::cout << "[EPLoader] ORT DLL version : " << base->GetVersionString() << std::endl;
|
||||
|
||||
@@ -141,7 +141,7 @@ namespace ANSCENTER {
|
||||
{
|
||||
try {
|
||||
// Make sure the Ort API pointer is initialised in THIS DLL.
|
||||
if (Ort::Global<void>::api_ == nullptr) {
|
||||
if (Ort::detail::Global::Api() == nullptr) {
|
||||
Ort::InitApi(static_cast<const OrtApi*>(EPLoader::GetOrtApiRaw()));
|
||||
}
|
||||
|
||||
@@ -574,10 +574,10 @@ namespace ANSCENTER {
|
||||
const auto& epInfo = EPLoader::Current();
|
||||
ANS_DBG("OrtHandler", "initialize_handler: EPLoader type=%d dir=%s",
|
||||
static_cast<int>(epInfo.type), epInfo.libraryDir.c_str());
|
||||
if (Ort::Global<void>::api_ == nullptr)
|
||||
if (Ort::detail::Global::Api() == nullptr)
|
||||
Ort::InitApi(static_cast<const OrtApi*>(EPLoader::GetOrtApiRaw()));
|
||||
|
||||
std::cout << "[ORT] api_ = " << (void*)Ort::Global<void>::api_ << std::endl;
|
||||
std::cout << "[ORT] api_ = " << (void*)Ort::detail::Global::Api() << std::endl;
|
||||
|
||||
EngineType engine = (static_cast<int>(m_engineType) == -1)
|
||||
? epInfo.type : m_engineType;
|
||||
@@ -1900,4 +1900,12 @@ namespace ANSCENTER {
|
||||
return std::fabs(width() * height());
|
||||
}
|
||||
|
||||
// Explicit instantiations of every BoundingBoxType member must live
|
||||
// AFTER the template definitions above so the compiler actually emits
|
||||
// symbols (the directives in ONNXEngine.h sit before the definitions
|
||||
// and ClangCL, unlike MSVC, refuses to emit symbols from there).
|
||||
template struct ANSCENTER::types::BoundingBoxType<int, float>;
|
||||
template struct ANSCENTER::types::BoundingBoxType<float, float>;
|
||||
template struct ANSCENTER::types::BoundingBoxType<double, double>;
|
||||
|
||||
} // namespace ANSCENTER
|
||||
@@ -73,9 +73,10 @@ namespace ANSCENTER {
|
||||
}
|
||||
};
|
||||
|
||||
template class BoundingBoxType<int, float>;
|
||||
template class BoundingBoxType<float, float>;
|
||||
template class BoundingBoxType<double, double>;
|
||||
// Explicit instantiations now live at the end of ONNXEngine.cpp
|
||||
// (after the template member definitions) so the compiler actually
|
||||
// emits symbols. ClangCL refuses to emit them from a directive that
|
||||
// precedes the definitions, whereas MSVC silently tolerated it.
|
||||
|
||||
typedef BoundingBoxType<int, float> Boxi;
|
||||
typedef BoundingBoxType<float, float> Boxf;
|
||||
|
||||
@@ -331,7 +331,7 @@ namespace ANSCENTER
|
||||
{
|
||||
// Initialize ORT API
|
||||
const auto& epInfo = EPLoader::Current();
|
||||
if (Ort::Global<void>::api_ == nullptr)
|
||||
if (Ort::detail::Global::Api() == nullptr)
|
||||
Ort::InitApi(static_cast<const OrtApi*>(EPLoader::GetOrtApiRaw()));
|
||||
|
||||
m_env = new Ort::Env(ORT_LOGGING_LEVEL_ERROR, "ONNXSAM3");
|
||||
|
||||
Reference in New Issue
Block a user