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

Method ReduceSum

tensorflow/core/ops/math_grad_test.cc:228–249  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

226 }
227
228 Tensor ReduceSum(const Tensor& x, gtl::ArraySlice<int32> axes) {
229 int num_axes = axes.length();
230 Tensor y(DT_INT32, TensorShape({num_axes}));
231 for (size_t i = 0; i < axes.size(); ++i) {
232 y.flat<int32>()(i) = axes[i];
233 }
234 auto T = x.dtype();
235 auto gdef = test::function::GDef(
236 {
237 f::NDef("x", "Placeholder", {}, {{"dtype", T}}),
238 f::NDef("y", "Const", {}, {{"dtype", DT_INT32}, {"value", y}}),
239 f::NDef("z", "Sum", {"x", "y"}, {{"T", T}}),
240 },
241 {});
242 auto sess = NewSession();
243 TF_CHECK_OK(sess->Create(gdef));
244 std::vector<Tensor> outputs;
245 TF_CHECK_OK(sess->Run({{"x:0", x}}, {"z:0"}, {}, &outputs));
246 CHECK_EQ(outputs.size(), 1);
247 TF_CHECK_OK(sess->Close());
248 return outputs[0];
249 }
250
251 Tensor MatMulCommon(const string& opname, const string& attr_adj_x,
252 const string& attr_adj_y, const Tensor& x, bool ax,

Callers

nothing calls this directly

Calls 10

GDefFunction · 0.85
NDefFunction · 0.85
NewSessionFunction · 0.70
TensorShapeClass · 0.50
lengthMethod · 0.45
sizeMethod · 0.45
dtypeMethod · 0.45
CreateMethod · 0.45
RunMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected