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

Constructor & Destructor Documentation

◆ SessionCache() [1/2]

tensorflow::SessionCache::SessionCache ( )
inline

Definition at line 197 of file TensorFlow.h.

197 {}

◆ SessionCache() [2/2]

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

Definition at line 201 of file TensorFlow.h.

References createSession(), and HLT_2024v14_cff::graphPath.

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

◆ ~SessionCache()

tensorflow::SessionCache::~SessionCache ( )
inline

Definition at line 206 of file TensorFlow.h.

References closeSession().

206 { closeSession(); }

Member Function Documentation

◆ closeSession()

void tensorflow::SessionCache::closeSession ( )

Definition at line 344 of file TensorFlow.cc.

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

Referenced by ~SessionCache().

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

◆ createSession()

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

Definition at line 211 of file TensorFlow.h.

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

Referenced by SessionCache().

211  {
212  graph.store(loadGraphDef(graphPath));
213  session.store(tensorflow::createSession(graph.load(), std::forward<Args>(sessionArgs)...));
214  }
GraphDef * loadGraphDef(const std::string &pbFile)
Definition: TensorFlow.cc:129
std::atomic< Session * > session
Definition: TensorFlow.h:194
Session * createSession()
Definition: TensorFlow.cc:146
std::atomic< GraphDef * > graph
Definition: TensorFlow.h:193

◆ getSession()

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

Definition at line 217 of file TensorFlow.h.

References session.

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

Member Data Documentation

◆ graph

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

Definition at line 193 of file TensorFlow.h.

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

◆ session

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

Definition at line 194 of file TensorFlow.h.

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