model-optimization icon indicating copy to clipboard operation
model-optimization copied to clipboard

Performance issue in the program

Open DLPerf opened this issue 4 years ago • 2 comments

Hello, I found a performance issue in the definition of encode, tensorflow_model_optimization/python/core/internal/tensor_encoding/stages/research/kashin.py, tf.cast will be calculated repeatedly during program execution, resulting in reduced efficiency. I think it should be created before the loop in encode.

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

DLPerf avatar Aug 18 '21 10:08 DLPerf

@DLPerf, it would be great if you can send a PR our way. @PraChetit, could you reply as I don't have any insight on this.

daverim avatar Aug 23 '21 02:08 daverim

It would not be calculated multiple times if you are in graph mode (i.e. when you have tf.function decorator somewhere). But even in eager mode, this would be a negligible difference. Nevertheless, feel free to send PR if that helps.

PraChetit avatar Aug 24 '21 06:08 PraChetit