Caffe2 - C++ API
A deep learning, cross platform ML framework
exp_op.cc
1 #include "caffe2/operators/elementwise_op.h"
2 #include "caffe2/utils/math.h"
3 
4 namespace caffe2 {
5 
6 struct ExpCPUFunctor {
7  template <typename T>
8  inline void
9  operator()(const int n, const T* x, T* y, CPUContext* device_context) {
10  math::Exp<T, CPUContext>(n, x, y, device_context);
11  }
12 };
13 
14 REGISTER_CPU_OPERATOR(
15  Exp,
17 
18 OPERATOR_SCHEMA(Exp)
19  .NumInputs(1)
20  .NumOutputs(1)
21  .AllowInplace({{0, 0}})
22  .IdenticalTypeAndShape()
23  .SetDoc(R"DOC(
24 Calculates the exponential of the given input tensor, element-wise. This
25 operation can be done in an in-place fashion too, by providing the same input
26 and output blobs.
27 )DOC")
28  .Input(0, "input", "Input tensor")
29  .Output(
30  0,
31  "output",
32  "The exponential of the input tensor computed "
33  "element-wise")
34  .InheritOnnxSchema("Exp");
35 
37  using GradientMakerBase::GradientMakerBase;
38  vector<OperatorDef> GetGradientDefs() override {
39  return SingleGradientDef(
40  "Mul",
41  "",
42  std::vector<string>{O(0), GO(0)},
43  std::vector<string>{GI(0)});
44  }
45 };
46 REGISTER_GRADIENT(Exp, GetExpGradient);
47 } // 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 ...