The loop body of map_fn. Args: i: the loop counter tas: the flat TensorArray accumulator list Returns: (i + 1, tas): the updated counter + updated TensorArrays Raises: TypeError: if dtype and packed_fn_values structure do not match ValueTy
(i, tas)
| 257 | i = constant_op.constant(0, dtype=dtypes.int32) |
| 258 | |
| 259 | def compute(i, tas): |
| 260 | """The loop body of map_fn. |
| 261 | |
| 262 | Args: |
| 263 | i: the loop counter |
| 264 | tas: the flat TensorArray accumulator list |
| 265 | |
| 266 | Returns: |
| 267 | (i + 1, tas): the updated counter + updated TensorArrays |
| 268 | |
| 269 | Raises: |
| 270 | TypeError: if dtype and packed_fn_values structure do not match |
| 271 | ValueType: if dtype and packed_fn_values lengths do not match |
| 272 | """ |
| 273 | # Get Tensors or RaggedTensors sliced at i, then pack it back to the |
| 274 | # original structure. |
| 275 | packed_values = input_pack([elem_flat[i] for elem_flat in elems_flat]) |
| 276 | packed_fn_values = fn(packed_values) |
| 277 | |
| 278 | # Check that the structure of the output matches what was declared or |
| 279 | # inferred. |
| 280 | # nest.assert_same_structure(dtype or elems, packed_fn_values) |
| 281 | |
| 282 | # Flatten and decompose to a list of Tensors |
| 283 | flat_fn_values = nest.flatten(packed_fn_values) |
| 284 | |
| 285 | # If we declared that we are expecting a RaggedTensor output, but we get a |
| 286 | # Tensor output. We should try to convert it to a RaggedTensor. |
| 287 | flat_fn_composite_tensors = list( |
| 288 | _convert_declared(flat_fn_values, dtype_flat)) |
| 289 | |
| 290 | flat_fn_components = [ |
| 291 | _maybe_decompose_tensor(t) for t in flat_fn_composite_tensors |
| 292 | ] |
| 293 | flat_fn_tensors = nest.flatten(flat_fn_components) |
| 294 | |
| 295 | # Write to TAs. |
| 296 | tas = [ta.write(i, value) for (ta, value) in zip(tas, flat_fn_tensors)] |
| 297 | |
| 298 | return (i + 1, tas) |
| 299 | |
| 300 | _, r_a = control_flow_ops.while_loop( |
| 301 | lambda i, _: i < n, compute, (i, accs_ta), |
nothing calls this directly
no test coverage detected