Caffe2 - C++ API
A deep learning, cross platform ML framework
zero_gradient_op.cc
1 
17 #include "caffe2/operators/zero_gradient_op.h"
18 
19 namespace caffe2 {
20 
21 REGISTER_CPU_OPERATOR(ZeroGradient, ZeroGradientOp<CPUContext>);
22 OPERATOR_SCHEMA(ZeroGradient)
23  .NumInputs(1)
24  .NumOutputs(0)
25  .SetDoc(R"DOC(
26 ZeroGradient operators doesn't produce any output blobs. One can use
27 this operator to produce 0 gradient for the input blob.
28 )DOC");
29 
31  using GradientMakerBase::GradientMakerBase;
32  std::vector<OperatorDef> GetGradientDefs() override {
33  return SingleGradientDef(
34  "ConstantFill",
35  "",
36  vector<string>{I(0)},
37  vector<string>{GI(0)},
38  vector<Argument>{MakeArgument<float>("value", 0.0)});
39  }
40 };
41 
42 REGISTER_GRADIENT(ZeroGradient, GetZeroGradientOpGradient);
43 
44 } // 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 ...