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

Method Backward_cpu

src/caffe/layers/slice_layer.cpp:97–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95
96template <typename Dtype>
97void 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
118STUB_GPU(SliceLayer);

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected