tp_dealloc for EagerTensor.
| 535 | |
| 536 | // tp_dealloc for EagerTensor. |
| 537 | void 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`. |
| 570 | static PyObject* EagerTensor_getid(EagerTensor* self, void* closure) { |
nothing calls this directly
no test coverage detected