Caffe2 - C++ API
A deep learning, cross platform ML framework
negate_gradient_op.cc
1 #include "caffe2/operators/negate_gradient_op.h"
2 
3 namespace caffe2 {
4 
5 REGISTER_CPU_OPERATOR(NegateGradient, NegateGradientOp<CPUContext>);
6 OPERATOR_SCHEMA(NegateGradient)
7  .NumInputs(1)
8  .NumOutputs(1)
9  .AllowInplace({{0, 0}})
10  .SetDoc(R"DOC(
11 NegagteGradient operator in forward pass simply copies input to the
12 output, and in backward pass, flips the sign of the output gradient
13 )DOC");
14 
16  using GradientMakerBase::GradientMakerBase;
17  std::vector<OperatorDef> GetGradientDefs() override {
18  CAFFE_ENFORCE_EQ(def_.input_size(), 1);
19  return SingleGradientDef(
20  "Negative", "", vector<string>{GO(0)}, vector<string>{GI(0)});
21  }
22 };
23 
24 REGISTER_GRADIENT(NegateGradient, GetNegateGradientGradient);
25 
26 } // 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 ...