| 177 | } // namespace |
| 178 | |
| 179 | Status AddWhileLoopGradient(WhileContext* while_ctx, const Scope& scope, |
| 180 | const std::vector<Output>& grad_inputs, |
| 181 | std::vector<Output>* grad_outputs) { |
| 182 | Output forward_loop_count; |
| 183 | TF_RETURN_IF_ERROR(AddForwardLoopCounter( |
| 184 | while_ctx, scope.NewSubScope("ForwardLoopCounter"), &forward_loop_count)); |
| 185 | |
| 186 | // TODO(skyewm): can we combine the backprop loop counter and main gradient |
| 187 | // loop into a single loop? The original Python code doesn't combine the |
| 188 | // loops, but I'm not sure why. |
| 189 | Output backprop_counter_cond; |
| 190 | TF_RETURN_IF_ERROR(AddBackPropLoopCounter( |
| 191 | while_ctx, forward_loop_count, scope.NewSubScope("BackPropLoopCounter"), |
| 192 | &backprop_counter_cond)); |
| 193 | |
| 194 | return AddWhileGradientLoop(while_ctx, grad_inputs, backprop_counter_cond, |
| 195 | scope, grad_outputs); |
| 196 | } |
| 197 | |
| 198 | } // namespace tensorflow |
no test coverage detected