Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Blob directly instead of shared_ptr for internal layer buffers #742

Merged
merged 7 commits into from
Jul 20, 2014

Conversation

longjon
Copy link
Contributor

@longjon longjon commented Jul 20, 2014

(This PR separates out and extends some of the cleanup from #594 for more expedient merging.)

Many layers have internal buffers. Currently, some are declared as Blob, while some are declared as shared_ptr<Blob> (and some used to be declared as shared_ptr<SyncedMemory>, although that is no longer as of fb8c061).

This PR changes all internal buffers to be Blob. Aside from consistency, this prepares internal buffers to be reshapable under #594. There are two reasons for this:

  • It simplifies the logic: whether setting up a buffer for the first time or changing its shape, just call Reshape.
  • Reshapable buffers shouldn't be shared anyway, since other owners may not like them changing shape.

…ltiplier_

This will make layer reshaping easier and more uniform, and is
consistent with col_buffer_.
Again, this is more uniform, and will simplify the implementation of
Reshape.
This will simplify the implementation of Reshape by making allocation
automatic. There is no need for shared_ptr here, and this is more
uniform with buffers used by other layers.
@jeffdonahue
Copy link
Contributor

I guess the argument for using a shared_ptr would be to save the time and memory of actually constructing a blob when it's not needed (e.g. if you're not using a bias term in the convolution layer you'd never allocate a bias_multiplier blob at all), but in the case of Blob's default constructor, the savings is two (empty) shared_ptrs and a few ints, so it probably doesn't matter. Merging.

jeffdonahue added a commit that referenced this pull request Jul 20, 2014
Use Blob directly instead of shared_ptr for internal layer buffers
@jeffdonahue jeffdonahue merged commit fb5c568 into BVLC:dev Jul 20, 2014
longjon added a commit to longjon/caffe that referenced this pull request Sep 12, 2014
longjon added a commit to shelhamer/caffe that referenced this pull request Sep 18, 2014
mitmul pushed a commit to mitmul/caffe that referenced this pull request Sep 30, 2014
Use Blob directly instead of shared_ptr for internal layer buffers
mitmul pushed a commit to mitmul/caffe that referenced this pull request Sep 30, 2014
RazvanRanca pushed a commit to RazvanRanca/caffe that referenced this pull request Nov 4, 2014
Use Blob directly instead of shared_ptr for internal layer buffers
RazvanRanca pushed a commit to RazvanRanca/caffe that referenced this pull request Nov 4, 2014
@longjon longjon deleted the direct-blob-buffers branch December 30, 2014 04:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants