tvm
attrs.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 
24 #ifndef TVM_RELAY_QNN_ATTRS_H_
25 #define TVM_RELAY_QNN_ATTRS_H_
26 
27 #include <tvm/ir/attrs.h>
28 
29 #include <string>
30 
31 namespace tvm {
32 namespace relay {
33 namespace qnn {
34 
36 struct RequantizeAttrs : public tvm::AttrsNode<RequantizeAttrs> {
37  int axis;
38  std::string rounding;
40 
41  TVM_DECLARE_ATTRS(RequantizeAttrs, "relay.attrs.RequantizeAttrs") {
42  TVM_ATTR_FIELD(axis)
43  .describe(
44  "The output channel axis for channel wise quantization. Default value is -1,"
45  "which corresponds to the last axis.")
46  .set_default(-1);
47  TVM_ATTR_FIELD(rounding).set_default("UPWARD").describe(
48  "Defines the rounding direction when the value is midway between"
49  "two representable values. There are two supported modes - UPWARD"
50  "or TONEAREST. Both modes behave exactly same except at the"
51  "midpoints between the two representable values. At the midpoint,"
52  "UPWARD rounds towards positive infinity (for example -1.5 will be"
53  "rounded to -1). TONEAREST is the standard rounding where the"
54  "value is rounded away from zero at midpoints (for example, -1.5"
55  "rounds to -2). More context can be found at following gblic manual"
56  "https://www.gnu.org/software/libc/manual/html_node/Rounding.html.");
57  TVM_ATTR_FIELD(out_dtype)
58  .set_default(NullValue<DataType>())
59  .describe("Output data type, set to explicit type under mixed precision setting");
60  }
61 };
62 
64 struct QuantizeAttrs : public tvm::AttrsNode<QuantizeAttrs> {
66  int axis;
67 
68  TVM_DECLARE_ATTRS(QuantizeAttrs, "relay.attrs.QuantizeAttrs") {
69  TVM_ATTR_FIELD(out_dtype).describe("Output data type, can be one of [int8 or uint8].");
70  TVM_ATTR_FIELD(axis)
71  .describe(
72  "The output channel axis for channel wise quantization. Default value is -1,"
73  "which corresponds to the last axis.")
74  .set_default(-1);
75  }
76 };
77 
78 struct SimulatedQuantizeAttrs : public tvm::AttrsNode<SimulatedQuantizeAttrs> {
79  int axis;
80 
81  TVM_DECLARE_ATTRS(SimulatedQuantizeAttrs, "relay.attrs.SimulatedQuantizeAttrs") {
82  TVM_ATTR_FIELD(axis)
83  .describe(
84  "The output channel axis for channel wise quantization. Default value is -1,"
85  "which corresponds to the last axis.")
86  .set_default(-1);
87  }
88 };
89 
91 struct DequantizeAttrs : public tvm::AttrsNode<DequantizeAttrs> {
92  int axis;
93 
94  TVM_DECLARE_ATTRS(DequantizeAttrs, "relay.attrs.DequantizeAttrs") {
95  TVM_ATTR_FIELD(axis)
96  .describe(
97  "The channel axis for channel wise dequantization. Default value is -1,"
98  "which corresponds to the last axis.")
99  .set_default(-1);
100  }
101 };
102 
103 } // namespace qnn
104 } // namespace relay
105 } // namespace tvm
106 #endif // TVM_RELAY_QNN_ATTRS_H_
Performance counters for profiling via the PAPI library.
Definition: analyzer.h:36
Attribute for quantize operator.
Definition: attrs.h:64
Helpers for attribute objects.
int axis
Definition: attrs.h:79
std::string rounding
Definition: attrs.h:38
Runtime primitive data type.
Definition: data_type.h:41
Attribute for requantize operator.
Definition: attrs.h:36
Attribute for dequantize operator.
Definition: attrs.h:91
int axis
Definition: attrs.h:37
#define TVM_ATTR_FIELD(FieldName)
Declare an attribute field.
Definition: attrs.h:76
int axis
Definition: attrs.h:92
DataType out_dtype
Definition: attrs.h:65
TVM_DECLARE_ATTRS(QuantizeAttrs, "relay.attrs.QuantizeAttrs")
Definition: attrs.h:68
DataType NullValue< DataType >()
Definition: attrs.h:90
TVM_DECLARE_ATTRS(RequantizeAttrs, "relay.attrs.RequantizeAttrs")
Definition: attrs.h:41
int axis
Definition: attrs.h:66
TVM_DECLARE_ATTRS(SimulatedQuantizeAttrs, "relay.attrs.SimulatedQuantizeAttrs")
Definition: attrs.h:81
The base class of the all the Use "curiously recurring template pattern".
Definition: attrs.h:793
TVM_DECLARE_ATTRS(DequantizeAttrs, "relay.attrs.DequantizeAttrs")
Definition: attrs.h:94
DataType out_dtype
Definition: attrs.h:39