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