| 6 | |
| 7 | template <typename Dtype> |
| 8 | void ReshapeLayer<Dtype>::LayerSetUp(const vector<Blob<Dtype>*>& bottom, |
| 9 | const vector<Blob<Dtype>*>& top) { |
| 10 | CHECK_NE(top[0], bottom[0]) << this->type() << " Layer does not " |
| 11 | "allow in-place computation."; |
| 12 | inferred_axis_ = -1; |
| 13 | copy_axes_.clear(); |
| 14 | const BlobShape& top_blob_shape = this->layer_param_.reshape_param().shape(); |
| 15 | const int top_num_axes = top_blob_shape.dim_size(); |
| 16 | constant_count_ = 1; |
| 17 | for (int i = 0; i < top_num_axes; ++i) { |
| 18 | const int top_dim = top_blob_shape.dim(i); |
| 19 | if (top_dim == 0) { |
| 20 | copy_axes_.push_back(i); |
| 21 | } else if (top_dim == -1) { |
| 22 | CHECK_EQ(inferred_axis_, -1) << "new shape contains multiple " |
| 23 | << "-1 dims; at most a single (1) value of -1 may be specified"; |
| 24 | inferred_axis_ = i; |
| 25 | } else { |
| 26 | constant_count_ *= top_dim; |
| 27 | } |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | template <typename Dtype> |
| 32 | void ReshapeLayer<Dtype>::Reshape(const vector<Blob<Dtype>*>& bottom, |