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 186 of file TensorFlow.h.

Constructor & Destructor Documentation

◆ SessionCache() [1/2]

tensorflow::SessionCache::SessionCache ( )
inline

Definition at line 191 of file TensorFlow.h.

191 {}

◆ SessionCache() [2/2]

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

Definition at line 195 of file TensorFlow.h.

References createSession(), and HLT_2022v15_cff::graphPath.

195  {
196  createSession(graphPath, std::forward<Args>(sessionArgs)...);
197  }
void createSession(const std::string &graphPath, Args &&... sessionArgs)
Definition: TensorFlow.h:205

◆ ~SessionCache()

tensorflow::SessionCache::~SessionCache ( )
inline

Definition at line 200 of file TensorFlow.h.

References closeSession().

200 { closeSession(); }

Member Function Documentation

◆ closeSession()

void tensorflow::SessionCache::closeSession ( )

Definition at line 281 of file TensorFlow.cc.

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

Referenced by ~SessionCache().

281  {
282  // delete the session if set
283  Session* s = session.load();
284  if (s != nullptr) {
286  session.store(nullptr);
287  }
288 
289  // delete the graph if set
290  if (graph.load() != nullptr) {
291  delete graph.load();
292  graph.store(nullptr);
293  }
294  }
std::atomic< Session * > session
Definition: TensorFlow.h:188
bool closeSession(Session *&session)
Definition: TensorFlow.cc:197
std::atomic< GraphDef * > graph
Definition: TensorFlow.h:187

◆ createSession()

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

Definition at line 205 of file TensorFlow.h.

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

Referenced by SessionCache().

205  {
206  graph.store(loadGraphDef(graphPath));
207  session.store(tensorflow::createSession(graph.load(), std::forward<Args>(sessionArgs)...));
208  }
Session * createSession(SessionOptions &sessionOptions)
Definition: TensorFlow.cc:84
GraphDef * loadGraphDef(const std::string &pbFile)
Definition: TensorFlow.cc:67
std::atomic< Session * > session
Definition: TensorFlow.h:188
std::atomic< GraphDef * > graph
Definition: TensorFlow.h:187

◆ getSession()

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

Definition at line 211 of file TensorFlow.h.

References session.

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

Member Data Documentation

◆ graph

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

Definition at line 187 of file TensorFlow.h.

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

◆ session

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

Definition at line 188 of file TensorFlow.h.

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