Caffe2 - C++ API
A deep learning, cross platform ML framework
square_root_divide_op.cc
1 
17 #include "caffe2/operators/square_root_divide_op.h"
18 
19 namespace caffe2 {
20 
21 REGISTER_CPU_OPERATOR(SquareRootDivide, SquareRootDivideOp<CPUContext>);
22 OPERATOR_SCHEMA(SquareRootDivide)
23  .NumInputs(2)
24  .NumOutputs(1)
25  .AllowInplace({{0, 0}})
26  .SetDoc(R"DOC(
27 Given DATA tensor with first dimension N and SCALE vector of the same size N
28 produces an output tensor with same dimensions as DATA. Which consists of DATA
29 slices. i-th slice is divided by sqrt(SCALE[i]) elementwise. If SCALE[i] == 0
30 output slice is identical to the input one (no scaling)
31 
32 Example:
33 
34  Data = [
35  [2.0, 4.0],
36  [9.0, 12.0]
37  ]
38 
39  SCALE = [4, 9]
40 
41  OUTPUT = [
42  [1.0, 2.0],
43  [3.0, 4.0]
44  ]
45 
46 )DOC");
47 
49  using GradientMakerBase::GradientMakerBase;
50  vector<OperatorDef> GetGradientDefs() override {
51  return SingleGradientDef(
52  "SquareRootDivide",
53  "",
54  vector<string>{GO(0), I(1)},
55  vector<string>{GI(0)});
56  }
57 };
58 REGISTER_GRADIENT(SquareRootDivide, GetSquareRootDivideGradient);
59 } // namespace caffe2
Copyright (c) 2016-present, Facebook, Inc.
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 ...