Caffe2 - C++ API
A deep learning, cross platform ML framework
log_op.cc
1 #include "caffe2/operators/math_ops.h"
2 #include "caffe2/utils/math.h"
3 
4 
5 namespace caffe2 {
6 
7 struct LogCPUFunctor {
8  template <typename T>
9  inline void
10  operator()(const int n, const T* x, T* y, CPUContext* device_context) {
11  math::Log<T, CPUContext>(n, x, y, device_context);
12  }
13 };
14 
15 REGISTER_CPU_OPERATOR(
16  Log,
18 
19 OPERATOR_SCHEMA(Log)
20  .NumInputs(1)
21  .NumOutputs(1)
22  .AllowInplace({{0, 0}})
23  .IdenticalTypeAndShape()
24  .SetDoc(R"DOC(
25 Calculates the natural log of the given input tensor, element-wise. This
26 operation can be done in an in-place fashion too, by providing the same input
27 and output blobs.
28 )DOC")
29  .Input(0, "input", "Input tensor")
30  .Output(
31  0,
32  "output",
33  "The natural log of the input tensor computed "
34  "element-wise")
35  .InheritOnnxSchema("Log");
36 
38  using GradientMakerBase::GradientMakerBase;
39  vector<OperatorDef> GetGradientDefs() override {
40  return SingleGradientDef(
41  "Div",
42  "",
43  std::vector<string>{GO(0), I(0)},
44  std::vector<string>{GI(0)});
45  }
46 };
47 REGISTER_GRADIENT(Log, GetLogGradient);
48 
49 } // namespace caffe2
The CPU Context, representing the bare minimum of what a Context class in Caffe2 should implement...
Definition: context.h:66
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...