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

Function EagerTensor_shape_tuple

tensorflow/python/eager/pywrap_tensor.cc:580–604  ·  view source on GitHub ↗

Getter for `_shape_tuple`.

Source from the content-addressed store, hash-verified

578
579// Getter for `_shape_tuple`.
580static PyObject* EagerTensor_shape_tuple(EagerTensor* self) {
581 auto handle = self->handle;
582 int n = TFE_TensorHandleNumDims(handle, self->status);
583 if (MaybeRaiseExceptionFromTFStatus(self->status, PyExc_ValueError)) {
584 // Cleanup self->status before returning.
585 TF_SetStatus(self->status, TF_OK, "");
586 return nullptr;
587 }
588 PyObject* shape = PyTuple_New(n);
589 if (PyErr_Occurred()) return nullptr;
590 for (int i = 0; i < n; ++i) {
591 PyObject* dim =
592 PyLong_FromLongLong(TFE_TensorHandleDim(handle, i, self->status));
593 if (MaybeRaiseExceptionFromTFStatus(self->status, PyExc_ValueError) ||
594 dim == nullptr || PyTuple_SetItem(shape, i, dim) != 0) {
595 // Cleanup self->status before returning.
596 TF_SetStatus(self->status, TF_OK, "");
597 Py_DECREF(shape);
598 if (dim != nullptr) Py_DECREF(dim);
599 PyErr_SetString(PyExc_RuntimeError, "Error while creating shape");
600 return nullptr;
601 }
602 }
603 return shape;
604}
605
606// Getter for `_rank`.
607static PyObject* EagerTensor_rank(EagerTensor* self) {

Callers

nothing calls this directly

Calls 4

TFE_TensorHandleNumDimsFunction · 0.85
TF_SetStatusFunction · 0.85
TFE_TensorHandleDimFunction · 0.85

Tested by

no test coverage detected