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

Function EagerTensorFromHandle

tensorflow/python/eager/pywrap_tensor.cc:893–921  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

891}
892
893PyObject* EagerTensorFromHandle(TFE_TensorHandle* handle) {
894 if (handle == nullptr) {
895 return nullptr;
896 }
897 EagerTensor* t = reinterpret_cast<EagerTensor*>(
898 EagerTensorType->tp_new(EagerTensorType, Py_None, Py_None));
899 if (t != nullptr) {
900 t->id = get_uid();
901 Py_INCREF(Py_None);
902 t->handle_data = Py_None;
903 Py_INCREF(Py_None);
904 t->tensor_shape = Py_None;
905 t->handle = handle;
906 t->status = TF_NewStatus();
907 t->weakreflist = nullptr;
908 PyObject* py_context = GetPyEagerContext();
909 if (py_context == nullptr) {
910 LOG(ERROR) << "Cannot create an eager tensor before eager context has "
911 "been set or after it has been deleted";
912 return nullptr;
913 }
914 t->context = py_context;
915
916 if (!MaybeInvokeCreatedOnEagerTensorProfiler(t)) {
917 return nullptr;
918 }
919 }
920 return reinterpret_cast<PyObject*>(t);
921}
922
923tensorflow::int64 PyEagerTensor_ID(const PyObject* tensor) {
924 DCHECK(EagerTensor_CheckExact(tensor));

Callers 6

ReadVariableOpFunction · 0.85
ConvertToTensorFunction · 0.85
TFE_Py_FastPathExecute_CFunction · 0.85
TFE_Py_TensorShapeSliceFunction · 0.85
MakeArgTupleFunction · 0.85

Calls 4

TF_NewStatusFunction · 0.85
GetPyEagerContextFunction · 0.85
get_uidFunction · 0.70

Tested by

no test coverage detected