CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
BaseMVACache Class Reference

#include <BaseMVAValueMapProducer.h>

Public Member Functions

 BaseMVACache (const std::string &model_path, const std::string &backend)
 
const cms::Ort::ONNXRuntimegetONNXSession () const
 
tensorflow::Session * getTFSession () const
 
 ~BaseMVACache ()
 

Private Attributes

std::shared_ptr< tensorflow::GraphDef > graph_
 
std::unique_ptr< cms::Ort::ONNXRuntimeort_
 
tensorflow::Session * tf_session_ = nullptr
 

Detailed Description

Definition at line 56 of file BaseMVAValueMapProducer.h.

Constructor & Destructor Documentation

◆ BaseMVACache()

BaseMVACache::BaseMVACache ( const std::string &  model_path,
const std::string &  backend 
)
inline

Definition at line 58 of file BaseMVAValueMapProducer.h.

References jetsAK4_CHS_cff::backend, tensorflow::createSession(), graph_, tensorflow::loadGraphDef(), HLT_2022v12_cff::model_path, ort_, and tf_session_.

58  {
59  if (backend == "TF") {
62  } else if (backend == "ONNX") {
63  ort_ = std::make_unique<cms::Ort::ONNXRuntime>(model_path);
64  }
65  }
Session * createSession(SessionOptions &sessionOptions)
Definition: TensorFlow.cc:85
std::shared_ptr< tensorflow::GraphDef > graph_
GraphDef * loadGraphDef(const std::string &pbFile)
Definition: TensorFlow.cc:68
std::unique_ptr< cms::Ort::ONNXRuntime > ort_
tensorflow::Session * tf_session_

◆ ~BaseMVACache()

BaseMVACache::~BaseMVACache ( )
inline

Definition at line 66 of file BaseMVAValueMapProducer.h.

References tensorflow::closeSession(), and tf_session_.

bool closeSession(Session *&session)
Definition: TensorFlow.cc:198
tensorflow::Session * tf_session_

Member Function Documentation

◆ getONNXSession()

const cms::Ort::ONNXRuntime& BaseMVACache::getONNXSession ( ) const
inline

Definition at line 69 of file BaseMVAValueMapProducer.h.

References ort_.

69 { return *ort_; }
std::unique_ptr< cms::Ort::ONNXRuntime > ort_

◆ getTFSession()

tensorflow::Session* BaseMVACache::getTFSession ( ) const
inline

Definition at line 68 of file BaseMVAValueMapProducer.h.

References tf_session_.

68 { return tf_session_; }
tensorflow::Session * tf_session_

Member Data Documentation

◆ graph_

std::shared_ptr<tensorflow::GraphDef> BaseMVACache::graph_
private

Definition at line 72 of file BaseMVAValueMapProducer.h.

Referenced by BaseMVACache().

◆ ort_

std::unique_ptr<cms::Ort::ONNXRuntime> BaseMVACache::ort_
private

Definition at line 74 of file BaseMVAValueMapProducer.h.

Referenced by BaseMVACache(), and getONNXSession().

◆ tf_session_

tensorflow::Session* BaseMVACache::tf_session_ = nullptr
private

Definition at line 73 of file BaseMVAValueMapProducer.h.

Referenced by BaseMVACache(), getTFSession(), and ~BaseMVACache().