bool Blob<Dtype>::ShapeEquals(const BlobProto& other) { if (other.has_num() || other.has_channels() || other.has_height() || other.has_width()) { // Using deprecated 4D Blob dimensions -- // shape is (num, channels, height, width). // Note: we do not use the normal Blob::num(), Blob::channels(), etc. // methods as these index from the beginning of the blob shape, where legacy // parameter blobs were indexed from the end of the blob shape (e.g., bias // Blob shape (1 x 1 x 1 x N), IP layer weight Blob shape (1 x 1 x M x N)). return shape_.size() <= 4 && LegacyShape(-4) == other.num() && LegacyShape(-3) == other.channels() && LegacyShape(-2) == other.height() && LegacyShape(-1) == other.width(); } vector<int> other_shape(other.shape().dim_size()); for (int i = 0; i < other.shape().dim_size(); ++i) { other_shape[i] = other.shape().dim(i); } return shape_ == other_shape; }
/// @brief Deprecated legacy shape accessor width: use shape(3) instead. inline int width() const {return LegacyShape(3);}
/// @brief Deprecated legacy shape accessor height: use shape(2) instead. inline int height() const {return LegacyShape(2);}
/// @brief Deprecated legacy shape accessor channels: use shape(1) instead. inline int channels() const {return LegacyShape(1);}
/// @brief Deprecated legacy shape accessor num: use shape(0) instead. inline int num() const {return LegacyShape(0);}
/// @brief Deprecated legacy shape accessor num: use shape(0) instead. inline int num() const { return LegacyShape(0, false); }