Func with custom gradient using tf.numpy_function
/tf.py_function
incompatible with tf.vectorized_map
#53726
Labels
comp:eager
Eager related issues
stat:awaiting tensorflower
Status - Awaiting response from tensorflower
TF 2.7
Issues related to TF 2.7.0
type:bug
Bug
Please make sure that this is a bug. As per our
GitHub Policy,
we only address code/doc bugs, performance issues, feature requests and
build/installation issues on GitHub. tag:bug_template
System information
pip
You can collect some of this information using our environment capture
script
You can also obtain the TensorFlow version with:
python -c "import tensorflow as tf; print(tf.GIT_VERSION, tf.VERSION)"
python -c "import tensorflow as tf; print(tf.version.GIT_VERSION, tf.version.VERSION)"
Describe the current behavior
When using
tf.vectorized_map
on a function that provides a custom gradient and the function uses eithertf.numpy_function
ortf.py_function
, then unexpected behaviour arises:tf.numpy_function
: the gradient is a vector of zeros;tf.py_function
:UnknownError: KeyError: b'pyfunc_12'
error arises.Describe the expected behavior
The gradient is computed without issues.
Contributing
Standalone code to reproduce the issue
Provide a reproducible test case that is the bare minimum necessary to generate
the problem. If possible, please share a link to Colab/Jupyter/any notebook.
Other info / logs Include any logs or source code that would be helpful to
diagnose the problem. If including tracebacks, please include the full
traceback. Large logs and files should be attached.
Output when using
Then getting
UnknownError: KeyError: b'pyfunc_12'
.For both, a
WARNING:tensorflow:Using a while_loop for converting EagerPyFunc
is also emitted.The text was updated successfully, but these errors were encountered: