tp_init for EagerTensor.
| 497 | |
| 498 | // tp_init for EagerTensor. |
| 499 | int EagerTensor_init(EagerTensor* self, PyObject* args, PyObject* kwds) { |
| 500 | self->id = get_uid(); |
| 501 | self->handle = nullptr; |
| 502 | Py_INCREF(Py_None); |
| 503 | self->handle_data = Py_None; |
| 504 | Py_INCREF(Py_None); |
| 505 | self->tensor_shape = Py_None; |
| 506 | self->status = TF_NewStatus(); |
| 507 | self->dict = nullptr; |
| 508 | self->weakreflist = nullptr; |
| 509 | self->context = nullptr; |
| 510 | PyObject* value; |
| 511 | const char* device_name = nullptr; |
| 512 | tensorflow::DataType dtype = tensorflow::DataType::DT_INVALID; |
| 513 | const char* kwlist[] = {"value", "device", "dtype", nullptr}; |
| 514 | if (!PyArg_ParseTupleAndKeywords( |
| 515 | args, kwds, "OO&|O&", const_cast<char**>(kwlist), &value, |
| 516 | ConvertDeviceName, &device_name, ConvertDataType, &dtype)) { |
| 517 | return -1; |
| 518 | } |
| 519 | |
| 520 | PyObject* py_context = GetPyEagerContext(); |
| 521 | if (py_context == nullptr) return -1; |
| 522 | self->context = py_context; |
| 523 | |
| 524 | auto* handle = tensorflow::ConvertToEagerTensor(GetContextHandle(py_context), |
| 525 | value, dtype, device_name); |
| 526 | if (handle == nullptr) return -1; |
| 527 | self->handle = handle; |
| 528 | |
| 529 | if (!MaybeInvokeCreatedOnEagerTensorProfiler(self)) { |
| 530 | return -1; |
| 531 | } |
| 532 | |
| 533 | return 0; |
| 534 | } |
| 535 | |
| 536 | // tp_dealloc for EagerTensor. |
| 537 | void EagerTensor_dealloc(EagerTensor* self) { |
nothing calls this directly
no test coverage detected