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

Method Backward_cpu

src/caffe/layers/bias_layer.cpp:90–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88
89template <typename Dtype>
90void BiasLayer<Dtype>::Backward_cpu(const vector<Blob<Dtype>*>& top,
91 const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom) {
92 if (propagate_down[0] && bottom[0] != top[0]) {
93 const Dtype* top_diff = top[0]->cpu_diff();
94 Dtype* bottom_diff = bottom[0]->mutable_cpu_diff();
95 caffe_copy(bottom[0]->count(), top_diff, bottom_diff);
96 }
97 // in-place, we don't need to do anything with the data diff
98 const bool bias_param = (bottom.size() == 1);
99 if ((!bias_param && propagate_down[1]) ||
100 (bias_param && this->param_propagate_down_[0])) {
101 const Dtype* top_diff = top[0]->cpu_diff();
102 Dtype* bias_diff = (bias_param ? this->blobs_[0].get() : bottom[1])
103 ->mutable_cpu_diff();
104 bool accum = bias_param;
105 for (int n = 0; n < outer_dim_; ++n) {
106 caffe_cpu_gemv(CblasNoTrans, bias_dim_, inner_dim_, Dtype(1),
107 top_diff, bias_multiplier_.cpu_data(), Dtype(accum), bias_diff);
108 top_diff += dim_;
109 accum = true;
110 }
111 }
112}
113
114#ifdef CPU_ONLY
115STUB_GPU(BiasLayer);

Callers

nothing calls this directly

Calls 7

caffe_copyFunction · 0.85
cpu_diffMethod · 0.80
mutable_cpu_diffMethod · 0.80
countMethod · 0.80
sizeMethod · 0.45
getMethod · 0.45
cpu_dataMethod · 0.45

Tested by

no test coverage detected