LSTM-UNet icon indicating copy to clipboard operation
LSTM-UNet copied to clipboard

Performance issue in DataHandeling.py

Open DLPerf opened this issue 1 year ago • 1 comments

Hello! Our static bug checker has found a performance issue in DataHandeling.py: normed_size is repeatedly called in a for loop, but there is a tf.function decorated function q_stat defined and called in normed_size.

In that case, when normed_size is called in a loop, the function q_stat will create a new graph every time, and that can trigger tf.function retracing warning.

Here is the tensorflow document to support it.

Briefly, for better efficiency, it's better to use:

@tf.function
def inner():
    pass

def outer():
    inner()  

than:

def outer():
    @tf.function
    def inner():
        pass
    inner()

Looking forward to your reply.

DLPerf avatar Mar 08 '23 01:03 DLPerf

The same with normed_size here and here. We are investigating this kind of issues, and your answer will be of great help to our work. Thank you in advance! @arbellea

DLPerf avatar Mar 08 '23 01:03 DLPerf