| 18 | // Compute y = (shift + scale * x)^power |
| 19 | template <typename Dtype> |
| 20 | void 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 | |
| 43 | template <typename Dtype> |
| 44 | void PowerLayer<Dtype>::Backward_cpu(const vector<Blob<Dtype>*>& top, |
nothing calls this directly
no test coverage detected