ATLAS Offline Software
OnnxRuntimeSessionToolCPU.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
8  : asg::AsgTool( name)
9 {
10 }
11 
13 {
14  // Get the Onnx Runtime service.
15  ATH_CHECK(m_onnxRuntimeSvc.retrieve());
16  ATH_MSG_INFO(" OnnxRuntime release: " << OrtGetApiBase()->GetVersionString());
17 
18  // Create the session options.
19  // TODO: Make this configurable.
20  // other threading options: https://onnxruntime.ai/docs/performance/tune-performance/threading.html
21  // 1) SetIntraOpNumThreads( 1 );
22  // 2) SetInterOpNumThreads( 1 );
23  // 3) SetGraphOptimizationLevel( GraphOptimizationLevel::ORT_ENABLE_EXTENDED );
24 
25  Ort::SessionOptions sessionOptions;
26  sessionOptions.SetGraphOptimizationLevel( GraphOptimizationLevel::ORT_ENABLE_ALL );
27 
28  // Create the session.
29  m_session = std::make_unique<Ort::Session>(m_onnxRuntimeSvc->env(), m_modelFileName.value().c_str(), sessionOptions);
30 
31  return StatusCode::SUCCESS;
32 }
33 
35 {
36  return *m_session;
37 }
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:34
python.oracle.Session
Session
Definition: oracle.py:78
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
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
AthOnnx::OnnxRuntimeSessionToolCPU::initialize
virtual StatusCode initialize() override final
Initialize the tool.
Definition: OnnxRuntimeSessionToolCPU.cxx:12