Caffe2 - C++ API
A deep learning, cross platform ML framework
log_op.cc
1 
17 #include "caffe2/operators/math_ops.h"
18 #include "caffe2/utils/math.h"
19 
20 
21 namespace caffe2 {
22 
23 struct LogCPUFunctor {
24  template <typename T>
25  inline void
26  operator()(const int n, const T* x, T* y, CPUContext* device_context) {
27  math::Log<T, CPUContext>(n, x, y, device_context);
28  }
29 };
30 
31 REGISTER_CPU_OPERATOR(
32  Log,
34 
35 OPERATOR_SCHEMA(Log)
36  .NumInputs(1)
37  .NumOutputs(1)
38  .AllowInplace({{0, 0}})
39  .IdenticalTypeAndShape()
40  .SetDoc(R"DOC(
41 Calculates the natural log of the given input tensor, element-wise. This
42 operation can be done in an in-place fashion too, by providing the same input
43 and output blobs.
44 )DOC")
45  .Input(0, "input", "Input tensor")
46  .Output(
47  0,
48  "output",
49  "The natural log of the input tensor computed "
50  "element-wise");
51 
53  using GradientMakerBase::GradientMakerBase;
54  vector<OperatorDef> GetGradientDefs() override {
55  return SingleGradientDef(
56  "Div",
57  "",
58  std::vector<string>{GO(0), I(0)},
59  std::vector<string>{GI(0)});
60  }
61 };
62 REGISTER_GRADIENT(Log, GetLogGradient);
63 
64 } // namespace caffe2
The CPU Context, representing the bare minimum of what a Context class in Caffe2 should implement...
Definition: context.h:82
Copyright (c) 2016-present, Facebook, Inc.