ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
AthOnnx::OnnxRuntimeSvc Class Reference

Service implementing AthOnnx::IOnnxRuntimeSvc. More...

#include <OnnxRuntimeSvc.h>

Inheritance diagram for AthOnnx::OnnxRuntimeSvc:
Collaboration diagram for AthOnnx::OnnxRuntimeSvc:

Public Member Functions

virtual void print () const
 Print the state of the service. More...
 
template<typename T >
void declareServiceInterface ()
 add the given interface to the list of interfaces More...
 
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvi)
 query interface for gaudi More...
 
MsgStream & msg () const
 
MsgStream & msg (const MSG::Level lvl) const
 
bool msgLvl (const MSG::Level lvl) const
 
 DeclareInterfaceID (AthOnnx::IOnnxRuntimeSvc, 1, 0)
 Declare the interface that this class provides. More...
 
Function(s) inherited from @c Service
 OnnxRuntimeSvc (const std::string &name, ISvcLocator *svc)
 
virtual StatusCode initialize () override
 Function initialising the service. More...
 
virtual StatusCode finalize () override
 Function finalising the service. More...
 
Function(s) inherited from @c AthOnnx::IOnnxRuntimeSvc
virtual Ort::Env & env () const override
 Return the Onnx Runtime environment object. More...
 

Private Attributes

std::unique_ptr< Ort::Env > m_env
 Global runtime environment for Onnx Runtime. More...
 
std::vector< std::pair< const InterfaceID &(*)(), void *(*)(AsgService *)> > m_interfaces
 list of interfaces we have More...
 

Detailed Description

Service implementing AthOnnx::IOnnxRuntimeSvc.

This is a very simple implementation, just managing the lifetime of some Onnx Runtime C++ objects.

Author
Attila Krasznahorkay Attil.nosp@m.a.Kr.nosp@m.aszna.nosp@m.hork.nosp@m.ay@ce.nosp@m.rn.c.nosp@m.h

Definition at line 27 of file OnnxRuntimeSvc.h.

Constructor & Destructor Documentation

◆ OnnxRuntimeSvc()

AthOnnx::OnnxRuntimeSvc::OnnxRuntimeSvc ( const std::string &  name,
ISvcLocator *  svc 
)

Definition at line 8 of file OnnxRuntimeSvc.cxx.

8  :
10  {
11  declareServiceInterface<AthOnnx::IOnnxRuntimeSvc>();
12  }

Member Function Documentation

◆ DeclareInterfaceID()

AthOnnx::IOnnxRuntimeSvc::DeclareInterfaceID ( AthOnnx::IOnnxRuntimeSvc  ,
,
 
)
inherited

Declare the interface that this class provides.

◆ declareServiceInterface()

template<typename T >
void asg::AsgService::declareServiceInterface
inherited

add the given interface to the list of interfaces

Definition at line 76 of file AsgService.h.

77  {
78 #ifndef XAOD_STANDALONE
79  m_interfaces.emplace_back (T::interfaceID, [] (AsgService *self) -> void* {return dynamic_cast<T*>(self);});
80 #endif
81  }

◆ env()

Ort::Env & AthOnnx::OnnxRuntimeSvc::env ( ) const
overridevirtual

Return the Onnx Runtime environment object.

Implements AthOnnx::IOnnxRuntimeSvc.

Definition at line 38 of file OnnxRuntimeSvc.cxx.

38  {
39 
40  return *m_env;
41  }

◆ finalize()

StatusCode AthOnnx::OnnxRuntimeSvc::finalize ( )
overridevirtual

Function finalising the service.

Reimplemented from asg::AsgService.

Definition at line 28 of file OnnxRuntimeSvc.cxx.

28  {
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  }

◆ initialize()

StatusCode AthOnnx::OnnxRuntimeSvc::initialize ( )
overridevirtual

Function initialising the service.

Reimplemented from asg::AsgService.

Definition at line 13 of file OnnxRuntimeSvc.cxx.

13  {
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  }

◆ msg() [1/2]

MsgStream& AthCommonMsg< Service >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24  {
25  return this->msgStream();
26  }

◆ msg() [2/2]

MsgStream& AthCommonMsg< Service >::msg ( const MSG::Level  lvl) const
inlineinherited

Definition at line 27 of file AthCommonMsg.h.

27  {
28  return this->msgStream(lvl);
29  }

◆ msgLvl()

bool AthCommonMsg< Service >::msgLvl ( const MSG::Level  lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30  {
31  return this->msgLevel(lvl);
32  }

◆ print()

void asg::AsgService::print ( ) const
virtualinherited

Print the state of the service.

Implements asg::IAsgService.

Definition at line 48 of file AsgService.cxx.

49  {
50  ATH_MSG_INFO( "AsgService " << name() << " @ " << this );
51  return;
52  }

◆ queryInterface()

StatusCode asg::AsgService::queryInterface ( const InterfaceID &  riid,
void **  ppvi 
)
virtualinherited

query interface for gaudi

Definition at line 57 of file AsgService.cxx.

59  {
60  for (const auto& interface : m_interfaces)
61  {
62  if (riid == interface.first())
63  {
64  *ppvi = interface.second (this);
65  addRef();
66  return StatusCode::SUCCESS;
67  }
68  }
69  return AsgServiceBase::queryInterface (riid, ppvi);
70  }

Member Data Documentation

◆ m_env

std::unique_ptr< Ort::Env > AthOnnx::OnnxRuntimeSvc::m_env
private

Global runtime environment for Onnx Runtime.

Definition at line 52 of file OnnxRuntimeSvc.h.

◆ m_interfaces

std::vector<std::pair<const InterfaceID& (*)(),void *(*)(AsgService*)> > asg::AsgService::m_interfaces
privateinherited

list of interfaces we have

Definition at line 68 of file AsgService.h.


The documentation for this class was generated from the following files:
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
asg::AsgService::m_interfaces
std::vector< std::pair< const InterfaceID &(*)(), void *(*)(AsgService *)> > m_interfaces
list of interfaces we have
Definition: AsgService.h:68
asg::AsgService
Base class for the dual-use service implementation classes.
Definition: AsgService.h:43
AthOnnx::OnnxRuntimeSvc::m_env
std::unique_ptr< Ort::Env > m_env
Global runtime environment for Onnx Runtime.
Definition: OnnxRuntimeSvc.h:52
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
asg::AsgService::AsgService
AsgService(const std::string &name, ISvcLocator *pSvcLocator)
Definition: AsgService.cxx:19
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35