MCPcopy Create free account
hub / github.com/BVLC/caffe / Reshape

Method Reshape

src/caffe/layers/flatten_layer.cpp:8–27  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6
7template <typename Dtype>
8void 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
29template <typename Dtype>
30void FlattenLayer<Dtype>::Forward_cpu(const vector<Blob<Dtype>*>& bottom,

Callers

nothing calls this directly

Calls 5

typeMethod · 0.95
CanonicalAxisIndexMethod · 0.80
shapeMethod · 0.80
countMethod · 0.80
num_axesMethod · 0.80

Tested by

no test coverage detected