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 107 of file NTSession.cc.

Constructor & Destructor Documentation

tensorflow::NTSessionFactory::NTSessionFactory ( )
inline

Definition at line 109 of file NTSession.cc.

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

109 {}

Member Function Documentation

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

Definition at line 111 of file NTSession.cc.

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

Definition at line 159 of file NTSession.cc.

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

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

159  {
160  mutex_lock l(sessions_lock_);
161  sessions_.erase(std::remove(sessions_.begin(), sessions_.end(), session),
162  sessions_.end());
163  }
def remove(d, key, TELL=False)
Definition: MatrixUtil.py:209
std::vector<NTSession*> sessions_ tensorflow::NTSessionFactory::GUARDED_BY ( sessions_lock_  )
private
Session* tensorflow::NTSessionFactory::NewSession ( const SessionOptions &  options)
inlineoverride

Definition at line 115 of file NTSession.cc.

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

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

Definition at line 137 of file NTSession.cc.

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

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

Member Data Documentation

mutex tensorflow::NTSessionFactory::sessions_lock_
private

Definition at line 166 of file NTSession.cc.

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