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

Function PackGrad

tensorflow/core/ops/array_grad_test.cc:36–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34}
35
36std::vector<Tensor> PackGrad(const Tensor& x0, const Tensor& x1,
37 const Tensor& dy, int axis) {
38 auto T = DT_FLOAT;
39 auto gdef = test::function::GDef(
40 {f::NDef("x0", "Placeholder", {}, {{"dtype", T}}),
41 f::NDef("x1", "Placeholder", {}, {{"dtype", T}}),
42 f::NDef("axis", "Placeholder", {}, {{"dtype", DT_INT32}}),
43 f::NDef("dy", "Placeholder", {}, {{"dtype", T}}),
44 f::NDef("dx", "SymbolicGradient", {"x0", "x1", "dy"},
45 {{"f", FDH::FunctionRef("Pack",
46 {{"N", 2}, {"T", T}, {"axis", axis}})},
47 {"Tin", DataTypeSlice{T, T, T}},
48 {"Tout", DataTypeSlice{T, T}}})});
49 VLOG(1) << DebugStringWhole(gdef);
50 auto sess = NewSession();
51 TF_CHECK_OK(sess->Create(gdef));
52 std::vector<Tensor> out;
53 TF_CHECK_OK(sess->Run({{"x0:0", x0},
54 {"x1:0", x1},
55 {"axis:0", test::AsScalar(axis)},
56 {"dy:0", dy}},
57 {"dx:0", "dx:1"}, {}, &out));
58 CHECK_EQ(out.size(), 2);
59 TF_CHECK_OK(sess->Close());
60 return out;
61}
62
63TEST(ArrayGradTest, PackGrad) {
64 Tensor x0(DT_FLOAT, {2, 3});

Callers 1

TESTFunction · 0.70

Calls 9

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

Tested by

no test coverage detected