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

Function ExpandDimsGrad

tensorflow/core/ops/array_grad_test.cc:346–366  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

344}
345
346std::vector<Tensor> ExpandDimsGrad(const Tensor& x, const Tensor& s,
347 const Tensor& dy) {
348 auto T = DT_FLOAT;
349 auto gdef = test::function::GDef(
350 {f::NDef("x", "Placeholder", {}, {{"dtype", T}}),
351 f::NDef("s", "Placeholder", {}, {{"dtype", DT_INT32}}),
352 f::NDef("dy", "Placeholder", {}, {{"dtype", T}}),
353 f::NDef("dx", "SymbolicGradient", {"x", "s", "dy"},
354 {{"f", FDH::FunctionRef("ExpandDims", {{"T", T}})},
355 {"Tin", DataTypeSlice{T, DT_INT32, T}},
356 {"Tout", DataTypeSlice{T, DT_INT32}}})});
357 VLOG(1) << DebugStringWhole(gdef);
358 auto sess = NewSession();
359 TF_CHECK_OK(sess->Create(gdef));
360 std::vector<Tensor> out;
361 TF_CHECK_OK(sess->Run({{"x:0", x}, {"s:0", s}, {"dy:0", dy}},
362 {"dx:0", "dx:1"}, {}, &out));
363 CHECK_EQ(out.size(), 2);
364 TF_CHECK_OK(sess->Close());
365 return out;
366}
367
368TEST(ArrayGradTest, ExpandDimsGrad) {
369 Tensor x(DT_FLOAT, {2, 4, 5});

Callers 1

TESTFunction · 0.70

Calls 8

GDefFunction · 0.85
NDefFunction · 0.85
DebugStringWholeFunction · 0.85
NewSessionFunction · 0.70
CreateMethod · 0.45
RunMethod · 0.45
sizeMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected