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

Function ReshapeGrad

tensorflow/core/ops/array_grad_test.cc:307–327  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

305}
306
307std::vector<Tensor> ReshapeGrad(const Tensor& x, const Tensor& s,
308 const Tensor& dy) {
309 auto T = DT_FLOAT;
310 auto gdef = test::function::GDef(
311 {f::NDef("x", "Placeholder", {}, {{"dtype", T}}),
312 f::NDef("s", "Placeholder", {}, {{"dtype", DT_INT32}}),
313 f::NDef("dy", "Placeholder", {}, {{"dtype", T}}),
314 f::NDef("dx", "SymbolicGradient", {"x", "s", "dy"},
315 {{"f", FDH::FunctionRef("Reshape", {{"T", T}})},
316 {"Tin", DataTypeSlice{T, DT_INT32, T}},
317 {"Tout", DataTypeSlice{T, DT_INT32}}})});
318 VLOG(1) << DebugStringWhole(gdef);
319 auto sess = NewSession();
320 TF_CHECK_OK(sess->Create(gdef));
321 std::vector<Tensor> out;
322 TF_CHECK_OK(sess->Run({{"x:0", x}, {"s:0", s}, {"dy:0", dy}},
323 {"dx:0", "dx:1"}, {}, &out));
324 CHECK_EQ(out.size(), 2);
325 TF_CHECK_OK(sess->Close());
326 return out;
327}
328
329TEST(ArrayGradTest, ReshapeGrad) {
330 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