ATLAS Offline Software
OnnxRuntimeSessionToolCPU.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 
9  : asg::AsgTool( name)
10 {
11 }
12 
14 {
15  // Get the Onnx Runtime service.
16  ATH_CHECK(m_onnxRuntimeSvc.retrieve());
17  ATH_MSG_INFO(" OnnxRuntime release: " << OrtGetApiBase()->GetVersionString());
18  Ort::SessionOptions sessionOptions;
19  sessionOptions.SetGraphOptimizationLevel( GraphOptimizationLevel::ORT_ENABLE_ALL );
20  sessionOptions.DisablePerSessionThreads(); // use global thread pool.
21 
22  // Create the session.
23  ATH_MSG_INFO("Asking model from: " << m_modelFileName.value());
24  std::string modelFilePath = PathResolver::find_calib_file(m_modelFileName.value());
25  ATH_MSG_INFO("Loading model from: " << modelFilePath);
26  m_session = std::make_unique<Ort::Session>(m_onnxRuntimeSvc->env(), modelFilePath.c_str(), sessionOptions);
27 
28  return StatusCode::SUCCESS;
29 }
30 
32 {
33  return *m_session;
34 }
PathResolver::find_calib_file
static std::string find_calib_file(const std::string &logical_file_name)
Definition: PathResolver.cxx:235
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
asg
Definition: DataHandleTestTool.h:28
AthOnnx::OnnxRuntimeSessionToolCPU::session
virtual Ort::Session & session() const override final
Create Onnx Runtime session.
Definition: OnnxRuntimeSessionToolCPU.cxx:31
python.oracle.Session
Session
Definition: oracle.py:76
OnnxRuntimeSessionToolCPU.h
AthOnnx::OnnxRuntimeSessionToolCPU::OnnxRuntimeSessionToolCPU
OnnxRuntimeSessionToolCPU()=delete
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
PathResolver.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
AthOnnx::OnnxRuntimeSessionToolCPU::initialize
virtual StatusCode initialize() override final
Initialize the tool.
Definition: OnnxRuntimeSessionToolCPU.cxx:13