Caffe2 - C++ API
A deep learning, cross platform ML framework
stump_func_op.cc
1 
17 #include "caffe2/operators/stump_func_op.h"
18 
19 namespace caffe2 {
20 
21 template <>
22 bool StumpFuncOp<float, float, CPUContext>::RunOnDevice() {
23  auto& in = Input(0);
24  const float* in_data = in.template data<float>();
25  auto* out = Output(0);
26  out->ResizeLike(in);
27  float* out_data = out->template mutable_data<float>();
28  for (int i = 0; i < in.size(); i++) {
29  out_data[i] = (in_data[i] <= threshold_) ? low_value_ : high_value_;
30  }
31  return true;
32 }
33 
34 REGISTER_CPU_OPERATOR(StumpFunc, StumpFuncOp<float, float, CPUContext>);
35 
36 OPERATOR_SCHEMA(StumpFunc)
37  .NumInputs(1)
38  .NumOutputs(1)
39  .Input(0, "X", "tensor of float")
40  .Output(0, "Y", "tensor of float")
41  .SetDoc(R"DOC(
42 Converts each input element into either high_ or low_value
43 based on the given threshold.
44 )DOC");
45 
46 NO_GRADIENT(StumpFunc);
47 
48 } // caffe2
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...