| 95 | |
| 96 | template <typename Dtype> |
| 97 | void SliceLayer<Dtype>::Backward_cpu(const vector<Blob<Dtype>*>& top, |
| 98 | const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom) { |
| 99 | if (!propagate_down[0] || top.size() == 1) { return; } |
| 100 | int offset_slice_axis = 0; |
| 101 | Dtype* bottom_diff = bottom[0]->mutable_cpu_diff(); |
| 102 | const int bottom_slice_axis = bottom[0]->shape(slice_axis_); |
| 103 | for (int i = 0; i < top.size(); ++i) { |
| 104 | const Dtype* top_diff = top[i]->cpu_diff(); |
| 105 | const int top_slice_axis = top[i]->shape(slice_axis_); |
| 106 | for (int n = 0; n < num_slices_; ++n) { |
| 107 | const int top_offset = n * top_slice_axis * slice_size_; |
| 108 | const int bottom_offset = |
| 109 | (n * bottom_slice_axis + offset_slice_axis) * slice_size_; |
| 110 | caffe_copy(top_slice_axis * slice_size_, |
| 111 | top_diff + top_offset, bottom_diff + bottom_offset); |
| 112 | } |
| 113 | offset_slice_axis += top_slice_axis; |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | #ifdef CPU_ONLY |
| 118 | STUB_GPU(SliceLayer); |
nothing calls this directly
no test coverage detected