Returns True if handle was created inside the pfor loop.
(pfor_input, handle)
| 2748 | |
| 2749 | |
| 2750 | def _handle_inside_pfor(pfor_input, handle): |
| 2751 | """Returns True if handle was created inside the pfor loop.""" |
| 2752 | # We use some heuristic to find the original TensorArray creation op. |
| 2753 | # The logic should handle the common cases (except cond based subgraphs). |
| 2754 | # In theory the user could perform different operations on the handle (like |
| 2755 | # Reshape, stack multiple handles, etc) which could break this logic. |
| 2756 | # TODO(agarwal): handle Switch/Merge. |
| 2757 | while handle.op.type in ("Enter", "Identity"): |
| 2758 | handle = handle.op.inputs[0] |
| 2759 | if handle.op.type not in [ |
| 2760 | "TensorArrayV3", "TensorArrayGradV3", "TensorArrayGradWithShape"]: |
| 2761 | raise ValueError("Unable to find source for handle %s" % handle) |
| 2762 | else: |
| 2763 | return pfor_input.pfor.op_is_inside_loop(handle.op) |
| 2764 | |
| 2765 | |
| 2766 | def _unstack_flow(value): |
no test coverage detected