MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / WatchVariable

Method WatchVariable

tensorflow/python/eager/pywrap_tfe_src.cc:1247–1266  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1245 }
1246
1247 void WatchVariable(PyObject* v) {
1248 tensorflow::Safe_PyObjectPtr handle(PyObject_GetAttrString(v, "handle"));
1249 if (handle == nullptr) {
1250 return;
1251 }
1252 tensorflow::int64 id = FastTensorId(handle.get());
1253
1254 if (!PyErr_Occurred()) {
1255 this->Watch(id);
1256 }
1257
1258 tensorflow::mutex_lock l(watched_variables_mu_);
1259 auto insert_result = watched_variables_.emplace(id, v);
1260
1261 if (insert_result.second) {
1262 // Only increment the reference count if we aren't already watching this
1263 // variable.
1264 Py_INCREF(v);
1265 }
1266 }
1267
1268 PyObject* GetVariablesAsPyTuple() {
1269 tensorflow::mutex_lock l(watched_variables_mu_);

Callers 1

TFE_Py_TapeWatchVariableFunction · 0.80

Calls 4

WatchMethod · 0.95
FastTensorIdFunction · 0.85
getMethod · 0.45
emplaceMethod · 0.45

Tested by

no test coverage detected