|
25 | 25 | #define TVM_RELAY_QNN_ATTRS_H_ |
26 | 26 |
|
27 | 27 | #include <tvm/ir/attrs.h> |
28 | | -#include <tvm/relay/base.h> |
29 | 28 |
|
30 | 29 | #include <string> |
31 | 30 |
|
@@ -126,104 +125,6 @@ struct BroadcastAttrs : public tvm::AttrsNode<BroadcastAttrs> { |
126 | 125 | } |
127 | 126 | }; |
128 | 127 |
|
129 | | -/*! \brief Attributes used in QNN convolution operator */ |
130 | | -struct QConv2DAttrs : public tvm::AttrsNode<QConv2DAttrs> { |
131 | | - Array<IndexExpr> strides; |
132 | | - Array<IndexExpr> padding; |
133 | | - Array<IndexExpr> dilation; |
134 | | - int groups; |
135 | | - IndexExpr channels; |
136 | | - Array<IndexExpr> kernel_size; |
137 | | - tvm::String data_layout; |
138 | | - tvm::String kernel_layout; |
139 | | - tvm::String out_layout; |
140 | | - tvm::String auto_scheduler_rewritten_layout; // The layout after auto-scheduler's layout rewrite |
141 | | - Array<PrimExpr> meta_schedule_original_shape; // The original shape of the weights |
142 | | - DataType out_dtype; |
143 | | - |
144 | | - // Optional extra attributes for Hexagon target. Describes requantization parameters. |
145 | | - // Note, It is not set up explicitly through qnn._make.conv2d. |
146 | | - int axis; |
147 | | - DataType rq_out_dtype; |
148 | | - |
149 | | - TVM_DECLARE_ATTRS(QConv2DAttrs, "relay.attrs.QConv2DAttrs") { |
150 | | - TVM_ATTR_FIELD(strides) |
151 | | - .set_default(Array<IndexExpr>({1, 1})) |
152 | | - .describe("Specifies the strides of the convolution."); |
153 | | - TVM_ATTR_FIELD(padding) |
154 | | - .set_default(Array<IndexExpr>({0, 0})) |
155 | | - .describe( |
156 | | - "If padding is non-zero, then the input is implicitly zero-padded" |
157 | | - "Padding support both symmetric and asymmetric as" |
158 | | - "one int : same padding used on all sides" |
159 | | - "two int : bottom, right will use same padding as top, left" |
160 | | - "four int : padding width in the order of (top, left, bottom, right)"); |
161 | | - TVM_ATTR_FIELD(dilation) |
162 | | - .set_default(Array<IndexExpr>({1, 1})) |
163 | | - .describe("Specifies the dilation rate to use for dilated convolution."); |
164 | | - TVM_ATTR_FIELD(groups).set_default(1).describe( |
165 | | - "Controls the connections between inputs and outputs." |
166 | | - "At groups=1, all inputs are convolved to all outputs." |
167 | | - "At groups=2, the operation becomes equivalent to having two convolution" |
168 | | - "layers side by side, each seeing half the input channels, and producing" |
169 | | - "half the output channels, and both subsequently concatenated."); |
170 | | - TVM_ATTR_FIELD(channels) |
171 | | - .describe( |
172 | | - "The number of output channels in the convolution." |
173 | | - " If it is not set, inferred by shape of the weight.") |
174 | | - .set_default(NullValue<IndexExpr>()); |
175 | | - TVM_ATTR_FIELD(kernel_size) |
176 | | - .describe("Specifies the dimensions of the convolution window.") |
177 | | - .set_default(NullValue<Array<IndexExpr>>()); |
178 | | - TVM_ATTR_FIELD(data_layout) |
179 | | - .set_default("NCHW") |
180 | | - .describe( |
181 | | - "Dimension ordering of input data. Can be 'NCHW', 'NHWC', etc." |
182 | | - "'N', 'C', 'H', 'W' stands for batch, channel, height, and width" |
183 | | - "dimensions respectively. Convolution is applied on the 'H' and" |
184 | | - "'W' dimensions."); |
185 | | - TVM_ATTR_FIELD(kernel_layout) |
186 | | - .set_default("OIHW") |
187 | | - .describe( |
188 | | - "Dimension ordering of weight. Can be 'OIHW', 'OIHW16o16i', etc." |
189 | | - "'O', 'I', 'H', 'W' stands for num_filter, input_channel, height, and width" |
190 | | - "dimensions respectively."); |
191 | | - TVM_ATTR_FIELD(out_layout) |
192 | | - .set_default("") |
193 | | - .describe( |
194 | | - "Dimension ordering of output. Can be 'NCHW', 'NHWC', etc." |
195 | | - "'N', 'C', 'H', 'W' stands for batch, channel, height, and width" |
196 | | - "dimensions respectively. Default to be same as input layout."); |
197 | | - |
198 | | - // use 0 bits to indicate none. |
199 | | - TVM_ATTR_FIELD(out_dtype) |
200 | | - .set_default(NullValue<DataType>()) |
201 | | - .describe("Output data type, set to explicit type under mixed precision setting"); |
202 | | - } |
203 | | -}; |
204 | | - |
205 | | -/*! \brief Attributes for QNN dense operator */ |
206 | | -struct QDenseAttrs : public tvm::AttrsNode<QDenseAttrs> { |
207 | | - IndexExpr units; |
208 | | - tvm::String auto_scheduler_rewritten_layout; // The layout after auto-scheduler's layout rewrite |
209 | | - Array<PrimExpr> meta_schedule_original_shape; // The original shape of the weights |
210 | | - DataType out_dtype; |
211 | | - |
212 | | - // Optional extra attributes for Hexagon target. Describes requantization parameters. |
213 | | - // Note, It is not set up explicitly through qnn._make.dense. |
214 | | - int axis; |
215 | | - DataType rq_out_dtype; |
216 | | - |
217 | | - TVM_DECLARE_ATTRS(QDenseAttrs, "relay.attrs.QDenseAttrs") { |
218 | | - TVM_ATTR_FIELD(units).describe("Number of hidden units of the dense transformation."); |
219 | | - |
220 | | - // use 0 bits to indicate none. |
221 | | - TVM_ATTR_FIELD(out_dtype) |
222 | | - .set_default(NullValue<DataType>()) |
223 | | - .describe("Output data type, set to explicit type under mixed precision setting"); |
224 | | - } |
225 | | -}; |
226 | | - |
227 | 128 | } // namespace qnn |
228 | 129 | } // namespace relay |
229 | 130 | } // namespace tvm |
|
0 commit comments