| 6 | |
| 7 | template <typename Dtype> |
| 8 | void FlattenLayer<Dtype>::Reshape(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 | const int start_axis = bottom[0]->CanonicalAxisIndex( |
| 13 | this->layer_param_.flatten_param().axis()); |
| 14 | const int end_axis = bottom[0]->CanonicalAxisIndex( |
| 15 | this->layer_param_.flatten_param().end_axis()); |
| 16 | vector<int> top_shape; |
| 17 | for (int i = 0; i < start_axis; ++i) { |
| 18 | top_shape.push_back(bottom[0]->shape(i)); |
| 19 | } |
| 20 | const int flattened_dim = bottom[0]->count(start_axis, end_axis + 1); |
| 21 | top_shape.push_back(flattened_dim); |
| 22 | for (int i = end_axis + 1; i < bottom[0]->num_axes(); ++i) { |
| 23 | top_shape.push_back(bottom[0]->shape(i)); |
| 24 | } |
| 25 | top[0]->Reshape(top_shape); |
| 26 | CHECK_EQ(top[0]->count(), bottom[0]->count()); |
| 27 | } |
| 28 | |
| 29 | template <typename Dtype> |
| 30 | void FlattenLayer<Dtype>::Forward_cpu(const vector<Blob<Dtype>*>& bottom, |
nothing calls this directly
no test coverage detected