ATLAS Offline Software
OnnxRuntimeSvc.cxx
Go to the documentation of this file.
1 // Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 
3 // Local include(s).
5 #include <onnxruntime_c_api.h>
6 
7 namespace AthOnnx {
8  OnnxRuntimeSvc::OnnxRuntimeSvc(const std::string& name, ISvcLocator* svc) :
9  base_class(name, svc)
10  {
11  }
12 
14 
15  // Create the environment object.
16  Ort::ThreadingOptions tp_options;
17  tp_options.SetGlobalIntraOpNumThreads(1);
18  tp_options.SetGlobalInterOpNumThreads(1);
19 
20  m_env = std::make_unique< Ort::Env >(
21  tp_options, ORT_LOGGING_LEVEL_WARNING, name().c_str());
22  ATH_MSG_DEBUG( "Ort::Env object created" );
23 
24  // Return gracefully.
25  return StatusCode::SUCCESS;
26  }
27 
29 
30  // Dekete the environment object.
31  m_env.reset();
32  ATH_MSG_DEBUG( "Ort::Env object deleted" );
33 
34  // Return gracefully.
35  return StatusCode::SUCCESS;
36  }
37 
38  Ort::Env& OnnxRuntimeSvc::env() const {
39 
40  return *m_env;
41  }
42 
43 } // namespace AthOnnx
AthOnnx::OnnxRuntimeSvc::finalize
virtual StatusCode finalize() override
Function finalising the service.
Definition: OnnxRuntimeSvc.cxx:28
AthOnnx::OnnxRuntimeSvc::m_env
std::unique_ptr< Ort::Env > m_env
Global runtime environment for Onnx Runtime.
Definition: OnnxRuntimeSvc.h:52
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
AthOnnx::OnnxRuntimeSvc::env
virtual Ort::Env & env() const override
Return the Onnx Runtime environment object.
Definition: OnnxRuntimeSvc.cxx:38
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
OnnxRuntimeSvc.h
AthOnnx::OnnxRuntimeSvc::initialize
virtual StatusCode initialize() override
Function initialising the service.
Definition: OnnxRuntimeSvc.cxx:13
AthOnnx::OnnxRuntimeSvc::OnnxRuntimeSvc
OnnxRuntimeSvc(const std::string &name, ISvcLocator *svc)
Definition: OnnxRuntimeSvc.cxx:8
AthOnnx
Namespace holding all of the Onnx Runtime example code.
Definition: EvaluateModel.cxx:11