CMS 3D CMS Logo

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

Public Member Functions

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

Private Member Functions

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

Private Attributes

mutex sessions_lock_
 

Detailed Description

Definition at line 108 of file NTSession.cc.

Constructor & Destructor Documentation

tensorflow::NTSessionFactory::NTSessionFactory ( )
inline

Definition at line 110 of file NTSession.cc.

Referenced by tensorflow::NTSessionRegistrar::NTSessionRegistrar().

110 {}

Member Function Documentation

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

Definition at line 112 of file NTSession.cc.

112 { return options.target == "no_threads"; }
void tensorflow::NTSessionFactory::Deregister ( const NTSession session)
inline

Definition at line 155 of file NTSession.cc.

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

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

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

Definition at line 114 of file NTSession.cc.

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

114  {
115  // Must do this before the CPU allocator is created.
116  if (options.config.graph_options().build_cost_model() > 0) {
117  EnableCPUAllocatorFullStats(true);
118  }
119  std::vector<Device*> devices;
120  const Status s = DeviceFactory::AddDevices(options, "/job:localhost/replica:0/task:0", &devices);
121  if (!s.ok()) {
122  LOG(ERROR) << s;
123  return nullptr;
124  }
125 
126  NTSession* session = new NTSession(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::NTSessionFactory::Reset ( const SessionOptions &  options,
const std::vector< string > &  containers 
)
inlineoverride

Definition at line 134 of file NTSession.cc.

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

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

Member Data Documentation

mutex tensorflow::NTSessionFactory::sessions_lock_
private

Definition at line 161 of file NTSession.cc.

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