-
Notifications
You must be signed in to change notification settings - Fork 614
tf.function bug #807
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
@fsx950223 Have you found the same issue with any other function apart from |
Function which passes python arguments has same issue.rrelu.sparsemax |
@fsx950223 Thanks for the report! So in practice these activation functions will likely not see frequent changes to their python args. The multiple retracing is happening here because each test case is modifying the data type or arguments. AKAIK There is no real benefit to having these activations decorated with |
A similar issue occurs for IMO we should remove |
Thanks for pinging me. I am fine with removing |
System information
Describe the bug
tf.function will trigger tf.function retracing several times if user convert python types into the tf.function which will cause memory leak.
A clear and concise description of what the bug is.
Invalid usage of tf.function leads memory leak
Code to reproduce the issue
addons/tensorflow_addons/activations/softshrink.py
Line 29 in 41a286c
Provide a reproducible test case that is the bare minimum necessary to generate the problem.
bazel test -c opt -k --test_timeout 300,450,1200,3600 --crosstool_top=//build_deps/toolchains/gcc7_manylinux2010-nvcc-cuda10.1:toolchain --test_output=all --jobs=1 //tensorflow_addons/activations:softshrink_test
Other info / logs
WARNING:tensorflow:9 out of the last 27 calls to <function softshrink at 0x7f37439a28c8> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings is likely due to passing python objects instead of tensors. Also, tf.function has experimental_relax_shapes=True option that relaxes argument shapes that can avoid unnecessary retracing. Please refer to https://www.tensorflow.org/tutorials/customization/performance#python_or_tensor_args and https://www.tensorflow.org/api_docs/python/tf/function for more details.
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.
The text was updated successfully, but these errors were encountered: