1
votes

In faster-rcnn c++ code which was generated from the .proto file (google protobuf) using protoc, I see this line and can't understand it. caffe-fast-rcnn/.build_release/src/caffe/proto/caffe.pb.cc

void NetParameter::MergeFrom(const NetParameter& from) {
  GOOGLE_CHECK_NE(&from, this);
  input_.MergeFrom(from.input_);
  input_shape_.MergeFrom(from.input_shape_);
  input_dim_.MergeFrom(from.input_dim_);
  layer_.MergeFrom(from.layer_);
  layers_.MergeFrom(from.layers_);
  if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
    if (from.has_name()) {
      set_name(from.name());
    }
    if (from.has_force_backward()) {
      set_force_backward(from.force_backward());
    }
    if (from.has_state()) {
      mutable_state()->::caffe::NetState::MergeFrom(from.state());
    }
    if (from.has_debug_info()) {
      set_debug_info(from.debug_info());
    }
  }
  mutable_unknown_fields()->MergeFrom(from.unknown_fields());
}

it's for merging (overwrite singular values and add to arrays) network parameters from 'from' to 'to'. The question I have here is this expression :

if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) 

why use 0/32 as index which is just 0? and why use 0 % 32 which is also 0?

1
I would guess because it is generated automatically that it could also be something different to 0t.niese
As you said, this is generated code. Looks like the generator substituded a 0 into two places in the expresssion.Dan Mašek
Hmm sounds plausible. sorry I can't mark your reply as answer because it's comment. just gave +1. :)Chan Kim

1 Answers

1
votes

Code generators often create code like this. In your case, the both expressions 0%32 and 0/32 result in 0. Since both expressions are calculated/simplified by the preprocessor, they consume no runtime.