microsoft / tf-gnn-samples

TensorFlow implementations of Graph Neural Networks
MIT License
914 stars 229 forks source link

Performance issue in the definition of sparse_rgdcn_layer, gnns/rgdcn.py #20

Closed DLPerf closed 3 years ago

DLPerf commented 3 years ago

Hello, I found a performance issue in the definition of sparse_rgdcn_layer, gnns/rgdcn.py, tf.initializers.truncated_normal will created repeatedly during program execution, resulting in reduced efficiency. I think it should be created before the loop in sparse_rgdcn_layer.

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

mmjb commented 3 years ago

This is TF1, so this code is building a computation graph that will be re-used. The loop is creating many different weights, and I'm not sure how you are proposing to avoid this?

DLPerf commented 3 years ago

I am sorry for that I propose a wrong issue. I think tf.initializers.truncated_normal will create repeatedly in the graph by mistake. Thank you for replying me.

mmjb commented 3 years ago

It will be called exactly once for each weight that requires initialization, so I think the code is correct.