| 891 | } |
| 892 | |
| 893 | PyObject* 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 | |
| 923 | tensorflow::int64 PyEagerTensor_ID(const PyObject* tensor) { |
| 924 | DCHECK(EagerTensor_CheckExact(tensor)); |
no test coverage detected