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

Method Forward_cpu

src/caffe/layers/power_layer.cpp:20–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18// Compute y = (shift + scale * x)^power
19template <typename Dtype>
20void PowerLayer<Dtype>::Forward_cpu(const vector<Blob<Dtype>*>& bottom,
21 const vector<Blob<Dtype>*>& top) {
22 Dtype* top_data = top[0]->mutable_cpu_data();
23 const int count = bottom[0]->count();
24 // Special case where we can ignore the input: scale or power is 0.
25 if (diff_scale_ == Dtype(0)) {
26 Dtype value = (power_ == 0) ? Dtype(1) : pow(shift_, power_);
27 caffe_set(count, value, top_data);
28 return;
29 }
30 const Dtype* bottom_data = bottom[0]->cpu_data();
31 caffe_copy(count, bottom_data, top_data);
32 if (scale_ != Dtype(1)) {
33 caffe_scal(count, scale_, top_data);
34 }
35 if (shift_ != Dtype(0)) {
36 caffe_add_scalar(count, shift_, top_data);
37 }
38 if (power_ != Dtype(1)) {
39 caffe_powx(count, top_data, power_, top_data);
40 }
41}
42
43template <typename Dtype>
44void PowerLayer<Dtype>::Backward_cpu(const vector<Blob<Dtype>*>& top,

Callers

nothing calls this directly

Calls 6

caffe_setFunction · 0.85
caffe_copyFunction · 0.85
caffe_add_scalarFunction · 0.85
countMethod · 0.80
mutable_cpu_dataMethod · 0.45
cpu_dataMethod · 0.45

Tested by

no test coverage detected