| 75 | |
| 76 | template <typename Dtype> |
| 77 | void ConcatLayer<Dtype>::Backward_cpu(const vector<Blob<Dtype>*>& top, |
| 78 | const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom) { |
| 79 | if (bottom.size() == 1) { return; } |
| 80 | const Dtype* top_diff = top[0]->cpu_diff(); |
| 81 | int offset_concat_axis = 0; |
| 82 | const int top_concat_axis = top[0]->shape(concat_axis_); |
| 83 | for (int i = 0; i < bottom.size(); ++i) { |
| 84 | const int bottom_concat_axis = bottom[i]->shape(concat_axis_); |
| 85 | if (propagate_down[i]) { |
| 86 | Dtype* bottom_diff = bottom[i]->mutable_cpu_diff(); |
| 87 | for (int n = 0; n < num_concats_; ++n) { |
| 88 | caffe_copy(bottom_concat_axis * concat_input_size_, top_diff + |
| 89 | (n * top_concat_axis + offset_concat_axis) * concat_input_size_, |
| 90 | bottom_diff + n * bottom_concat_axis * concat_input_size_); |
| 91 | } |
| 92 | } |
| 93 | offset_concat_axis += bottom_concat_axis; |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | #ifdef CPU_ONLY |
| 98 | STUB_GPU(ConcatLayer); |
nothing calls this directly
no test coverage detected