Why is the Layer::Reshape(...) function called for every Forward?!

452 views
Skip to first unread message

Philipp

unread,
Aug 21, 2015, 5:02:45 AM8/21/15
to Caffe Users
I am developing caffe code for over half a year now.
I still don't quite understand why there is LayerSetUp and Reshape and why Reshape is called in

inline Dtype Layer<Dtype>::Forward(...)

It should only be called if size has acutally changed.
 
If LayerSetUp is to set up size-independent stuff, then why in e.g. "BaseConvolutionLayer<Dtype>::LayerSetUp(...)", many size-dependent things happen (bottom channels)

I know in the old caffe it hasn't been like that.
For our nets we have homogenously-sized data and I think this is a big overhead.

Evan Shelhamer

unread,
Aug 24, 2015, 9:29:51 PM8/24/15
to Philipp, Caffe Users
`Layer::Reshape()` was introduced in https://github.com/BVLC/caffe/pull/594. There is virtually no overhead except when an input is large enough to require reallocation. For fixed size input the `Reshape()` calls are essentially no-ops.

Evan Shelhamer

--
You received this message because you are subscribed to the Google Groups "Caffe Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to caffe-users...@googlegroups.com.
To post to this group, send email to caffe...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/caffe-users/e54c237c-9518-49e0-80dc-1e54d5ede19b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Philipp

unread,
Aug 28, 2015, 9:05:48 AM8/28/15
to Caffe Users, m...@phil.fm
Thanks Evan for your reply.
I agree that the Blob Reshape functions behave exactly as you describe.
However I am talking about the Layer Reshape which will be reimplemented for every layer and for some layers may involve 
additional overhead to recompute the desired top blob sizes (which however won't have changed if the bottom didn't change).

I think it would be sensible to check if any bottom blob sizes have changed before actually calling the layer's Reshape method.

Reply all
Reply to author
Forward
0 new messages