gimlet
gimlet copied to clipboard
Performance issue in lime/scripts/lipo_gru/ht_lipo_gru.py
Hello! Our static bug checker has found a performance issue in lime/scripts/lipo_gru/ht_lipo_gru.py: init
is repeatedly called in a for loop, but there are several tf.function decorated functions call
, call
and call
defined and called in init
.
In that case, when init
is called in a loop, the function call
will create a new graph every time, and that can trigger tf.function retracing warning.
Similar issues in: lime/scripts/lipo_gru/ht_lipo_ind_gru.py, lime/scripts/elf_with_wbo/ht_elf_with_wbo.py, lime/scripts/partial_charge/ht_charge.py and lime/scripts/partial_charge/ht_charge_fast.py.
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.
There are some variables in class passed to the function, the code may be more complex if changes are made. Do you have any idea? @dotsdl @jchodera @bas-rustenburg @jaimergp