Caffe 中类似函数的宏(如 CHECK & CHECK_EQ)的定义究竟在哪里?

Where is exactly the definition of function-like macros such as CHECK & CHECK_EQ in Caffe?

本文关键字:CHECK EQ 定义 在哪里 究竟 函数 Caffe      更新时间:2023-10-16

正如我所注意到的,有很多类似函数的宏,如CHECKCHECK_EQ。。。它经常用于Caffe头文件和源文件,例如在blob.cpp中,我们有:

template <typename Dtype>
void Blob<Dtype>::FromProto(const BlobProto& proto, bool reshape) {
if (reshape) {
  vector<int> shape;
  if (proto.has_num() || proto.has_channels() ||
      proto.has_height() || proto.has_width()) {
    // Using deprecated 4D Blob dimensions --
    // shape is (num, channels, height, width).
    shape.resize(4);
    shape[0] = proto.num();
    shape[1] = proto.channels();
    shape[2] = proto.height();
    shape[3] = proto.width();
  } else {
    shape.resize(proto.shape().dim_size());
    for (int i = 0; i < proto.shape().dim_size(); ++i) {
      shape[i] = proto.shape().dim(i);
    }
  }
  Reshape(shape);
} else {
  CHECK(ShapeEquals(proto)) << "shape mismatch (reshape not set)";
}
// copy data
Dtype* data_vec = mutable_cpu_data();
if (proto.double_data_size() > 0) {
  CHECK_EQ(count_, proto.double_data_size());
  for (int i = 0; i < count_; ++i) {
    data_vec[i] = proto.double_data(i);
  }
} else {
  CHECK_EQ(count_, proto.data_size());
  for (int i = 0; i < count_; ++i) {
    data_vec[i] = proto.data(i);
  }
}
if (proto.double_diff_size() > 0) {
  CHECK_EQ(count_, proto.double_diff_size());
  Dtype* diff_vec = mutable_cpu_diff();
  for (int i = 0; i < count_; ++i) {
    diff_vec[i] = proto.double_diff(i);
  }
} else if (proto.diff_size() > 0) {
  CHECK_EQ(count_, proto.diff_size());
  Dtype* diff_vec = mutable_cpu_diff();
  for (int i = 0; i < count_; ++i) {
    diff_vec[i] = proto.diff(i);
  }
 }

这些宏的定义究竟在哪里?

这些宏是caffe正在使用的Google glog日志库的一部分。