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

Method Forward_cpu

src/caffe/layers/reduction_layer.cpp:42–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40
41template <typename Dtype>
42void ReductionLayer<Dtype>::Forward_cpu(
43 const vector<Blob<Dtype>*>& bottom, const vector<Blob<Dtype>*>& top) {
44 const Dtype* bottom_data = bottom[0]->cpu_data();
45 const Dtype* mult_data = NULL;
46 if (sum_multiplier_.count() > 0) {
47 mult_data = sum_multiplier_.cpu_data();
48 }
49 Dtype* top_data = top[0]->mutable_cpu_data();
50 for (int i = 0; i < num_; ++i) {
51 switch (op_) {
52 case ReductionParameter_ReductionOp_SUM:
53 case ReductionParameter_ReductionOp_MEAN:
54 *top_data = caffe_cpu_dot(dim_, mult_data, bottom_data);
55 break;
56 case ReductionParameter_ReductionOp_ASUM:
57 *top_data = caffe_cpu_asum(dim_, bottom_data);
58 break;
59 case ReductionParameter_ReductionOp_SUMSQ:
60 *top_data = caffe_cpu_dot(dim_, bottom_data, bottom_data);
61 break;
62 default:
63 LOG(FATAL) << "Unknown reduction op: "
64 << ReductionParameter_ReductionOp_Name(op_);
65 }
66 bottom_data += dim_;
67 ++top_data;
68 }
69 if (coeff_ != Dtype(1)) {
70 // Reset the top_data pointer.
71 top_data = top[0]->mutable_cpu_data();
72 caffe_scal(num_, coeff_, top_data);
73 }
74}
75
76template <typename Dtype>
77void ReductionLayer<Dtype>::Backward_cpu(const vector<Blob<Dtype>*>& top,

Callers

nothing calls this directly

Calls 4

caffe_cpu_dotFunction · 0.85
countMethod · 0.80
cpu_dataMethod · 0.45
mutable_cpu_dataMethod · 0.45

Tested by

no test coverage detected