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

Function UnpackGrad

tensorflow/core/ops/array_grad_test.cc:77–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75}
76
77std::vector<Tensor> UnpackGrad(const Tensor& x, const Tensor& dy0,
78 const Tensor& dy1, int axis) {
79 auto T = DT_FLOAT;
80 auto gdef = test::function::GDef(
81 {f::NDef("x", "Placeholder", {}, {{"dtype", T}}),
82 f::NDef("axis", "Placeholder", {}, {{"dtype", DT_INT32}}),
83 f::NDef("dy0", "Placeholder", {}, {{"dtype", T}}),
84 f::NDef("dy1", "Placeholder", {}, {{"dtype", T}}),
85 f::NDef("dx", "SymbolicGradient", {"x", "dy0", "dy1"},
86 {{"f", FDH::FunctionRef("Unpack",
87 {{"num", 2}, {"T", T}, {"axis", axis}})},
88 {"Tin", DataTypeSlice{T, T, T}},
89 {"Tout", DataTypeSlice{T}}})});
90 VLOG(1) << DebugStringWhole(gdef);
91 auto sess = NewSession();
92 TF_CHECK_OK(sess->Create(gdef));
93 std::vector<Tensor> out;
94 TF_CHECK_OK(sess->Run({{"x:0", x},
95 {"axis:0", test::AsScalar(axis)},
96 {"dy0:0", dy0},
97 {"dy1:0", dy1}},
98 {"dx:0"}, {}, &out));
99 CHECK_EQ(out.size(), 1);
100 TF_CHECK_OK(sess->Close());
101 return out;
102}
103
104TEST(ArrayGradTest, UnpackGrad) {
105 Tensor x(DT_FLOAT, {2, 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