| 1102 | } |
| 1103 | |
| 1104 | PyObject* Ones(const PyTapeTensor& tensor) const final { |
| 1105 | if (PyErr_Occurred()) { |
| 1106 | return nullptr; |
| 1107 | } |
| 1108 | PyObject* py_shape = tensor.GetShape(); |
| 1109 | PyObject* py_dtype = tensor.GetPyDType(); |
| 1110 | PyObject* arg_list = Py_BuildValue("OO", py_shape, py_dtype); |
| 1111 | PyObject* result = PyEval_CallObject(ones_fn_, arg_list); |
| 1112 | Py_DECREF(arg_list); |
| 1113 | Py_DECREF(py_dtype); |
| 1114 | Py_DECREF(py_shape); |
| 1115 | return result; |
| 1116 | } |
| 1117 | |
| 1118 | PyObject* GraphShape(PyObject* tensor) const { |
| 1119 | PyObject* arg_list = Py_BuildValue("(O)", tensor); |