(not_all_done, indices, *args)
| 600 | return not_all_done |
| 601 | |
| 602 | def body(not_all_done, indices, *args): |
| 603 | # See documentatin for __call__ for the structure of *args. |
| 604 | num_enters = len(self._enters) |
| 605 | inputs = args[:num_enters] |
| 606 | output_tas = args[num_enters:] |
| 607 | # TODO(agarwal): see which outputs have consumers and only populate the |
| 608 | # TensorArrays corresponding to those. Or do those paths get trimmed out |
| 609 | # from inside the while_loop body? |
| 610 | assert len(inputs) >= len(output_tas) |
| 611 | assert len(inputs) == len(inputs_stacked) |
| 612 | |
| 613 | # Convert condition |
| 614 | with ops.name_scope("while_cond"): |
| 615 | # Note that we set cond_stacked to True here. At this point we don't |
| 616 | # know if it could be loop invariant, hence the conservative value is |
| 617 | # to assume stacked. |
| 618 | cond_pfor = self._init_pfor(pfor_input.pfor, indices, |
| 619 | cond_stacked=True, |
| 620 | inputs=inputs, |
| 621 | inputs_stacked=inputs_stacked) |
| 622 | conditions, cond_stacked, _ = cond_pfor._convert_helper(self._condition) |
| 623 | cond_is_stacked[0] = cond_stacked |
| 624 | |
| 625 | # Recompute the new condition, write outputs of done iterations, and |
| 626 | # partition the inputs if needed. |
| 627 | if not cond_stacked: |
| 628 | (not_all_done, new_indices, |
| 629 | new_inputs, new_output_tas) = self._process_cond_unstacked( |
| 630 | conditions, indices, inputs, output_tas) |
| 631 | else: |
| 632 | (not_all_done, new_indices, |
| 633 | new_inputs, new_output_tas) = self._process_cond_stacked( |
| 634 | conditions, indices, inputs, inputs_stacked, output_tas) |
| 635 | |
| 636 | # Convert body |
| 637 | with ops.name_scope("while_body"): |
| 638 | # Compute the outputs from the body. |
| 639 | new_outputs = self._process_body(pfor_input, inputs_stacked, |
| 640 | new_indices, cond_stacked, new_inputs, |
| 641 | not_all_done) |
| 642 | |
| 643 | # Note that the first num_outputs new values of inputs are computed using |
| 644 | # the body. Rest of them were direct Enters into the condition/body and |
| 645 | # the partitioning done earlier is sufficient to give the new value. |
| 646 | num_outputs = len(self._outputs) |
| 647 | new_args = ([not_all_done, new_indices] + new_outputs + list( |
| 648 | new_inputs[num_outputs:]) + new_output_tas) |
| 649 | return tuple(new_args) |
| 650 | |
| 651 | while_outputs = control_flow_ops.while_loop( |
| 652 | cond, body, init_values, shape_invariants=shape_invariants) |
nothing calls this directly
no test coverage detected