25 #ifndef NNVM_TOP_NN_H_ 26 #define NNVM_TOP_NN_H_ 43 DMLC_DECLARE_FIELD(units).set_lower_bound(1)
44 .describe(
"Number of hidden units of the dense transformation.");
45 DMLC_DECLARE_FIELD(use_bias).set_default(
true)
46 .describe(
"Whether to use bias parameter");
49 static const constexpr
int kData = 0;
51 static const constexpr
int kBias = 2;
58 DMLC_DECLARE_FIELD(rate).set_default(0.5)
60 .describe(
"Fraction of the input that gets dropped out during training time.");
72 DMLC_DECLARE_FIELD(axis).set_default(1)
73 .describe(
"Specify which shape axis the channel is specified.");
74 DMLC_DECLARE_FIELD(epsilon).set_default(1e-5)
75 .describe(
"Small float added to variance to avoid dividing by zero.");
76 DMLC_DECLARE_FIELD(center).set_default(
true)
77 .describe(
"If True, add offset of `beta` to normalized tensor." 78 "If False, `beta` is ignored.");
79 DMLC_DECLARE_FIELD(scale).set_default(
true)
80 .describe(
"If True, multiply by `gamma`. If False, `gamma` is not used." 81 "When the next layer is piecewise linear (also e.g. `nn.relu`)," 82 "this can be disabled since the scaling" 83 "will be done by the next layer.");
86 static const constexpr
int kData = 0;
87 static const constexpr
int kGamma = 1;
88 static const constexpr
int kBeta = 2;
89 static const constexpr
int kMovingMean = 3;
90 static const constexpr
int kMovingVariance = 4;
99 DMLC_DECLARE_FIELD(axis).set_default(-1)
100 .describe(
"The axis to sum over when computing softmax.");
108 DMLC_DECLARE_FIELD(alpha).set_lower_bound(0.0).set_default(0.25)
109 .describe(
"slope coefficient for the negative half axis.");
116 DMLC_DECLARE_FIELD(axis).set_default(1)
117 .describe(
"Specify which shape axis the channel is specified.");
121 struct PadParam :
public dmlc::Parameter<PadParam> {
126 DMLC_DECLARE_FIELD(pad_value).set_default(0.0)
127 .describe(
"The value to be padded.");
128 DMLC_DECLARE_FIELD(pad_width)
129 .describe(
"Number of values padded to the edges of each axis, " 130 "in the format of ((before_1, after_1), ... (before_N, after_N))");
149 DMLC_DECLARE_FIELD(channels)
150 .describe(
"The dimensionality of the output space" 151 "i.e. the number of output channels in the convolution.");
152 DMLC_DECLARE_FIELD(kernel_size)
153 .describe(
"Specifies the dimensions of the convolution window.");
154 DMLC_DECLARE_FIELD(strides).set_default(
TShape({1, 1}))
155 .describe(
"Specifies the strides of the convolution.");
156 DMLC_DECLARE_FIELD(padding).set_default(
TShape({0, 0}))
157 .describe(
"If padding is non-zero, then the input is implicitly zero-padded" 158 "on both sides for padding number of points");
159 DMLC_DECLARE_FIELD(dilation).set_default(
TShape({1, 1}))
160 .describe(
"Specifies the dilation rate to use for dilated convolution.");
161 DMLC_DECLARE_FIELD(groups).set_default(1)
162 .describe(
"Controls the connections between inputs and outputs." 163 "At groups=1, all inputs are convolved to all outputs." 164 "At groups=2, the operation becomes equivalent to having two convolution" 165 "layers side by side, each seeing half the input channels, and producing" 166 "half the output channels, and both subsequently concatenated.");
167 DMLC_DECLARE_FIELD(layout).set_default(
"NCHW")
168 .describe(
"Dimension ordering of input data. Can be 'NCHW', 'NHWC', etc." 169 "'N', 'C', 'H', 'W' stands for batch, channel, height, and width" 170 "dimensions respectively. Convolution is applied on the 'H' and" 172 DMLC_DECLARE_FIELD(out_layout).set_default(
"__undef__")
173 .describe(
"Dimension ordering of output. Can be 'NCHW', 'NHWC', etc." 174 "'N', 'C', 'H', 'W' stands for batch, channel, height, and width" 175 "dimensions respectively. Default to be same as input layout.");
176 DMLC_DECLARE_FIELD(kernel_layout).set_default(
"OIHW")
177 .describe(
"Dimension ordering of weight. Can be 'OIHW', 'OIHW16o16i', etc." 178 "'O', 'I', 'H', 'W' stands for num_filter, input_channel, height, and width" 179 "dimensions respectively.");
181 .add_enum(
"same", -1)
183 .describe(
"Output data type, set to explicit type under mixed precision setting");
185 DMLC_DECLARE_FIELD(use_bias).set_default(
true)
186 .describe(
"Whether the layer uses a bias vector.");
189 static const constexpr
int kData = 0;
191 static const constexpr
int kBias = 2;
198 DMLC_DECLARE_FIELD(tile_size)
199 .describe(
"Tile size of winograd. E.g. 2 for F(2x2, 3x3) and 4 for F(4x4, 3x3)");
206 :
public dmlc::Parameter<WinogradNNPACKWeightTransformParam> {
211 DMLC_DECLARE_FIELD(convolution_algorithm)
213 "The convolution algorithm for Winograd NNPACK. " 214 "E.g. tvm.contrib.nnpack.ConvolutionAlgorithm.WT_8x8 for WT_8x8, " 215 "tvm.contrib.nnpack.ConvolutionAlgorithm.WT_8x8_FP16 for WT_8x8_FP16");
217 .add_enum(
"same", -1)
219 .describe(
"Output data type, set to explicit type under mixed precision setting");
240 DMLC_DECLARE_FIELD(channels)
241 .describe(
"The dimensionality of the output space" 242 "i.e. the number of output channels in the convolution.");
243 DMLC_DECLARE_FIELD(kernel_size)
244 .describe(
"Specifies the dimensions of the convolution window.");
245 DMLC_DECLARE_FIELD(strides).set_default(
TShape({1, 1}))
246 .describe(
"Specifies the strides of the convolution.");
247 DMLC_DECLARE_FIELD(padding).set_default(
TShape({0, 0}))
248 .describe(
"If padding is non-zero, then the input is implicitly zero-padded" 249 "on both sides for padding number of points");
250 DMLC_DECLARE_FIELD(dilation).set_default(
TShape({1, 1}))
251 .describe(
"Specifies the dilation rate to use for dilated convolution.");
252 DMLC_DECLARE_FIELD(groups).set_default(1)
253 .describe(
"Controls the connections between inputs and outputs." 254 "At groups=1, all inputs are convolved to all outputs." 255 "At groups=2, the operation becomes equivalent to having two convolution" 256 "layers side by side, each seeing half the input channels, and producing" 257 "half the output channels, and both subsequently concatenated.");
258 DMLC_DECLARE_FIELD(layout).set_default(
"NCHW")
259 .describe(
"Dimension ordering of input data. Can be 'NCHW', 'NHWC', etc." 260 "'N', 'C', 'H', 'W' stands for batch, channel, height, and width" 261 "dimensions respectively. Convolution is applied on the 'H' and" 263 DMLC_DECLARE_FIELD(out_layout).set_default(
"__undef__")
264 .describe(
"Dimension ordering of output. Can be 'NCHW', 'NHWC', etc." 265 "'N', 'C', 'H', 'W' stands for batch, channel, height, and width" 266 "dimensions respectively. Default to be same as input layout.");
267 DMLC_DECLARE_FIELD(kernel_layout).set_default(
"OIHW")
268 .describe(
"Dimension ordering of weight. Can be 'OIHW', 'OIHW16o16i', etc." 269 "'O', 'I', 'H', 'W' stands for num_filter, input_channel, height, and width" 270 "dimensions respectively.");
272 .add_enum(
"same", -1)
274 .describe(
"Output data type, set to explicit type under mixed precision setting");
275 DMLC_DECLARE_FIELD(use_bias).set_default(
true)
276 .describe(
"Whether the layer uses a bias vector.");
277 DMLC_DECLARE_FIELD(tile_size)
278 .describe(
"Tile size of winograd. E.g. 2 for F(2x2, 3x3) and 4 for F(4x4, 3x3)");
281 static const constexpr
int kData = 0;
283 static const constexpr
int kBias = 2;
300 DMLC_DECLARE_FIELD(channels)
301 .describe(
"The dimensionality of the output space" 302 "i.e. the number of output channels in the convolution.");
303 DMLC_DECLARE_FIELD(kernel_size)
304 .describe(
"Specifies the dimensions of the convolution window.");
305 DMLC_DECLARE_FIELD(strides).set_default(
TShape({1, 1}))
306 .describe(
"Specifies the strides of the convolution.");
307 DMLC_DECLARE_FIELD(output_padding).set_default(
TShape({0, 0}))
308 .describe(
"Zero-padding added to one side of the output.");
309 DMLC_DECLARE_FIELD(padding).set_default(
TShape({0, 0}))
310 .describe(
"If padding is non-zero, then the input is implicitly zero-padded" 311 "on both sides for padding number of points");
312 DMLC_DECLARE_FIELD(dilation).set_default(
TShape({1, 1}))
313 .describe(
"Specifies the dilation rate to use for dilated convolution.");
314 DMLC_DECLARE_FIELD(groups).set_default(1)
315 .describe(
"Controls the connections between inputs and outputs." 316 "At groups=1, all inputs are convolved to all outputs." 317 "At groups=2, the operation becomes equivalent to having two convolution" 318 "layers side by side, each seeing half the input channels, and producing" 319 "half the output channels, and both subsequently concatenated.");
320 DMLC_DECLARE_FIELD(layout).set_default(
"NCHW")
321 .describe(
"Dimension ordering of data. Can be 'NCHW', 'NHWC', etc." 322 "'N', 'C', 'H', 'W' stands for batch, channel, height, and width" 323 "dimensions respectively. Convolution is applied on the 'H' and" 325 DMLC_DECLARE_FIELD(kernel_layout).set_default(
"OIHW")
326 .describe(
"Dimension ordering of data and weight. Can be 'OIHW', 'OIHW16o16i', etc." 327 "'O', 'I', 'H', 'W' stands for num_filter, input_channel, height, and width" 328 "dimensions respectively.");
330 .add_enum(
"same", -1)
332 .describe(
"Output data type, set to explicit type under mixed precision setting");
333 DMLC_DECLARE_FIELD(use_bias).set_default(
true)
334 .describe(
"Whether the layer uses a bias vector.");
337 static const constexpr
int kData = 0;
339 static const constexpr
int kBias = 2;
351 DMLC_DECLARE_FIELD(pool_size)
352 .describe(
"Size of the pooling windows..");
353 DMLC_DECLARE_FIELD(strides).set_default(
TShape({1, 1}))
354 .describe(
"Specifies the strides of the convolution.");
355 DMLC_DECLARE_FIELD(padding).set_default(
TShape({0, 0}))
356 .describe(
"If padding is non-zero, then the input is implicitly zero-padded" 357 "Padding support both symmetric and asymmetric as" 358 "one int : same padding used on all sides" 359 "two int : bottom, right will use same padding as top, left" 360 "four int : padding width in the order of (top, left, bottom, right)");
361 DMLC_DECLARE_FIELD(layout).set_default(
"NCHW")
362 .describe(
"Dimension ordering of data and weight. Can be 'NCHW', 'NHWC', etc." 363 "'N', 'C', 'H', 'W' stands for batch, channel, height, and width" 364 "dimensions respectively. Convolution is applied on the 'H' and" 366 DMLC_DECLARE_FIELD(ceil_mode).set_default(
false)
367 .describe(
"When true, will use ceil instead of floor to compute the output shape.");
381 DMLC_DECLARE_FIELD(pool_size)
382 .describe(
"Size of the pooling windows..");
383 DMLC_DECLARE_FIELD(strides).set_default(
TShape({1, 1}))
384 .describe(
"Specifies the strides of the convolution.");
385 DMLC_DECLARE_FIELD(padding).set_default(
TShape({0, 0}))
386 .describe(
"If padding is non-zero, then the input is implicitly zero-padded" 387 "Padding support both symmetric and asymmetric as" 388 "one int : same padding used on all sides" 389 "two int : bottom, right will use same padding as top, left" 390 "four int : padding width in the order of (top, left, bottom, right)");
391 DMLC_DECLARE_FIELD(layout).set_default(
"NCHW")
392 .describe(
"Dimension ordering of data and weight. Can be 'NCHW', 'NHWC', etc." 393 "'N', 'C', 'H', 'W' stands for batch, channel, height, and width" 394 "dimensions respectively. Convolution is applied on the 'H' and" 396 DMLC_DECLARE_FIELD(ceil_mode).set_default(
false)
397 .describe(
"When true, will use ceil instead of floor to compute the output shape.");
398 DMLC_DECLARE_FIELD(count_include_pad).set_default(
false)
399 .describe(
"When true, will include padding to compute the average");
408 DMLC_DECLARE_FIELD(layout).set_default(
"NCHW")
409 .describe(
"Dimension ordering of data and weight. Can be 'NCHW', 'NHWC', etc." 410 "'N', 'C', 'H', 'W' stands for batch, channel, height, and width" 411 "dimensions respectively. Convolution is applied on the 'H' and" 422 DMLC_DECLARE_FIELD(scale)
423 .describe(
"upsampling scaling factor");
424 DMLC_DECLARE_FIELD(layout)
426 .describe(
"Dimension ordering of data. Can be 'NCHW', 'NHWC', etc." 427 "'N', 'C', 'H', 'W' stands for batch, channel, height, and width" 428 "dimensions respectively. Upsampling is applied on the 'H' and" 430 DMLC_DECLARE_FIELD(method)
431 .set_default(
"NEAREST_NEIGHBOR")
432 .describe(
"Specify the mode to use for scaling." 433 "NEAREST_NEIGHBOR - Nearest Neighbor" 434 "BILINEAR - Bilinear Interpolation");
443 DMLC_DECLARE_FIELD(src_layout).set_default(
"__undef__")
444 .describe(
"Dimension ordering of data");
445 DMLC_DECLARE_FIELD(dst_layout).set_default(
"__undef__")
446 .describe(
"Dimension ordering of data.");
458 DMLC_DECLARE_FIELD(sizes).set_default(
Tuple<float>({1.0}))
459 .describe(
"List of sizes of generated MultiBoxPriores.");
460 DMLC_DECLARE_FIELD(ratios).set_default(
Tuple<float>({1.0}))
461 .describe(
"List of aspect ratios of generated MultiBoxPriores.");
462 DMLC_DECLARE_FIELD(steps).set_default(
Tuple<float>({-1.0, -1.0}))
463 .describe(
"Priorbox step across y and x, -1 for auto calculation.");
464 DMLC_DECLARE_FIELD(offsets).set_default(
Tuple<float>({0.5, 0.5}))
465 .describe(
"Priorbox center offsets, y and x respectively.");
466 DMLC_DECLARE_FIELD(clip).set_default(
false)
467 .describe(
"Whether to clip out-of-boundary boxes.");
476 DMLC_DECLARE_FIELD(clip).set_default(
true)
477 .describe(
"Clip out-of-boundary boxes.");
478 DMLC_DECLARE_FIELD(threshold).set_default(0.01)
479 .describe(
"Threshold to be a positive prediction.");
480 DMLC_DECLARE_FIELD(variances).set_default(
Tuple<float>({0.1f, 0.1f, 0.2f, 0.2f}))
481 .describe(
"Variances to be decoded from box regression output.");
496 DMLC_DECLARE_FIELD(max_output_size).set_default(-1)
497 .describe(
"Max number of output valid boxes for each instance." 498 "By default all valid boxes are returned.");
499 DMLC_DECLARE_FIELD(iou_threshold).set_default(0.5)
500 .describe(
"Non-maximum suppression threshold.");
501 DMLC_DECLARE_FIELD(force_suppress).set_default(
false)
502 .describe(
"Suppress all detections regardless of class_id.");
503 DMLC_DECLARE_FIELD(top_k).set_default(-1)
504 .describe(
"Keep maximum top k detections before nms, -1 for no limit.");
505 DMLC_DECLARE_FIELD(coord_start).set_default(2)
506 .describe(
"Start index of the consecutive 4 coordinates.");
507 DMLC_DECLARE_FIELD(score_index).set_default(1)
508 .describe(
"Index of the scores/confidence of boxes.");
509 DMLC_DECLARE_FIELD(id_index).set_default(0)
510 .describe(
"Axis index of id.");
511 DMLC_DECLARE_FIELD(return_indices).set_default(
true)
512 .describe(
"Whether to return box indices in input data.");
513 DMLC_DECLARE_FIELD(invalid_to_bottom).set_default(
false)
514 .describe(
"Whether to move all invalid bounding boxes to the bottom.");
518 struct LRNParam :
public dmlc::Parameter<LRNParam> {
526 DMLC_DECLARE_FIELD(size)
527 .describe(
"The size of the local region to be considered for normalization.");
528 DMLC_DECLARE_FIELD(axis)
529 .describe(
"input data layout channel axis");
530 DMLC_DECLARE_FIELD(alpha)
531 .describe(
"The scaling parameter.");
532 DMLC_DECLARE_FIELD(beta)
533 .describe(
"The exponent parameter.");
534 DMLC_DECLARE_FIELD(bias)
535 .describe(
"The offset parameter.");
538 static const constexpr
int kData = 0;
546 DMLC_DECLARE_FIELD(eps)
547 .describe(
"float type epsilon value.");
548 DMLC_DECLARE_FIELD(axis)
549 .describe(
"axis over the normalization applied");
556 #endif // NNVM_TOP_NN_H_ TShape strides
Definition: nn.h:228
TShape kernel_size
Definition: nn.h:227
bool use_bias
Definition: nn.h:236
bool scale
Definition: nn.h:69
int out_dtype
Definition: nn.h:235
Tuple< int > axis
Definition: nn.h:543
TShape pool_size
Definition: nn.h:344
A dynamic sized array data structure that is optimized for storing small number of elements with same...
Definition: tuple.h:52
int max_output_size
Definition: nn.h:493
Tuple< float > steps
Definition: nn.h:453
TShape strides
Definition: nn.h:289
DMLC_DECLARE_PARAMETER(GlobalPool2DParam)
Definition: nn.h:407
int top_k
Definition: nn.h:489
bool clip
Definition: nn.h:455
static const constexpr int kWeight
Definition: nn.h:50
DMLC_DECLARE_PARAMETER(L2NormalizeParam)
Definition: nn.h:545
int coord_start
Definition: nn.h:491
DMLC_DECLARE_PARAMETER(LRNParam)
Definition: nn.h:525
TShape kernel_size
Definition: nn.h:288
int id_index
Definition: nn.h:490
A Shape class that is used to represent shape of each tensor.
Definition: tuple.h:344
DMLC_DECLARE_PARAMETER(LeakyReLUParam)
Definition: nn.h:107
int axis
Definition: nn.h:65
bool invalid_to_bottom
Definition: nn.h:494
float eps
Definition: nn.h:542
int tile_size
Definition: nn.h:237
float iou_threshold
Definition: nn.h:487
bool use_bias
Definition: nn.h:297
bool force_suppress
Definition: nn.h:488
std::string layout
Definition: nn.h:142
bool use_bias
Definition: nn.h:146
int axis
Definition: nn.h:96
bool return_indices
Definition: nn.h:486
int size
Definition: nn.h:519
TShape strides
Definition: nn.h:345
DMLC_DECLARE_PARAMETER(Conv2DTransposeParam)
Definition: nn.h:299
DMLC_DECLARE_PARAMETER(BatchNormParam)
Definition: nn.h:71
DMLC_DECLARE_PARAMETER(AvgPool2DParam)
Definition: nn.h:380
int units
Definition: nn.h:39
bool ceil_mode
Definition: nn.h:348
Tuple< float > sizes
Definition: nn.h:451
int channels
Definition: nn.h:287
DMLC_DECLARE_PARAMETER(UpSamplingParam)
Definition: nn.h:421
static const constexpr int kBias
Definition: nn.h:51
DMLC_DECLARE_PARAMETER(Conv2DParam)
Definition: nn.h:148
std::string layout
Definition: nn.h:376
TShape pool_size
Definition: nn.h:373
int out_dtype
Definition: nn.h:145
DMLC_DECLARE_PARAMETER(NonMaximumSuppressionParam)
Definition: nn.h:495
double momentum
Definition: nn.h:67
TShape padding
Definition: nn.h:290
#define DMLC_DECLARE_DTYPE_FIELD(name)
Definition: tensor.h:117
bool ceil_mode
Definition: nn.h:377
TShape padding
Definition: nn.h:375
std::string out_layout
Definition: nn.h:144
float bias
Definition: nn.h:523
std::string out_layout
Definition: nn.h:234
int channels
Definition: nn.h:226
std::string kernel_layout
Definition: nn.h:295
int out_dtype
Definition: nn.h:296
Data structure Tuple and TShape to store dynamic sized shapes.
TShape padding
Definition: nn.h:346
Tuple< float > offsets
Definition: nn.h:454
Auxiliary param for tensor primitive.
bool center
Definition: nn.h:68
DMLC_DECLARE_PARAMETER(WinogradConv2DParam)
Definition: nn.h:239
TShape dilation
Definition: nn.h:140
bool count_include_pad
Definition: nn.h:378
std::string layout
Definition: nn.h:418
TShape dilation
Definition: nn.h:230
DMLC_DECLARE_PARAMETER(PReLUParam)
Definition: nn.h:115
int axis
Definition: nn.h:520
int channels
Definition: nn.h:136
double alpha
Definition: nn.h:105
TShape kernel_size
Definition: nn.h:137
int axis
Definition: nn.h:114
int groups
Definition: nn.h:141
Tuple< float > ratios
Definition: nn.h:452
int groups
Definition: nn.h:231
TShape dilation
Definition: nn.h:292
DMLC_DECLARE_PARAMETER(MaxPool2DParam)
Definition: nn.h:350
int groups
Definition: nn.h:293
int scale
Definition: nn.h:417
float pad_value
Definition: nn.h:122
std::string layout
Definition: nn.h:294
float rate
Definition: nn.h:55
TShape strides
Definition: nn.h:138
TShape padding
Definition: nn.h:229
bool use_bias
Definition: nn.h:40
static const constexpr int kData
Definition: nn.h:49
double epsilon
Definition: nn.h:66
TShape output_padding
Definition: nn.h:291
int score_index
Definition: nn.h:492
Layout expression. The layout is composed of upper cases, lower cases and numbers, where upper case indicates a (super-)dimension and the corresponding lower case with factor size indicates the split (sub-)dimension. For example, NCHW16c can describe a 5-D tensor of [batch_size, channel, height, width, channel_block]. Here sub-dimension channel_block=16 is the split of super-dimension C (channel).
DMLC_DECLARE_PARAMETER(PadParam)
Definition: nn.h:125
std::string layout
Definition: nn.h:347
std::string layout
Definition: nn.h:405
float alpha
Definition: nn.h:521
DMLC_DECLARE_PARAMETER(DenseParam)
Definition: nn.h:42
DMLC_DECLARE_PARAMETER(DropoutParam)
Definition: nn.h:57
DMLC_DECLARE_PARAMETER(MultiBoxPriorParam)
Definition: nn.h:457
std::string kernel_layout
Definition: nn.h:143
std::string kernel_layout
Definition: nn.h:233
DMLC_DECLARE_PARAMETER(SoftmaxParam)
Definition: nn.h:98
Tuple< Tuple< int > > pad_width
Definition: nn.h:123
Provide lightweight util to do parameter setup and checking.
std::string method
Definition: nn.h:419
TShape padding
Definition: nn.h:139
std::string layout
Definition: nn.h:232
TShape strides
Definition: nn.h:374
float beta
Definition: nn.h:522