| 1040 | } |
| 1041 | |
| 1042 | tensorflow::int64 NumElements(PyObject* tensor) const final { |
| 1043 | if (EagerTensor_CheckExact(tensor)) { |
| 1044 | return PyEagerTensor_NumElements(tensor); |
| 1045 | } |
| 1046 | PyObject* arglist = |
| 1047 | Py_BuildValue("(O)", reinterpret_cast<PyObject*>(tensor)); |
| 1048 | PyObject* result = PyEval_CallObject(num_elements_, arglist); |
| 1049 | Py_DECREF(arglist); |
| 1050 | if (result == nullptr) { |
| 1051 | // The caller detects whether a python exception has been raised. |
| 1052 | return -1; |
| 1053 | } |
| 1054 | tensorflow::int64 r = MakeInt(result); |
| 1055 | Py_DECREF(result); |
| 1056 | return r; |
| 1057 | } |
| 1058 | |
| 1059 | PyObject* AggregateGradients( |
| 1060 | tensorflow::gtl::ArraySlice<PyObject*> gradient_tensors) const final { |
nothing calls this directly
no test coverage detected