py_function is slower in TF2.7 (and 2.6) compared to TF2.5 #53620
Labels
comp:ops
OPs related issues
stat:awaiting tensorflower
Status - Awaiting response from tensorflower
TF 2.9
Issues found in the TF 2.9 release (or RCs)
type:performance
Performance Issue
System information
Describe the current behavior
In my training code I'm using
tf.data.Dataset.map
with atf.py_function
within it. I know that usingtf.py_function
is slower than regular tensorflow, but there's a part of my dataset processing that requires the usage of plain Python code.However, when I tried to upgrade TF from 2.5 to 2.6, I noticed that my trainings were slower in 2.6 compared to 2.5. I postponed the upgrade at the moment. When 2.7 came out I tried again but the slower data processing was still present.
Describe the expected behavior
I would have expected this kind of code to be as efficient as it was in 2.5
Standalone code to reproduce the issue
You can find a reproducible example in this colab.
To reproduce my issue, I wrapped the opening of the image on disk within a
tf.py_function
and opened it using Pillow and numpy. I know that this can be done in a more efficient way as I explained directly in the colab.Here are the results I got when executing the
%%timeit
cell with 2 different versions of TF:The text was updated successfully, but these errors were encountered: