Waymo-2D-Object-Detection icon indicating copy to clipboard operation
Waymo-2D-Object-Detection copied to clipboard

Performance issue in input/models/research/seq_flow_lite/models/sgnn/sgnn.py

Open DLPerf opened this issue 2 years ago • 2 comments

Hello! Our static bug checker has found a performance issue in input/models/research/seq_flow_lite/models/sgnn/sgnn.py: fused_project is repeatedly called in a for loop, but there is a tf.function decorated function func defined and called in fused_project.

In that case, when fused_project is called in a loop, the function func 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. Btw, I am glad to create a PR to fix it if you are too busy.

DLPerf avatar Feb 24 '23 01:02 DLPerf

Thanks for the suggestion. Go ahead for pull request

sek788432 avatar Feb 25 '23 07:02 sek788432

Sorry for the delay. But some variables are depending on the outer function. Code may be more complex if changes are made. Is it necessary to make the change or do you have any other ideas?

DLPerf avatar Mar 06 '23 02:03 DLPerf