Some of these indents are triggering markdown's (horrible) "4-space indent is a code block" feature
PiperOrigin-RevId: 316883013
Change-Id: If2b53a6788d3179b868a62fb6b4caeeb08caa4bf
If fn_output_signature argument contains TensorSpec then extract the static
shape information and pass them to TensorArray used to collect output slices.
This is required for TF Lite conversion of models using tf.map_fn(), because
the conversion rejects TensorArray/List with unknown element shapes.
PiperOrigin-RevId: 313810480
Change-Id: I1d1e381b7212b3e691d55ff43e84789a7b9ecd9a
This PR tries to address the issue raised in 39229 where
empty lists input was not checked and throw out a non-obvious error:
```python
>>> import numpy as np
>>> import tensorflow as tf
>>> fn = lambda x: x
>>> tf.map_fn(fn, [])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/3.7/site-packages/tensorflow/python/util/deprecation.py", line 574, in new_func
return func(*args, **kwargs)
File "/Library/Python/3.7/site-packages/tensorflow/python/ops/map_fn.py", line 425, in map_fn_v2
name=name)
File "/Library/Python/3.7/site-packages/tensorflow/python/ops/map_fn.py", line 213, in map_fn
static_shape = elems_flat[0].shape
IndexError: list index out of range
>>>
```
In case of empty list the behavior is undefined as we even don't know the output dtype.
This PR update to perform a check and thrown out
`ValueError("elems must not be empty")` to help clarify.
This PR fixes 39229.
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Mark back_prop flag as deprecated in tf.while_loop, tf.map_fn, tf.foldl, tf.foldr, tf.scan.
PiperOrigin-RevId: 285433878
Change-Id: I59e5ea3b566b8fa1feae0884da704454562cef43