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 104 of file TBBSession.cc.

Constructor & Destructor Documentation

tensorflow::TBBSessionFactory::TBBSessionFactory ( )
inline

Definition at line 106 of file TBBSession.cc.

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

106 {}

Member Function Documentation

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

Definition at line 108 of file TBBSession.cc.

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

Definition at line 156 of file TBBSession.cc.

References checklumidiff::l, MatrixUtil::remove(), dataDML::session, and sessions_lock_.

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

156  {
157  mutex_lock l(sessions_lock_);
158  sessions_.erase(std::remove(sessions_.begin(), sessions_.end(), session),
159  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 112 of file TBBSession.cc.

References dqm::qstatus::ERROR, checklumidiff::l, LOG, alignCSCRings::s, dataDML::session, sessions_lock_, and btagGenBb_cfi::Status.

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

Definition at line 134 of file TBBSession.cc.

References checklumidiff::l, alignCSCRings::s, dataDML::session, sessions_lock_, btagGenBb_cfi::Status, and std::swap().

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