google-deepmind / graph_nets

Build Graph Nets in Tensorflow
https://arxiv.org/abs/1806.01261
Apache License 2.0
5.34k stars 783 forks source link

Performance issue in /graph_nets/tests (by P3) #144

Closed DLPerf closed 2 years ago

DLPerf commented 3 years ago

Hello! I've found a performance issue in /graph_nets/tests/utils_tf_test.py: with tf.Session() as sess(here) is repeatedly called in the loop for graph_dict in self.graphs_dicts_in(here).

tf.Session being defined repeatedly could lead to incremental overhead. If you define tf.Session out of the loop and pass tf.Session as a parameter to the loop, your program would be much more efficient. Here is the Stack Overflow post to support it.

Looking forward to your reply. Btw, I am very glad to create a PR to fix it if you are too busy.

alvarosg commented 3 years ago

Thank you for your message! Since this is a simple test we favored code simplicity over performance by reducing the span of the session variable in the code. But please continue to report any potential performance issues you may find in the core of the library!

DLPerf commented 3 years ago

Thanks for your reply. @alvarosg