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

Method Backward_cpu

src/caffe/layers/concat_layer.cpp:77–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75
76template <typename Dtype>
77void 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
98STUB_GPU(ConcatLayer);

Callers

nothing calls this directly

Calls 5

caffe_copyFunction · 0.85
cpu_diffMethod · 0.80
shapeMethod · 0.80
mutable_cpu_diffMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected