Use proto extensions with hashed field numbers for layer-specific parameters #2036
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is the proof-of-concept mentioned by @shelhamer in #1896. DO NOT MERGE -- I'm not really sure if this is a good way to go, this PR is just for discussion for now.
This would facilitate self-contained independent development of layers by addressing one of the major current pain points with that -- conflicting proto field numbers. The idea is that instead of picking a field number consecutively after the previous one, which of course causes conflicts whenever other new layers are added, as long as your field name (e.g.,
convolution_param
) doesn't conflict with anything else inLayerParameter
, the field number is generated as a function of the name, and (with high probability) you get a unique number. (The collision odds for any given pair of extensions are 1 in 536,850,911; haven't done the birthday problem analysis to figure out what that actually means in practice, but if we were going to use this we might need to eventually add a "salt" field to escape collisions.)See
src/caffe/proto/reshape_param.proto.varextnum
for an example of what it looks like to declare a LayerParameter extension this way. The scriptscripts/fill_proto_ext_num.py
creates the actualreshape_param.proto
file from the*.varextnum
version.Build notes: there is currently something finicky about my Makefile changes such that parallel builds with
make -j
sometimes don't work -- a workaround is to first domake proto
(no-j
) before doingmake -j
. I haven't attempted to add CMake support.