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

Method AggregateGradients

tensorflow/python/eager/pywrap_tfe_src.cc:1059–1075  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1057 }
1058
1059 PyObject* AggregateGradients(
1060 tensorflow::gtl::ArraySlice<PyObject*> gradient_tensors) const final {
1061 PyObject* list = PyList_New(gradient_tensors.size());
1062 for (size_t i = 0; i < gradient_tensors.size(); ++i) {
1063 // Note: stealing a reference to the gradient tensors.
1064 CHECK(gradient_tensors[i] != nullptr);
1065 CHECK(gradient_tensors[i] != Py_None);
1066 PyList_SET_ITEM(list, i,
1067 reinterpret_cast<PyObject*>(gradient_tensors[i]));
1068 }
1069 PyObject* arglist = Py_BuildValue("(O)", list);
1070 CHECK(arglist != nullptr);
1071 PyObject* result = PyEval_CallObject(aggregate_fn_, arglist);
1072 Py_DECREF(arglist);
1073 Py_DECREF(list);
1074 return result;
1075 }
1076
1077 tensorflow::int64 TensorId(PyObject* tensor) const final {
1078 return FastTensorId(tensor);

Callers 2

ComputeGradientMethod · 0.80
WatchMethod · 0.80

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected