| 89 | }; |
| 90 | |
| 91 | TEST_F(WhileGradientsTest, Basic) { |
| 92 | // Create loop: while (i < 10) i += 1 |
| 93 | Init(1); |
| 94 | CreateLoop( |
| 95 | [](const Scope& s, const std::vector<Output>& inputs, Output* output) { |
| 96 | *output = ops::Less(s, inputs[0], 10); |
| 97 | return s.status(); |
| 98 | }, |
| 99 | [](const Scope& s, const std::vector<Output>& inputs, |
| 100 | std::vector<Output>* outputs) { |
| 101 | // Use AddN, rather than Add, because the gradient function doesn't |
| 102 | // depend on the input shapes, and thus we do not need to store |
| 103 | // intermediate values in a stack. |
| 104 | outputs->push_back(ops::AddN(s, {inputs[0], 1})); |
| 105 | return s.status(); |
| 106 | }); |
| 107 | CreateBackprop(); |
| 108 | |
| 109 | Run<int>({1}, {1}); |
| 110 | Run<int>({11}, {1}); |
| 111 | } |
| 112 | |
| 113 | TEST_F(WhileGradientsTest, MultipleLoopVars) { |
| 114 | // Create loop: while (i < 10) i += j; j += 1; k = k |
nothing calls this directly
no test coverage detected