| 55 | |
| 56 | template <typename Dtype> |
| 57 | void LogLayer<Dtype>::Backward_cpu(const vector<Blob<Dtype>*>& top, |
| 58 | const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom) { |
| 59 | if (!propagate_down[0]) { return; } |
| 60 | const int count = bottom[0]->count(); |
| 61 | const Dtype* bottom_data = bottom[0]->cpu_data(); |
| 62 | const Dtype* top_diff = top[0]->cpu_diff(); |
| 63 | Dtype* bottom_diff = bottom[0]->mutable_cpu_diff(); |
| 64 | caffe_copy(count, bottom_data, bottom_diff); |
| 65 | if (input_scale_ != Dtype(1)) { |
| 66 | caffe_scal(count, input_scale_, bottom_diff); |
| 67 | } |
| 68 | if (input_shift_ != Dtype(0)) { |
| 69 | caffe_add_scalar(count, input_shift_, bottom_diff); |
| 70 | } |
| 71 | caffe_powx(count, bottom_diff, Dtype(-1), bottom_diff); |
| 72 | if (backward_num_scale_ != Dtype(1)) { |
| 73 | caffe_scal(count, backward_num_scale_, bottom_diff); |
| 74 | } |
| 75 | caffe_mul(count, top_diff, bottom_diff, bottom_diff); |
| 76 | } |
| 77 | |
| 78 | #ifdef CPU_ONLY |
| 79 | STUB_GPU(LogLayer); |
nothing calls this directly
no test coverage detected