CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes
tensorflow::SessionCache Struct Reference

#include <TensorFlow.h>

Public Member Functions

void closeSession ()
 
template<typename... Args>
void createSession (const std::string &graphPath, Args &&... sessionArgs)
 
const SessiongetSession () const
 
 SessionCache ()
 
template<typename... Args>
 SessionCache (const std::string &graphPath, Args &&... sessionArgs)
 
 ~SessionCache ()
 

Public Attributes

std::atomic< GraphDef * > graph
 
std::atomic< Session * > session
 

Detailed Description

Definition at line 190 of file TensorFlow.h.

Constructor & Destructor Documentation

◆ SessionCache() [1/2]

tensorflow::SessionCache::SessionCache ( )
inline

Definition at line 195 of file TensorFlow.h.

195 {}

◆ SessionCache() [2/2]

template<typename... Args>
tensorflow::SessionCache::SessionCache ( const std::string &  graphPath,
Args &&...  sessionArgs 
)
inline

Definition at line 199 of file TensorFlow.h.

References createSession(), and HLT_2024v10_cff::graphPath.

199  {
200  createSession(graphPath, std::forward<Args>(sessionArgs)...);
201  }
void createSession(const std::string &graphPath, Args &&... sessionArgs)
Definition: TensorFlow.h:209

◆ ~SessionCache()

tensorflow::SessionCache::~SessionCache ( )
inline

Definition at line 204 of file TensorFlow.h.

References closeSession().

204 { closeSession(); }

Member Function Documentation

◆ closeSession()

void tensorflow::SessionCache::closeSession ( )

Definition at line 318 of file TensorFlow.cc.

References tensorflow::closeSession(), graph, alignCSCRings::s, and session.

Referenced by ~SessionCache().

318  {
319  // delete the session if set
320  Session* s = session.load();
321  if (s != nullptr) {
323  session.store(nullptr);
324  }
325 
326  // delete the graph if set
327  if (graph.load() != nullptr) {
328  delete graph.load();
329  graph.store(nullptr);
330  }
331  }
std::atomic< Session * > session
Definition: TensorFlow.h:192
bool closeSession(Session *&session)
Definition: TensorFlow.cc:234
std::atomic< GraphDef * > graph
Definition: TensorFlow.h:191

◆ createSession()

template<typename... Args>
void tensorflow::SessionCache::createSession ( const std::string &  graphPath,
Args &&...  sessionArgs 
)
inline

Definition at line 209 of file TensorFlow.h.

References tensorflow::createSession(), graph, HLT_2024v10_cff::graphPath, tensorflow::loadGraphDef(), and session.

Referenced by SessionCache().

209  {
210  graph.store(loadGraphDef(graphPath));
211  session.store(tensorflow::createSession(graph.load(), std::forward<Args>(sessionArgs)...));
212  }
GraphDef * loadGraphDef(const std::string &pbFile)
Definition: TensorFlow.cc:120
std::atomic< Session * > session
Definition: TensorFlow.h:192
Session * createSession()
Definition: TensorFlow.cc:137
std::atomic< GraphDef * > graph
Definition: TensorFlow.h:191

◆ getSession()

const Session* tensorflow::SessionCache::getSession ( ) const
inline

Definition at line 215 of file TensorFlow.h.

References session.

215 { return session.load(); }
std::atomic< Session * > session
Definition: TensorFlow.h:192

Member Data Documentation

◆ graph

std::atomic<GraphDef*> tensorflow::SessionCache::graph

Definition at line 191 of file TensorFlow.h.

Referenced by closeSession(), createSession(), and cuy.FindIssue::startElement().

◆ session

std::atomic<Session*> tensorflow::SessionCache::session

Definition at line 192 of file TensorFlow.h.

Referenced by closeSession(), createSession(), and getSession().