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

Class PyTapeTensor

tensorflow/python/eager/pywrap_tfe_src.cc:964–997  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

962}
963
964class PyTapeTensor {
965 public:
966 PyTapeTensor(tensorflow::int64 id, tensorflow::DataType dtype,
967 const tensorflow::TensorShape& shape)
968 : id_(id), dtype_(dtype), shape_(shape) {}
969 PyTapeTensor(tensorflow::int64 id, tensorflow::DataType dtype,
970 PyObject* shape)
971 : id_(id), dtype_(dtype), shape_(shape) {
972 Py_INCREF(absl::get<1>(shape_));
973 }
974 PyTapeTensor(const PyTapeTensor& other) {
975 id_ = other.id_;
976 dtype_ = other.dtype_;
977 shape_ = other.shape_;
978 if (shape_.index() == 1) {
979 Py_INCREF(absl::get<1>(shape_));
980 }
981 }
982
983 ~PyTapeTensor() {
984 if (shape_.index() == 1) {
985 Py_DECREF(absl::get<1>(shape_));
986 }
987 }
988 PyObject* GetShape() const;
989 PyObject* GetPyDType() const { return PyLong_FromLong(dtype_); }
990 tensorflow::int64 GetID() const { return id_; }
991 tensorflow::DataType GetDType() const { return dtype_; }
992
993 private:
994 tensorflow::int64 id_;
995 tensorflow::DataType dtype_;
996 absl::variant<tensorflow::TensorShape, PyObject*> shape_;
997};
998
999static PyTapeTensor TapeTensorFromTensor(PyObject* tensor);
1000

Callers 2

TapeTensorFromTensorFunction · 0.85
TFE_Py_TapeGradientFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected