CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
tensorflow::TBBSessionFactory Class Reference
Inheritance diagram for tensorflow::TBBSessionFactory:

Public Member Functions

bool AcceptsOptions (const SessionOptions &options) override
 
void Deregister (const TBBSession *session)
 
SessionNewSession (const SessionOptions &options) override
 
Status Reset (const SessionOptions &options, const std::vector< string > &containers) override
 
 TBBSessionFactory ()
 

Private Member Functions

std::vector< TBBSession * > sessions_ GUARDED_BY (sessions_lock_)
 

Private Attributes

mutex sessions_lock_
 

Detailed Description

Definition at line 110 of file TBBSession.cc.

Constructor & Destructor Documentation

tensorflow::TBBSessionFactory::TBBSessionFactory ( )
inline

Definition at line 112 of file TBBSession.cc.

Referenced by tensorflow::TBBSessionRegistrar::TBBSessionRegistrar().

112 {}

Member Function Documentation

bool tensorflow::TBBSessionFactory::AcceptsOptions ( const SessionOptions &  options)
inlineoverride

Definition at line 114 of file TBBSession.cc.

114 { return options.target == "tbb"; }
void tensorflow::TBBSessionFactory::Deregister ( const TBBSession session)
inline

Definition at line 157 of file TBBSession.cc.

References cmsLHEtoEOSManager::l, MatrixUtil::remove(), and sessions_lock_.

Referenced by tensorflow::TBBSession::Close().

157  {
158  mutex_lock l(sessions_lock_);
159  sessions_.erase(std::remove(sessions_.begin(), sessions_.end(), session), sessions_.end());
160  }
def remove(d, key, TELL=False)
Definition: MatrixUtil.py:212
std::vector<TBBSession*> sessions_ tensorflow::TBBSessionFactory::GUARDED_BY ( sessions_lock_  )
private
Session* tensorflow::TBBSessionFactory::NewSession ( const SessionOptions &  options)
inlineoverride

Definition at line 116 of file TBBSession.cc.

References dqm::qstatus::ERROR, cmsLHEtoEOSManager::l, LOG, alignCSCRings::s, sessions_lock_, and btagGenBb_cfi::Status.

116  {
117  // Must do this before the CPU allocator is created.
118  if (options.config.graph_options().build_cost_model() > 0) {
119  EnableCPUAllocatorFullStats(true);
120  }
121  std::vector<Device*> devices;
122  const Status s = DeviceFactory::AddDevices(options, "/job:localhost/replica:0/task:0", &devices);
123  if (!s.ok()) {
124  LOG(ERROR) << s;
125  return nullptr;
126  }
127 
128  TBBSession* session = new TBBSession(options, new DeviceMgr(devices), this);
129  {
130  mutex_lock l(sessions_lock_);
131  sessions_.push_back(session);
132  }
133  return session;
134  }
#define LOG(A)
static const int ERROR
Status tensorflow::TBBSessionFactory::Reset ( const SessionOptions &  options,
const std::vector< string > &  containers 
)
inlineoverride

Definition at line 136 of file TBBSession.cc.

References cmsLHEtoEOSManager::l, alignCSCRings::s, sessions_lock_, btagGenBb_cfi::Status, and std::swap().

136  {
137  std::vector<TBBSession*> sessions_to_reset;
138  {
139  mutex_lock l(sessions_lock_);
140  // We create a copy to ensure that we don't have a deadlock when
141  // session->Close calls the TBBSessionFactory.Deregister, which
142  // acquires sessions_lock_.
143  std::swap(sessions_to_reset, sessions_);
144  }
145  Status s;
146  for (auto session : sessions_to_reset) {
147  s.Update(session->Reset(containers));
148  }
149  // TODO(suharshs): Change the Reset behavior of all SessionFactories so that
150  // it doesn't close the sessions?
151  for (auto session : sessions_to_reset) {
152  s.Update(session->Close());
153  }
154  return s;
155  }
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)

Member Data Documentation

mutex tensorflow::TBBSessionFactory::sessions_lock_
private

Definition at line 163 of file TBBSession.cc.

Referenced by Deregister(), NewSession(), and Reset().