| 390 | |
| 391 | template <typename Dtype> |
| 392 | bool Blob<Dtype>::ShapeEquals(const BlobProto& other) { |
| 393 | if (other.has_num() || other.has_channels() || |
| 394 | other.has_height() || other.has_width()) { |
| 395 | // Using deprecated 4D Blob dimensions -- |
| 396 | // shape is (num, channels, height, width). |
| 397 | // Note: we do not use the normal Blob::num(), Blob::channels(), etc. |
| 398 | // methods as these index from the beginning of the blob shape, where legacy |
| 399 | // parameter blobs were indexed from the end of the blob shape (e.g., bias |
| 400 | // Blob shape (1 x 1 x 1 x N), IP layer weight Blob shape (1 x 1 x M x N)). |
| 401 | return shape_.size() <= 4 && |
| 402 | LegacyShape(-4) == other.num() && |
| 403 | LegacyShape(-3) == other.channels() && |
| 404 | LegacyShape(-2) == other.height() && |
| 405 | LegacyShape(-1) == other.width(); |
| 406 | } |
| 407 | vector<int> other_shape(other.shape().dim_size()); |
| 408 | for (int i = 0; i < other.shape().dim_size(); ++i) { |
| 409 | other_shape[i] = other.shape().dim(i); |
| 410 | } |
| 411 | return shape_ == other_shape; |
| 412 | } |
| 413 | |
| 414 | template <typename Dtype> |
| 415 | void Blob<Dtype>::CopyFrom(const Blob& source, bool copy_diff, bool reshape) { |