| 74 | |
| 75 | template <typename Dtype> |
| 76 | void 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 | |
| 96 | template <typename Dtype> |
| 97 | void SliceLayer<Dtype>::Backward_cpu(const vector<Blob<Dtype>*>& top, |
nothing calls this directly
no test coverage detected