Caffe2 - C++ API
A deep learning, cross platform ML framework
rowmul_op.cc
1 #include "caffe2/operators/rowmul_op.h"
2 
3 namespace caffe2 {
4 namespace {
5 
6 REGISTER_CPU_OPERATOR(ReduceTailSum, ReduceTailSumOp<float, CPUContext>);
7 REGISTER_CPU_OPERATOR(RowMul, RowMulOp<float, CPUContext>);
8 
9 OPERATOR_SCHEMA(ReduceTailSum)
10  .NumInputs(1, 1)
11  .NumOutputs(1)
12  .SetDoc(R"DOC(
13 Reduce the tailing dimensions
14 )DOC")
15  .Input(0, "mat", "The matrix")
16  .Output(0, "output", "Output");
17 
18 OPERATOR_SCHEMA(RowMul)
19  .NumInputs(2, 2)
20  .NumOutputs(1)
21  .SetDoc(R"DOC(
22 Given a matrix A and column vector w, the output is the multiplication of row i
23 of A and element i of w, e.g. C[i][j] = A[i][j] * w[i]. This operator should be
24 deprecated when the gradient operator of Mul with broadcast is implemented.
25 )DOC")
26  .Input(0, "mat", "The matrix")
27  .Input(1, "w", "The column vector")
28  .Output(0, "output", "Output");
29 
30 class GetRowMulGradient : public GradientMakerBase {
31  using GradientMakerBase::GradientMakerBase;
32  vector<OperatorDef> GetGradientDefs() override {
33  return vector<OperatorDef>{
34  CreateOperatorDef(
35  "RowMul", "", vector<string>{GO(0), I(1)}, vector<string>{GI(0)}),
36  CreateOperatorDef(
37  "Mul",
38  "",
39  vector<string>{GO(0), I(0)},
40  vector<string>{GI(1) + "before_aggregate"}),
41  CreateOperatorDef(
42  "ReduceTailSum",
43  "",
44  vector<string>{GI(1) + "before_aggregate"},
45  vector<string>{GI(1)})};
46  }
47 };
48 REGISTER_GRADIENT(RowMul, GetRowMulGradient);
49 
50 } // namespace
51 
52 } // namespace caffe2
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
Definition: blob.h:13