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

Function ReverseV2Grad

tensorflow/core/ops/array_grad_test.cc:486–508  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

484}
485
486std::vector<Tensor> ReverseV2Grad(const Tensor& x, const Tensor& axis,
487 const Tensor& dy) {
488 auto T = DT_FLOAT;
489 auto Tidx = DT_INT32;
490 auto gdef = test::function::GDef(
491 {f::NDef("x", "Placeholder", {}, {{"dtype", T}}),
492 f::NDef("axis", "Placeholder", {}, {{"dtype", DT_INT32}}),
493 f::NDef("dy", "Placeholder", {}, {{"dtype", T}}),
494 f::NDef(
495 "dx", "SymbolicGradient", {"x", "axis", "dy"},
496 {{"f", FDH::FunctionRef("ReverseV2", {{"T", T}, {"Tidx", Tidx}})},
497 {"Tin", DataTypeSlice{T, DT_INT32, T}},
498 {"Tout", DataTypeSlice{T, DT_INT32}}})});
499 VLOG(1) << DebugStringWhole(gdef);
500 auto sess = NewSession();
501 TF_CHECK_OK(sess->Create(gdef));
502 std::vector<Tensor> out;
503 TF_CHECK_OK(sess->Run({{"x:0", x}, {"axis:0", axis}, {"dy:0", dy}},
504 {"dx:0", "dx:1"}, {}, &out));
505 CHECK_EQ(out.size(), 2);
506 TF_CHECK_OK(sess->Close());
507 return out;
508}
509
510TEST(ArrayGradTest, ReverseV2Grad) {
511 Tensor x(DT_FLOAT, {2, 3});

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