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

Function EagerTensor_dealloc

tensorflow/python/eager/pywrap_tensor.cc:537–567  ·  view source on GitHub ↗

tp_dealloc for EagerTensor.

Source from the content-addressed store, hash-verified

535
536// tp_dealloc for EagerTensor.
537void EagerTensor_dealloc(EagerTensor* self) {
538 // Unhook the object from python's GC so that the weakref deleter doesn't
539 // try to re-delete this.
540 PyObject_GC_UnTrack((PyObject*)self);
541
542 // Clear weak references to self.
543 // Needs to happen before any actual destruction.
544 PyObject_ClearWeakRefs((PyObject*)self);
545
546 TF_DeleteStatus(self->status);
547 Py_DECREF(self->handle_data);
548 Py_DECREF(self->tensor_shape);
549 // If an attribute dictionary has been created, release it. Note that this
550 // is only ever created by CPython's attribute setting methods; we don't
551 // create it ourselves.
552 Py_CLEAR(self->dict);
553 if (self->handle != nullptr) {
554 TFE_DeleteTensorHandle(self->handle);
555 self->handle = nullptr;
556 }
557
558 // Decref context after deleting the tensor handle.
559 Py_XDECREF(self->context);
560
561 // We have the global interpreter lock, so use this chance to perform delayed
562 // refcount decrements.
563 tensorflow::ClearDecrefCache();
564 auto id = self->id;
565 Py_TYPE(self)->tp_free(self);
566 TFE_Py_TapeSetDeleteTrace(id);
567}
568
569// Getter for `_id`.
570static PyObject* EagerTensor_getid(EagerTensor* self, void* closure) {

Callers

nothing calls this directly

Calls 4

TF_DeleteStatusFunction · 0.85
TFE_DeleteTensorHandleFunction · 0.85
ClearDecrefCacheFunction · 0.85

Tested by

no test coverage detected