(pfor_input)
| 943 | |
| 944 | |
| 945 | def _fallback_converter(pfor_input): |
| 946 | logging.warn("Using a while_loop for converting %s", pfor_input.op_type) |
| 947 | output_dtypes = [x.dtype for x in pfor_input.outputs] |
| 948 | iters = pfor_input.pfor.loop_len_vector[0] |
| 949 | |
| 950 | def while_body(i, *ta_list): |
| 951 | """Body of while loop.""" |
| 952 | inputs = [ |
| 953 | x[i, ...] if stacked else x for x, stacked, _ in pfor_input.inputs |
| 954 | ] |
| 955 | op_outputs = _create_op( |
| 956 | pfor_input.op_type, |
| 957 | inputs, |
| 958 | output_dtypes, |
| 959 | attrs=pfor_input.op.node_def.attr).outputs |
| 960 | |
| 961 | outputs = [] |
| 962 | for out, ta in zip(op_outputs, ta_list): |
| 963 | assert isinstance(out, ops.Tensor) |
| 964 | outputs.append(ta.write(i, array_ops.expand_dims(out, 0))) |
| 965 | return tuple([i + 1] + outputs) |
| 966 | |
| 967 | ta_list = control_flow_ops.while_loop( |
| 968 | lambda i, *ta: i < iters, while_body, [0] + [ |
| 969 | tensor_array_ops.TensorArray(dtype, iters) for dtype in output_dtypes |
| 970 | ])[1:] |
| 971 | return tuple([wrap(ta.concat(), True) for ta in ta_list]) |
| 972 | |
| 973 | |
| 974 | class PForConfig(object): |
nothing calls this directly
no test coverage detected