benchmarks icon indicating copy to clipboard operation
benchmarks copied to clipboard

Why reshape after bias_add ?

Open sleepfin opened this issue 7 years ago • 5 comments

Notice codes HERE

        biased = tf.reshape(
            tf.nn.bias_add(
                conv, biases, data_format=self.data_format),
            conv.get_shape())

I think the output shape of bias_add is exactly the same as conv.get_shape(). So why bother to reshape? Then I add some slim analyzer codes to print the total_ops total_ops = slim.model_analyzer.analyze_ops(sess.graph) I notice that total_ops is different with reshape or not (Run Training)

With reshape: TOTAL_OPS = 4856506501 Without reshape: TOTAL_OPS = 3989465117

Of course the performance is also different.

sleepfin avatar Jun 09 '17 03:06 sleepfin

Thank you for the note. We are checking it out. Sorry for the slow response.

tfboyd avatar Jun 27 '17 20:06 tfboyd

Your findings have been confirmed internally with some basic testing, the next version will have it fixed assuming something very unexpected does not happen. In Q3 -2017 I hope to setup an auto sync so we can push out changes more often. Thank you again for the notice and information.

tfboyd avatar Jun 27 '17 23:06 tfboyd

I am 99% sure this has been fixed. I looked at that section and unless I am just not seeing the reshape, it has been fixed. Sorry for the slow update and more sorry if I am reading the code wrong.

tfboyd avatar Oct 24 '17 18:10 tfboyd

@tfboyd Hi, I still find the reshape after bias add, can you help to check it? add the code bellow. thanks. https://github.com/tensorflow/benchmarks/blob/master/scripts/tf_cnn_benchmarks/convnet_builder.py#L217

guizili0 avatar Jan 07 '19 03:01 guizili0

@reedwm will take it. Sorry maybe I missed it or there was some funny rollback. Either way very sorry.

tfboyd avatar Jan 11 '19 02:01 tfboyd