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

Function EagerTensor_init

tensorflow/python/eager/pywrap_tensor.cc:499–534  ·  view source on GitHub ↗

tp_init for EagerTensor.

Source from the content-addressed store, hash-verified

497
498// tp_init for EagerTensor.
499int 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.
537void EagerTensor_dealloc(EagerTensor* self) {

Callers

nothing calls this directly

Calls 6

TF_NewStatusFunction · 0.85
GetPyEagerContextFunction · 0.85
ConvertToEagerTensorFunction · 0.85
GetContextHandleFunction · 0.85
get_uidFunction · 0.70

Tested by

no test coverage detected