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

Function SplitVGrad

tensorflow/core/ops/array_grad_test.cc:241–272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

239}
240
241std::vector<Tensor> SplitVGrad(const Tensor& x, const Tensor& size_splits,
242 int dim, const Tensor& dy0, const Tensor& dy1) {
243 auto T = DT_FLOAT;
244 auto Tlen = DT_INT64;
245 auto gdef = test::function::GDef(
246 {f::NDef("x", "Placeholder", {}, {{"dtype", T}}),
247 f::NDef("size_splits", "Placeholder", {}, {{"dtype", Tlen}}),
248 f::NDef("dim", "Placeholder", {}, {{"dtype", DT_INT32}}),
249 f::NDef("dy0", "Placeholder", {}, {{"dtype", T}}),
250 f::NDef("dy1", "Placeholder", {}, {{"dtype", T}}),
251 f::NDef("dx", "SymbolicGradient",
252 {"x", "size_splits", "dim", "dy0", "dy1"},
253 {{"f", FDH::FunctionRef("SplitV", {{"split_dim", dim},
254 {"num_split", 2},
255 {"T", T},
256 {"Tlen", Tlen}})},
257 {"Tin", DataTypeSlice{T, Tlen, DT_INT32, T, T}},
258 {"Tout", DataTypeSlice{T, Tlen, DT_INT32}}})});
259 VLOG(1) << DebugStringWhole(gdef);
260 auto sess = NewSession();
261 TF_CHECK_OK(sess->Create(gdef));
262 std::vector<Tensor> out;
263 TF_CHECK_OK(sess->Run({{"x:0", x},
264 {"size_splits:0", size_splits},
265 {"dim", test::AsScalar(dim)},
266 {"dy0:0", dy0},
267 {"dy1:0", dy1}},
268 {"dx:0", "dx:1", "dx:2"}, {}, &out));
269 CHECK_EQ(out.size(), 3);
270 TF_CHECK_OK(sess->Close());
271 return out;
272}
273
274TEST(ArrayGradTest, SplitGrad) {
275 Tensor x(DT_FLOAT, {2, 4, 5});

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