| 484 | } |
| 485 | |
| 486 | std::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 | |
| 510 | TEST(ArrayGradTest, ReverseV2Grad) { |
| 511 | Tensor x(DT_FLOAT, {2, 3}); |
no test coverage detected