Caffe2 - C++ API
A deep learning, cross platform ML framework
scale_op.cc
1 #include "caffe2/operators/scale_op.h"
2 
3 namespace caffe2 {
4 
5 REGISTER_CPU_OPERATOR(Scale, ScaleOp<CPUContext>);
6 OPERATOR_SCHEMA(Scale)
7  .NumInputs(1)
8  .NumOutputs(1)
9  .AllowInplace({{0, 0}})
10  .IdenticalTypeAndShape()
11  .SetDoc(R"DOC(
12 Scale takes one input data (Tensor) and produces one output data
13 (Tensor) whose value is the input data tensor scaled element-wise.
14 )DOC")
15  .Arg("scale", "(float, default 1.0) the scale to apply.");
16 
18  using GradientMakerBase::GradientMakerBase;
19  vector<OperatorDef> GetGradientDefs() override {
20  // CopyArguments is true by default so the "scale" arg is going to be copied
21  return SingleGradientDef(
22  "Scale", "", vector<string>{GO(0)}, vector<string>{GI(0)});
23  }
24 };
25 REGISTER_GRADIENT(Scale, GetScaleGradient);
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 ...