models icon indicating copy to clipboard operation
models copied to clipboard

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

Open DLPerf opened this issue 2 years ago • 0 comments

Hello! Our static bug checker has found a performance issue in 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.

DLPerf avatar Feb 23 '23 07:02 DLPerf