Caffe2 - C++ API
A deep learning, cross platform ML framework
square_root_divide_op.cc
1 #include "caffe2/operators/square_root_divide_op.h"
2 
3 namespace caffe2 {
4 
5 REGISTER_CPU_OPERATOR(SquareRootDivide, SquareRootDivideOp<CPUContext>);
6 OPERATOR_SCHEMA(SquareRootDivide)
7  .NumInputs(2)
8  .NumOutputs(1)
9  .AllowInplace({{0, 0}})
10  .SetDoc(R"DOC(
11 Given DATA tensor with first dimension N and SCALE vector of the same size N
12 produces an output tensor with same dimensions as DATA. Which consists of DATA
13 slices. i-th slice is divided by sqrt(SCALE[i]) elementwise. If SCALE[i] == 0
14 output slice is identical to the input one (no scaling)
15 
16 Example:
17 
18  Data = [
19  [2.0, 4.0],
20  [9.0, 12.0]
21  ]
22 
23  SCALE = [4, 9]
24 
25  OUTPUT = [
26  [1.0, 2.0],
27  [3.0, 4.0]
28  ]
29 
30 )DOC");
31 
33  using GradientMakerBase::GradientMakerBase;
34  vector<OperatorDef> GetGradientDefs() override {
35  return SingleGradientDef(
36  "SquareRootDivide",
37  "",
38  vector<string>{GO(0), I(1)},
39  vector<string>{GI(0)});
40  }
41 };
42 REGISTER_GRADIENT(SquareRootDivide, GetSquareRootDivideGradient);
43 } // namespace caffe2
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
Definition: blob.h:13
static vector< OperatorDef > SingleGradientDef(const Args &...args)
a helper function to allow one to create one single operator def, which is usually the case for many ...