Caffe2 - C++ API
A deep learning, cross platform ML framework
int8_add_op.cc
1 #include "caffe2/operators/quantized/int8_add_op.h"
2 
3 #include <climits>
4 
5 #include "caffe2/operators/utility_ops.h"
6 
7 namespace caffe2 {
8 
9 REGISTER_CPU_OPERATOR(Int8Add, int8::Int8AddOp<int8::Activation::NONE>);
10 REGISTER_CPU_OPERATOR(Int8AddRelu, int8::Int8AddOp<int8::Activation::RELU>);
11 
12 REGISTER_CPU_OPERATOR(Int8Sum, int8::Int8AddOp<int8::Activation::NONE>);
13 REGISTER_CPU_OPERATOR(Int8SumRelu, int8::Int8AddOp<int8::Activation::RELU>);
14 
15 OPERATOR_SCHEMA(Int8Add)
16  .NumInputs(2)
17  .NumOutputs(1)
18  .AllowInplace({{0, 0}, {1, 0}})
19  .Arg("Y_scale", "Output tensor quantization scale")
20  .Arg("Y_zero_point", "Output tensor quantization offset")
21  .SetDoc(R"DOC(
22  Performs element-wise binary Add (with no broadcast support).
23 )DOC")
24  .Input(
25  0,
26  "A",
27  "First operand, should share the type with the second operand.")
28  .Input(1, "B", "Second operand. It should be of the same size as A.")
29  .Output(0, "C", "Result, has same dimensions and type as A");
30 
31 OPERATOR_SCHEMA(Int8AddRelu)
32  .NumInputs(2)
33  .NumOutputs(1)
34  .AllowInplace({{0, 0}, {1, 0}})
35  .Arg("Y_scale", "Output tensor quantization scale")
36  .Arg("Y_zero_point", "Output tensor quantization offset")
37  .SetDoc(R"DOC(
38  Performs element-wise binary Add (with no broadcast support). "
39  "Output will go through rectified linear "
40  "function, where y = max(0, x).
41 )DOC")
42  .Input(
43  0,
44  "A",
45  "First operand, should share the type with the second operand.")
46  .Input(1, "B", "Second operand. It should be of the same size as A.")
47  .Output(0, "C", "Result, has same dimensions and type as A");
48 
49 /*
50  * These ops are defined as alias of Int8Add/Int8AddRelu for compatibility
51  * with current production models. In the future these ops will be changed
52  * to an equivalent of Sum op, which does reduction of a single argument.
53  * We deliberately omit schema for Int8Sum/Int8SumRelu so they can
54  * temporary use either legacy or the new semantics depending on the engine.
55  */
56 OPERATOR_SCHEMA(Int8Sum)
57  .NumInputs(1, std::numeric_limits<int>::max())
58  .NumOutputs(1)
59  .AllowInplace({{0, 0}, {1, 0}})
60  .CostInferenceFunction(CostInferenceForSum)
61  .IdenticalTypeAndShapeOfInput(0)
62  .Arg("Y_scale", "Output tensor quantization scale")
63  .Arg("Y_zero_point", "Output tensor quantization offset");
64 
65 OPERATOR_SCHEMA(Int8SumRelu)
66  .NumInputs(1, std::numeric_limits<int>::max())
67  .NumOutputs(1)
68  .AllowInplace({{0, 0}, {1, 0}})
69  .CostInferenceFunction(CostInferenceForSum)
70  .IdenticalTypeAndShapeOfInput(0)
71  .Arg("Y_scale", "Output tensor quantization scale")
72  .Arg("Y_zero_point", "Output tensor quantization offset");
73 
74 } // namespace caffe2
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
Definition: blob.h:13