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

Method Zeros

tensorflow/python/eager/pywrap_tfe_src.cc:1083–1102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1081 void MarkAsResult(PyObject* gradient) const final { Py_INCREF(gradient); }
1082
1083 PyObject* Zeros(const PyTapeTensor& tensor) const final {
1084 if (PyErr_Occurred()) {
1085 return nullptr;
1086 }
1087 PyObject* py_shape = tensor.GetShape();
1088 if (PyErr_Occurred()) {
1089 return nullptr;
1090 }
1091 PyObject* py_dtype = tensor.GetPyDType();
1092 if (PyErr_Occurred()) {
1093 Py_DECREF(py_shape);
1094 return nullptr;
1095 }
1096 PyObject* arg_list = Py_BuildValue("OO", py_shape, py_dtype);
1097 PyObject* result = PyEval_CallObject(zeros_fn_, arg_list);
1098 Py_DECREF(arg_list);
1099 Py_DECREF(py_dtype);
1100 Py_DECREF(py_shape);
1101 return reinterpret_cast<PyObject*>(result);
1102 }
1103
1104 PyObject* Ones(const PyTapeTensor& tensor) const final {
1105 if (PyErr_Occurred()) {

Callers 5

test_ZerosMethod · 0.45
testZerosMethod · 0.45
TFE_Py_TapeGradientFunction · 0.45
ComputeGradientMethod · 0.45
AccumulateMethod · 0.45

Calls 2

GetPyDTypeMethod · 0.80
GetShapeMethod · 0.45

Tested by 2

test_ZerosMethod · 0.36
testZerosMethod · 0.36