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

Method Forward_cpu

src/caffe/layers/scale_layer.cpp:117–142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115
116template <typename Dtype>
117void ScaleLayer<Dtype>::Forward_cpu(
118 const vector<Blob<Dtype>*>& bottom, const vector<Blob<Dtype>*>& top) {
119 const Dtype* bottom_data = bottom[0]->cpu_data();
120 if (bottom[0] == top[0]) {
121 // In-place computation; need to store bottom data before overwriting it.
122 // Note that this is only necessary for Backward; we could skip this if not
123 // doing Backward, but Caffe currently provides no way of knowing whether
124 // we'll need to do Backward at the time of the Forward call.
125 caffe_copy(bottom[0]->count(), bottom[0]->cpu_data(),
126 temp_.mutable_cpu_data());
127 }
128 const Dtype* scale_data =
129 ((bottom.size() > 1) ? bottom[1] : this->blobs_[0].get())->cpu_data();
130 Dtype* top_data = top[0]->mutable_cpu_data();
131 for (int n = 0; n < outer_dim_; ++n) {
132 for (int d = 0; d < scale_dim_; ++d) {
133 const Dtype factor = scale_data[d];
134 caffe_cpu_scale(inner_dim_, factor, bottom_data, top_data);
135 bottom_data += inner_dim_;
136 top_data += inner_dim_;
137 }
138 }
139 if (bias_layer_) {
140 bias_layer_->Forward(bias_bottom_vec_, top);
141 }
142}
143
144template <typename Dtype>
145void ScaleLayer<Dtype>::Backward_cpu(const vector<Blob<Dtype>*>& top,

Callers

nothing calls this directly

Calls 7

caffe_copyFunction · 0.85
countMethod · 0.80
ForwardMethod · 0.80
cpu_dataMethod · 0.45
mutable_cpu_dataMethod · 0.45
sizeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected