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

Constructor & Destructor Documentation

◆ SessionCache() [1/2]

tensorflow::SessionCache::SessionCache ( )
inline

Definition at line 202 of file TensorFlow.h.

202 {}

◆ SessionCache() [2/2]

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

Definition at line 206 of file TensorFlow.h.

References createSession(), and HLT_2022v15_cff::graphPath.

206  {
207  createSession(graphPath, std::forward<Args>(sessionArgs)...);
208  }
void createSession(const std::string &graphPath, Args &&... sessionArgs)
Definition: TensorFlow.h:216

◆ ~SessionCache()

tensorflow::SessionCache::~SessionCache ( )
inline

Definition at line 211 of file TensorFlow.h.

References closeSession().

211 { closeSession(); }

Member Function Documentation

◆ closeSession()

void tensorflow::SessionCache::closeSession ( )

Definition at line 345 of file TensorFlow.cc.

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

Referenced by ~SessionCache().

345  {
346  // delete the session if set
347  Session* s = session.load();
348  if (s != nullptr) {
350  session.store(nullptr);
351  }
352 
353  // delete the graph if set
354  if (graph.load() != nullptr) {
355  delete graph.load();
356  graph.store(nullptr);
357  }
358  }
std::atomic< Session * > session
Definition: TensorFlow.h:199
bool closeSession(Session *&session)
Definition: TensorFlow.cc:261
std::atomic< GraphDef * > graph
Definition: TensorFlow.h:198

◆ createSession()

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

Definition at line 216 of file TensorFlow.h.

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

Referenced by SessionCache().

216  {
217  graph.store(loadGraphDef(graphPath));
218  session.store(tensorflow::createSession(graph.load(), std::forward<Args>(sessionArgs)...));
219  }
Session * createSession(SessionOptions &sessionOptions)
Definition: TensorFlow.cc:145
GraphDef * loadGraphDef(const std::string &pbFile)
Definition: TensorFlow.cc:128
std::atomic< Session * > session
Definition: TensorFlow.h:199
std::atomic< GraphDef * > graph
Definition: TensorFlow.h:198

◆ getSession()

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

Definition at line 222 of file TensorFlow.h.

References session.

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

Member Data Documentation

◆ graph

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

Definition at line 198 of file TensorFlow.h.

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

◆ session

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

Definition at line 199 of file TensorFlow.h.

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