Skip to content

Commit

Permalink
Keep arena config alive
Browse files Browse the repository at this point in the history
  • Loading branch information
baijumeswani committed Sep 28, 2024
1 parent a7ed199 commit 30ed06b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/generators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ namespace Generators {
static bool _ = (Ort::InitApi(), false);

OrtGlobals::OrtGlobals()
: env_{OrtEnv::Create(OrtLoggingLevel::ORT_LOGGING_LEVEL_ERROR)} {
auto arena_config = OrtArenaCfg::Create(0, -1, -1, -1);
: env_{OrtEnv::Create(OrtLoggingLevel::ORT_LOGGING_LEVEL_ERROR)},
arena_config_{OrtArenaCfg::Create(0, -1, -1, -1)} {
Ort::Allocator& allocator_cpu{Ort::Allocator::GetWithDefaultOptions()};
env_->CreateAndRegisterAllocator(allocator_cpu.GetInfo(), *arena_config);
env_->CreateAndRegisterAllocator(allocator_cpu.GetInfo(), *arena_config_);
}

// Ensure Shutdown() has been called before process exit
Expand Down
1 change: 1 addition & 0 deletions src/generators.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ struct OrtGlobals {
OrtGlobals();

std::unique_ptr<OrtEnv> env_;
std::unique_ptr<OrtArenaCfg> arena_config_;
#if USE_CUDA
std::unique_ptr<OrtMemoryInfo> memory_info_cuda_;
std::unique_ptr<Ort::Allocator> allocator_cuda_;
Expand Down

0 comments on commit 30ed06b

Please sign in to comment.