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

Method Forward_cpu

src/caffe/layers/slice_layer.cpp:76–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74
75template <typename Dtype>
76void SliceLayer<Dtype>::Forward_cpu(const vector<Blob<Dtype>*>& bottom,
77 const vector<Blob<Dtype>*>& top) {
78 if (top.size() == 1) { return; }
79 int offset_slice_axis = 0;
80 const Dtype* bottom_data = bottom[0]->cpu_data();
81 const int bottom_slice_axis = bottom[0]->shape(slice_axis_);
82 for (int i = 0; i < top.size(); ++i) {
83 Dtype* top_data = top[i]->mutable_cpu_data();
84 const int top_slice_axis = top[i]->shape(slice_axis_);
85 for (int n = 0; n < num_slices_; ++n) {
86 const int top_offset = n * top_slice_axis * slice_size_;
87 const int bottom_offset =
88 (n * bottom_slice_axis + offset_slice_axis) * slice_size_;
89 caffe_copy(top_slice_axis * slice_size_,
90 bottom_data + bottom_offset, top_data + top_offset);
91 }
92 offset_slice_axis += top_slice_axis;
93 }
94}
95
96template <typename Dtype>
97void SliceLayer<Dtype>::Backward_cpu(const vector<Blob<Dtype>*>& top,

Callers

nothing calls this directly

Calls 5

caffe_copyFunction · 0.85
shapeMethod · 0.80
sizeMethod · 0.45
cpu_dataMethod · 0.45
mutable_cpu_dataMethod · 0.45

Tested by

no test coverage detected