Elffuss BraidHub

kikocis/ncnn public

e91df65e9177 · 69.5 KiBRenderedRawPermalink
1
2* [AbsVal](#absval)
3* [ArgMax](#argmax)
4* [BatchNorm](#batchnorm)
5* [Bias](#bias)
6* [BinaryOp](#binaryop)
7* [BNLL](#bnll)
8* [Cast](#cast)
9* [CELU](#celu)
10* [Clip](#clip)
11* [Concat](#concat)
12* [Convolution](#convolution)
13* [Convolution1D](#convolution1d)
14* [Convolution3D](#convolution3d)
15* [ConvolutionDepthWise](#convolutiondepthwise)
16* [ConvolutionDepthWise1D](#convolutiondepthwise1d)
17* [ConvolutionDepthWise3D](#convolutiondepthwise3d)
18* [CopyTo](#copyto)
19* [Crop](#crop)
20* [CumulativeSum](#cumulativesum)
21* [Deconvolution](#deconvolution)
22* [Deconvolution1D](#deconvolution1d)
23* [Deconvolution3D](#deconvolution3d)
24* [DeconvolutionDepthWise](#deconvolutiondepthwise)
25* [DeconvolutionDepthWise1D](#deconvolutiondepthwise1d)
26* [DeconvolutionDepthWise3D](#deconvolutiondepthwise3d)
27* [DeformableConv2D](#deformableconv2d)
28* [Dequantize](#dequantize)
29* [Diag](#diag)
30* [Dropout](#dropout)
31* [Eltwise](#eltwise)
32* [ELU](#elu)
33* [Embed](#embed)
34* [Exp](#exp)
35* [Flatten](#flatten)
36* [Fold](#fold)
37* [GELU](#gelu)
38* [GLU](#glu)
39* [Gemm](#gemm)
40* [GridSample](#gridsample)
41* [GroupNorm](#groupnorm)
42* [GRU](#gru)
43* [HardSigmoid](#hardsigmoid)
44* [HardSwish](#hardswish)
45* [InnerProduct](#innerproduct)
46* [Input](#input)
47* [InstanceNorm](#instancenorm)
48* [Interp](#interp)
49* [LayerNorm](#layernorm)
50* [Log](#log)
51* [LRN](#lrn)
52* [LSTM](#lstm)
53* [MemoryData](#memorydata)
54* [Mish](#mish)
55* [MultiHeadAttention](#multiheadattention)
56* [MVN](#mvn)
57* [Noop](#noop)
58* [Normalize](#normalize)
59* [Packing](#packing)
60* [Padding](#padding)
61* [Permute](#permute)
62* [PixelShuffle](#pixelshuffle)
63* [Pooling](#pooling)
64* [Pooling1D](#pooling1d)
65* [Pooling3D](#pooling3d)
66* [Power](#power)
67* [PReLU](#prelu)
68* [Quantize](#quantize)
69* [Reduction](#reduction)
70* [ReLU](#relu)
71* [Reorg](#reorg)
72* [Requantize](#requantize)
73* [Reshape](#reshape)
74* [RNN](#rnn)
75* [Scale](#scale)
76* [SELU](#selu)
77* [Shrink](#shrink)
78* [ShuffleChannel](#shufflechannel)
79* [Sigmoid](#sigmoid)
80* [Slice](#slice)
81* [Softmax](#softmax)
82* [Softplus](#softplus)
83* [Split](#split)
84* [Swish](#swish)
85* [TanH](#tanh)
86* [Threshold](#threshold)
87* [Tile](#tile)
88* [UnaryOp](#unaryop)
89* [Unfold](#unfold)
90
91# AbsVal
92```
93y = abs(x)
94```
95
96* one_blob_only
97* support_inplace
98
99# ArgMax
100```
101y = argmax(x, out_max_val, topk)
102```
103
104* one_blob_only
105
106| param id | name | type | default | description |
107| --------- | ------------- | ----- | --------- | ----------------- |
108| 0 | out_max_val | int | 0 | |
109| 1 | topk | int | 1 | |
110
111# BatchNorm
112```
113y = (x - mean) / sqrt(var + eps) * slope + bias
114```
115
116* one_blob_only
117* support_inplace
118
119| param id | name | type | default | description |
120| --------- | ------------- | ----- | --------- | ----------------- |
121| 0 | channels | int | 0 | |
122| 1 | eps | float | 0.f | |
123
124| weight | type | shape |
125| ------------- | ----- | --------------------- |
126| slope_data | float | [channels] |
127| mean_data | float | [channels] |
128| var_data | float | [channels] |
129| bias_data | float | [channels] |
130
131# Bias
132```
133y = x + bias
134```
135
136* one_blob_only
137* support_inplace
138
139| param id | name | type | default | description |
140| --------- | ------------- | ----- | --------- | ----------------- |
141| 0 | bias_data_size| int | 0 | |
142
143| weight | type | shape |
144| ------------- | ----- | --------------------- |
145| bias_data | float | [channels] |
146
147# BinaryOp
148 This operation is used for binary computation, and the calculation rule depends on the [broadcasting rule](https://github.com/Tencent/ncnn/wiki/binaryop-broadcasting).
149```
150C = binaryop(A, B)
151```
152if with_scalar = 1:
153- one_blob_only
154- support_inplace
155
156| param id | name | type | default | description |
157| --------- | ------------- | ----- | --------- | ----------------- |
158| 0 | op_type | int | 0 | Operation type as follows |
159| 1 | with_scalar | int | 0 | with_scalar=0 B is a matrix, with_scalar=1 B is a scalar |
160| 2 | b | float | 0.f | When B is a scalar, B = b |
161
162Operation type:
163- 0 = ADD
164- 1 = SUB
165- 2 = MUL
166- 3 = DIV
167- 4 = MAX
168- 5 = MIN
169- 6 = POW
170- 7 = RSUB
171- 8 = RDIV
172- 9 = RPOW
173- 10 = ATAN2
174- 11 = RATAN2
175
176# BNLL
177```
178y = log(1 + e^(-x)) , x > 0
179y = log(1 + e^x), x < 0
180```
181
182* one_blob_only
183* support_inplace
184
185# Cast
186```
187y = cast(x)
188```
189
190* one_blob_only
191* support_packing
192
193| param id | name | type | default | description |
194| --------- | ------------- | ----- | --------- | ----------------- |
195| 0 | type_from | int | 0 | |
196| 1 | type_to | int | 0 | |
197
198Element type:
199- 0 = auto
200- 1 = float32
201- 2 = float16
202- 3 = int8
203- 4 = bfloat16
204
205# CELU
206```
207if x < 0 y = (exp(x / alpha) - 1.f) * alpha
208else y = x
209```
210
211* one_blob_only
212* support_inplace
213
214| param id | name | type | default | description |
215| --------- | ------------- | ----- | --------- | ----------------- |
216| 0 | alpha | float | 1.f | |
217
218# Clip
219```
220y = clamp(x, min, max)
221```
222
223* one_blob_only
224* support_inplace
225
226| param id | name | type | default | description |
227| --------- | ------------- | ----- | --------- | ----------------- |
228| 0 | min | float | -FLT_MAX | |
229| 1 | max | float | FLT_MAX | |
230
231# Concat
232```
233y = concat(x0, x1, x2, ...) by axis
234```
235
236| param id | name | type | default | description |
237| --------- | ------------- | ----- | --------- | ----------------- |
238| 0 | axis | int | 0 | |
239
240# Convolution
241```
242x2 = pad(x, pads, pad_value)
243x3 = conv(x2, weight, kernel, stride, dilation) + bias
244y = activation(x3, act_type, act_params)
245```
246
247* one_blob_only
248
249| param id | name | type | default | description |
250| --------- | ------------- | ----- | --------- | ----------------- |
251| 0 | num_output | int | 0 | |
252| 1 | kernel_w | int | 0 | |
253| 2 | dilation_w | int | 1 | |
254| 3 | stride_w | int | 1 | |
255| 4 | pad_left | int | 0 | |
256| 5 | bias_term | int | 0 | |
257| 6 | weight_data_size| int | 0 | |
258| 8 | int8_scale_term| int | 0 | |
259| 9 | activation_type| int | 0 | |
260| 10 | activation_params| array | [ ] | |
261| 11 | kernel_h | int | kernel_w | |
262| 12 | dilation_h | int | dilation_w | |
263| 13 | stride_h | int | stride_w | |
264| 14 | pad_top | int | pad_left | |
265| 15 | pad_right | int | pad_left | |
266| 16 | pad_bottom | int | pad_top | |
267| 18 | pad_value | float | 0.f | |
268| 19 | dynamic_weight| int | 0 | |
269
270| weight | type | shape |
271| ------------- | ----- | --------------------- |
272| weight_data | float/fp16/int8 | [kernel_w, kernel_h, num_input, num_output] |
273| bias_data | float | [num_output] |
274| weight_data_int8_scales| float | [num_output] |
275| bottom_blob_int8_scales| float | [1] |
276| top_blob_int8_scales| float | [1] |
277
278# Convolution1D
279```
280x2 = pad(x, pads, pad_value)
281x3 = conv1d(x2, weight, kernel, stride, dilation) + bias
282y = activation(x3, act_type, act_params)
283```
284
285* one_blob_only
286
287| param id | name | type | default | description |
288| --------- | ------------- | ----- | --------- | ----------------- |
289| 0 | num_output | int | 0 | |
290| 1 | kernel_w | int | 0 | |
291| 2 | dilation_w | int | 1 | |
292| 3 | stride_w | int | 1 | |
293| 4 | pad_left | int | 0 | |
294| 5 | bias_term | int | 0 | |
295| 6 | weight_data_size| int | 0 | |
296| 9 | activation_type| int | 0 | |
297| 10 | activation_params| array | [ ] | |
298| 15 | pad_right | int | pad_left | |
299| 18 | pad_value | float | 0.f | |
300| 19 | dynamic_weight| int | 0 | |
301
302| weight | type | shape |
303| ------------- | ----- | --------------------- |
304| weight_data | float/fp16/int8 | [kernel_w, num_input, num_output] |
305| bias_data | float | [num_output] |
306
307# Convolution3D
308```
309x2 = pad(x, pads, pad_value)
310x3 = conv3d(x2, weight, kernel, stride, dilation) + bias
311y = activation(x3, act_type, act_params)
312```
313
314* one_blob_only
315
316| param id | name | type | default | description |
317| --------- | ------------- | ----- | --------- | ----------------- |
318| 0 | num_output | int | 0 | |
319| 1 | kernel_w | int | 0 | |
320| 2 | dilation_w | int | 1 | |
321| 3 | stride_w | int | 1 | |
322| 4 | pad_left | int | 0 | |
323| 5 | bias_term | int | 0 | |
324| 6 | weight_data_size| int | 0 | |
325| 9 | activation_type| int | 0 | |
326| 10 | activation_params| array | [ ] | |
327| 11 | kernel_h | int | kernel_w | |
328| 12 | dilation_h | int | dilation_w | |
329| 13 | stride_h | int | stride_w | |
330| 14 | pad_top | int | pad_left | |
331| 15 | pad_right | int | pad_left | |
332| 16 | pad_bottom | int | pad_top | |
333| 17 | pad_behind | int | pad_front | |
334| 18 | pad_value | float | 0.f | |
335| 21 | kernel_d | int | kernel_w | |
336| 22 | dilation_d | int | dilation_w | |
337| 23 | stride_d | int | stride_w | |
338| 24 | pad_front | int | pad_left | |
339
340| weight | type | shape |
341| ------------- | ----- | --------------------- |
342| weight_data | float/fp16/int8 | [kernel_w, kernel_h, kernel_d, num_input, num_output] |
343| bias_data | float | [num_output] |
344
345# ConvolutionDepthWise
346```
347x2 = pad(x, pads, pad_value)
348x3 = conv(x2, weight, kernel, stride, dilation, group) + bias
349y = activation(x3, act_type, act_params)
350```
351
352* one_blob_only
353
354| param id | name | type | default | description |
355| --------- | ------------- | ----- | --------- | ----------------- |
356| 0 | num_output | int | 0 | |
357| 1 | kernel_w | int | 0 | |
358| 2 | dilation_w | int | 1 | |
359| 3 | stride_w | int | 1 | |
360| 4 | pad_left | int | 0 | |
361| 5 | bias_term | int | 0 | |
362| 6 | weight_data_size| int | 0 | |
363| 7 | group | int | 1 | |
364| 8 | int8_scale_term| int | 0 | |
365| 9 | activation_type| int | 0 | |
366| 10 | activation_params| array | [ ] | |
367| 11 | kernel_h | int | kernel_w | |
368| 12 | dilation_h | int | dilation_w | |
369| 13 | stride_h | int | stride_w | |
370| 14 | pad_top | int | pad_left | |
371| 15 | pad_right | int | pad_left | |
372| 16 | pad_bottom | int | pad_top | |
373| 18 | pad_value | float | 0.f | |
374| 19 | dynamic_weight| int | 0 | |
375
376| weight | type | shape |
377| ------------- | ----- | --------------------- |
378| weight_data | float/fp16/int8 | [kernel_w, kernel_h, num_input / group, num_output / group, group] |
379| bias_data | float | [num_output] |
380| weight_data_int8_scales| float | [group] |
381| bottom_blob_int8_scales| float | [1] |
382| top_blob_int8_scales| float | [1] |
383
384# ConvolutionDepthWise1D
385```
386x2 = pad(x, pads, pad_value)
387x3 = conv1d(x2, weight, kernel, stride, dilation, group) + bias
388y = activation(x3, act_type, act_params)
389```
390
391* one_blob_only
392
393| param id | name | type | default | description |
394| --------- | ------------- | ----- | --------- | ----------------- |
395| 0 | num_output | int | 0 | |
396| 1 | kernel_w | int | 0 | |
397| 2 | dilation_w | int | 1 | |
398| 3 | stride_w | int | 1 | |
399| 4 | pad_left | int | 0 | |
400| 5 | bias_term | int | 0 | |
401| 6 | weight_data_size| int | 0 | |
402| 7 | group | int | 1 | |
403| 9 | activation_type| int | 0 | |
404| 10 | activation_params| array | [ ] | |
405| 15 | pad_right | int | pad_left | |
406| 18 | pad_value | float | 0.f | |
407| 19 | dynamic_weight| int | 0 | |
408
409| weight | type | shape |
410| ------------- | ----- | --------------------- |
411| weight_data | float/fp16/int8 | [kernel_w, num_input / group, num_output / group, group] |
412| bias_data | float | [num_output] |
413
414# ConvolutionDepthWise3D
415```
416x2 = pad(x, pads, pad_value)
417x3 = conv3d(x2, weight, kernel, stride, dilation, group) + bias
418y = activation(x3, act_type, act_params)
419```
420
421* one_blob_only
422
423| param id | name | type | default | description |
424| --------- | ------------- | ----- | --------- | ----------------- |
425| 0 | num_output | int | 0 | |
426| 1 | kernel_w | int | 0 | |
427| 2 | dilation_w | int | 1 | |
428| 3 | stride_w | int | 1 | |
429| 4 | pad_left | int | 0 | |
430| 5 | bias_term | int | 0 | |
431| 6 | weight_data_size| int | 0 | |
432| 7 | group | int | 1 | |
433| 9 | activation_type| int | 0 | |
434| 10 | activation_params| array | [ ] | |
435| 11 | kernel_h | int | kernel_w | |
436| 12 | dilation_h | int | dilation_w | |
437| 13 | stride_h | int | stride_w | |
438| 14 | pad_top | int | pad_left | |
439| 15 | pad_right | int | pad_left | |
440| 16 | pad_bottom | int | pad_top | |
441| 17 | pad_behind | int | pad_front | |
442| 18 | pad_value | float | 0.f | |
443| 21 | kernel_d | int | kernel_w | |
444| 22 | dilation_d | int | dilation_w | |
445| 23 | stride_d | int | stride_w | |
446| 24 | pad_front | int | pad_left | |
447
448| weight | type | shape |
449| ------------- | ----- | --------------------- |
450| weight_data | float/fp16/int8 | [kernel_w, kernel_h, kernel_d, num_input / group, num_output / group, group] |
451| bias_data | float | [num_output] |
452
453# CopyTo
454```
455self[offset] = src
456```
457
458* one_blob_only
459
460| param id | name | type | default | description |
461| --------- | ------------- | ----- | --------- | ----------------- |
462| 0 | woffset | int | 0 | |
463| 1 | hoffset | int | 0 | |
464| 13 | doffset | int | 0 | |
465| 2 | coffset | int | 0 | |
466| 9 | starts | array | [ ] | |
467| 11 | axes | array | [ ] | |
468
469# Crop
470```
471y = crop(x)
472```
473
474* one_blob_only
475
476| param id | name | type | default | description |
477| --------- | ------------- | ----- | --------- | ----------------- |
478| 0 | woffset | int | 0 | |
479| 1 | hoffset | int | 0 | |
480| 13 | doffset | int | 0 | |
481| 2 | coffset | int | 0 | |
482| 3 | outw | int | 0 | |
483| 4 | outh | int | 0 | |
484| 14 | outd | int | 0 | |
485| 5 | outc | int | 0 | |
486| 6 | woffset2 | int | 0 | |
487| 7 | hoffset2 | int | 0 | |
488| 15 | doffset2 | int | 0 | |
489| 8 | coffset2 | int | 0 | |
490| 9 | starts | array | [ ] | |
491| 10 | ends | array | [ ] | |
492| 11 | axes | array | [ ] | |
493
494# CumulativeSum
495
496If axis < 0, we use axis = x.dims + axis
497
498It implements https://pytorch.org/docs/stable/generated/torch.cumsum.html
499
500* one_blob_only
501* support_inplace
502
503| param id | name | type | default | description |
504| --------- | ------------- | ----- | --------- | ----------------- |
505| 0 | axis | int | 0 | |
506
507
508# Deconvolution
509```
510x2 = deconv(x, weight, kernel, stride, dilation) + bias
511x3 = depad(x2, pads, pad_value)
512y = activation(x3, act_type, act_params)
513```
514
515* one_blob_only
516
517| param id | name | type | default | description |
518| --------- | ------------- | ----- | --------- | ----------------- |
519| 0 | num_output | int | 0 | |
520| 1 | kernel_w | int | 0 | |
521| 2 | dilation_w | int | 1 | |
522| 3 | stride_w | int | 1 | |
523| 4 | pad_left | int | 0 | |
524| 5 | bias_term | int | 0 | |
525| 6 | weight_data_size| int | 0 | |
526| 9 | activation_type| int | 0 | |
527| 10 | activation_params| array | [ ] | |
528| 11 | kernel_h | int | kernel_w | |
529| 12 | dilation_h | int | dilation_w | |
530| 13 | stride_h | int | stride_w | |
531| 14 | pad_top | int | pad_left | |
532| 15 | pad_right | int | pad_left | |
533| 16 | pad_bottom | int | pad_top | |
534| 18 | output_pad_right| int | 0 | |
535| 19 | output_pad_bottom| int | output_pad_right | |
536| 20 | output_w | int | 0 | |
537| 21 | output_h | int | output_w | |
538| 28 | dynamic_weight| int | 0 | |
539
540| weight | type | shape |
541| ------------- | ----- | --------------------- |
542| weight_data | float/fp16 | [kernel_w, kernel_h, num_input, num_output] |
543| bias_data | float | [num_output] |
544
545# Deconvolution1D
546```
547x2 = deconv1d(x, weight, kernel, stride, dilation) + bias
548x3 = depad(x2, pads, pad_value)
549y = activation(x3, act_type, act_params)
550```
551
552* one_blob_only
553
554| param id | name | type | default | description |
555| --------- | ------------- | ----- | --------- | ----------------- |
556| 0 | num_output | int | 0 | |
557| 1 | kernel_w | int | 0 | |
558| 2 | dilation_w | int | 1 | |
559| 3 | stride_w | int | 1 | |
560| 4 | pad_left | int | 0 | |
561| 5 | bias_term | int | 0 | |
562| 6 | weight_data_size| int | 0 | |
563| 9 | activation_type| int | 0 | |
564| 10 | activation_params| array | [ ] | |
565| 15 | pad_right | int | pad_left | |
566| 18 | output_pad_right| int | 0 | |
567| 20 | output_w | int | 0 | |
568| 28 | dynamic_weight| int | 0 | |
569
570| weight | type | shape |
571| ------------- | ----- | --------------------- |
572| weight_data | float/fp16 | [kernel_w, num_input, num_output] |
573| bias_data | float | [num_output] |
574
575# Deconvolution3D
576```
577x2 = deconv3d(x, weight, kernel, stride, dilation) + bias
578x3 = depad(x2, pads, pad_value)
579y = activation(x3, act_type, act_params)
580```
581
582* one_blob_only
583
584| param id | name | type | default | description |
585| --------- | ------------- | ----- | --------- | ----------------- |
586| 0 | num_output | int | 0 | |
587| 1 | kernel_w | int | 0 | |
588| 2 | dilation_w | int | 1 | |
589| 3 | stride_w | int | 1 | |
590| 4 | pad_left | int | 0 | |
591| 5 | bias_term | int | 0 | |
592| 6 | weight_data_size| int | 0 | |
593| 9 | activation_type| int | 0 | |
594| 10 | activation_params| array | [ ] | |
595| 11 | kernel_h | int | kernel_w | |
596| 12 | dilation_h | int | dilation_w | |
597| 13 | stride_h | int | stride_w | |
598| 14 | pad_top | int | pad_left | |
599| 15 | pad_right | int | pad_left | |
600| 16 | pad_bottom | int | pad_top | |
601| 17 | pad_behind | int | pad_front | |
602| 18 | output_pad_right| int | 0 | |
603| 19 | output_pad_bottom| int | output_pad_right | |
604| 20 | output_pad_behind| int | output_pad_right | |
605| 21 | kernel_d | int | kernel_w | |
606| 22 | dilation_d | int | dilation_w | |
607| 23 | stride_d | int | stride_w | |
608| 24 | pad_front | int | pad_left | |
609| 25 | output_w | int | 0 | |
610| 26 | output_h | int | output_w | |
611| 27 | output_d | int | output_w | |
612
613| weight | type | shape |
614| ------------- | ----- | --------------------- |
615| weight_data | float/fp16 | [kernel_w, kernel_h, kernel_d, num_input, num_output] |
616| bias_data | float | [num_output] |
617
618# DeconvolutionDepthWise
619```
620x2 = deconv(x, weight, kernel, stride, dilation, group) + bias
621x3 = depad(x2, pads, pad_value)
622y = activation(x3, act_type, act_params)
623```
624
625* one_blob_only
626
627| param id | name | type | default | description |
628| --------- | ------------- | ----- | --------- | ----------------- |
629| 0 | num_output | int | 0 | |
630| 1 | kernel_w | int | 0 | |
631| 2 | dilation_w | int | 1 | |
632| 3 | stride_w | int | 1 | |
633| 4 | pad_left | int | 0 | |
634| 5 | bias_term | int | 0 | |
635| 6 | weight_data_size| int | 0 | |
636| 7 | group | int | 1 | |
637| 9 | activation_type| int | 0 | |
638| 10 | activation_params| array | [ ] | |
639| 11 | kernel_h | int | kernel_w | |
640| 12 | dilation_h | int | dilation_w | |
641| 13 | stride_h | int | stride_w | |
642| 14 | pad_top | int | pad_left | |
643| 15 | pad_right | int | pad_left | |
644| 16 | pad_bottom | int | pad_top | |
645| 18 | output_pad_right| int | 0 | |
646| 19 | output_pad_bottom| int | output_pad_right | |
647| 20 | output_w | int | 0 | |
648| 21 | output_h | int | output_w | |
649| 28 | dynamic_weight| int | 0 | |
650
651| weight | type | shape |
652| ------------- | ----- | --------------------- |
653| weight_data | float/fp16 | [kernel_w, kernel_h, num_input / group, num_output / group, group] |
654| bias_data | float | [num_output] |
655
656# DeconvolutionDepthWise1D
657```
658x2 = deconv1d(x, weight, kernel, stride, dilation, group) + bias
659x3 = depad(x2, pads, pad_value)
660y = activation(x3, act_type, act_params)
661```
662
663* one_blob_only
664
665| param id | name | type | default | description |
666| --------- | ------------- | ----- | --------- | ----------------- |
667| 0 | num_output | int | 0 | |
668| 1 | kernel_w | int | 0 | |
669| 2 | dilation_w | int | 1 | |
670| 3 | stride_w | int | 1 | |
671| 4 | pad_left | int | 0 | |
672| 5 | bias_term | int | 0 | |
673| 6 | weight_data_size| int | 0 | |
674| 7 | group | int | 1 | |
675| 9 | activation_type| int | 0 | |
676| 10 | activation_params| array | [ ] | |
677| 15 | pad_right | int | pad_left | |
678| 18 | output_pad_right| int | 0 | |
679| 20 | output_w | int | 0 | |
680| 28 | dynamic_weight| int | 0 | |
681
682| weight | type | shape |
683| ------------- | ----- | --------------------- |
684| weight_data | float/fp16 | [kernel_w, num_input / group, num_output / group, group] |
685| bias_data | float | [num_output] |
686
687# DeconvolutionDepthWise3D
688```
689x2 = deconv3d(x, weight, kernel, stride, dilation, group) + bias
690x3 = depad(x2, pads, pad_value)
691y = activation(x3, act_type, act_params)
692```
693
694* one_blob_only
695
696| param id | name | type | default | description |
697| --------- | ------------- | ----- | --------- | ----------------- |
698| 0 | num_output | int | 0 | |
699| 1 | kernel_w | int | 0 | |
700| 2 | dilation_w | int | 1 | |
701| 3 | stride_w | int | 1 | |
702| 4 | pad_left | int | 0 | |
703| 5 | bias_term | int | 0 | |
704| 6 | weight_data_size| int | 0 | |
705| 7 | group | int | 1 | |
706| 9 | activation_type| int | 0 | |
707| 10 | activation_params| array | [ ] | |
708| 11 | kernel_h | int | kernel_w | |
709| 12 | dilation_h | int | dilation_w | |
710| 13 | stride_h | int | stride_w | |
711| 14 | pad_top | int | pad_left | |
712| 15 | pad_right | int | pad_left | |
713| 16 | pad_bottom | int | pad_top | |
714| 17 | pad_behind | int | pad_front | |
715| 18 | output_pad_right| int | 0 | |
716| 19 | output_pad_bottom| int | output_pad_right | |
717| 20 | output_pad_behind| int | output_pad_right | |
718| 21 | kernel_d | int | kernel_w | |
719| 22 | dilation_d | int | dilation_w | |
720| 23 | stride_d | int | stride_w | |
721| 24 | pad_front | int | pad_left | |
722| 25 | output_w | int | 0 | |
723| 26 | output_h | int | output_w | |
724| 27 | output_d | int | output_w | |
725
726| weight | type | shape |
727| ------------- | ----- | --------------------- |
728| weight_data | float/fp16 | [kernel_w, kernel_h, kernel_d, num_input / group, num_output / group, group] |
729| bias_data | float | [num_output] |
730
731# DeformableConv2D
732```
733x2 = deformableconv2d(x, offset, mask, weight, kernel, stride, dilation) + bias
734y = activation(x2, act_type, act_params)
735```
736
737| param id | name | type | default | description |
738| --------- | ------------- | ----- | --------- | ----------------- |
739| 0 | num_output | int | 0 | |
740| 1 | kernel_w | int | 0 | |
741| 2 | dilation_w | int | 1 | |
742| 3 | stride_w | int | 1 | |
743| 4 | pad_left | int | 0 | |
744| 5 | bias_term | int | 0 | |
745| 6 | weight_data_size| int | 0 | |
746| 9 | activation_type| int | 0 | |
747| 10 | activation_params| array | [ ] | |
748| 11 | kernel_h | int | kernel_w | |
749| 12 | dilation_h | int | dilation_w | |
750| 13 | stride_h | int | stride_w | |
751| 14 | pad_top | int | pad_left | |
752| 15 | pad_right | int | pad_left | |
753| 16 | pad_bottom | int | pad_top | |
754
755| weight | type | shape |
756| ------------- | ----- | --------------------- |
757| weight_data | float/fp16/int8 | [kernel_w, kernel_h, num_input, num_output] |
758| bias_data | float | [num_output] |
759
760# Dequantize
761```
762y = x * scale + bias
763```
764
765* one_blob_only
766* support_inplace
767
768| param id | name | type | default | description |
769| --------- | ------------- | ----- | --------- | ----------------- |
770| 0 | scale_data_size| int | 1 | |
771| 1 | bias_data_size| int | 0 | |
772
773| weight | type | shape |
774| ------------- | ----- | --------------------- |
775| scale_data | float | [scale_data_size] |
776| bias_data | float | [bias_data_size] |
777
778# Diag
779```
780y = diag(x, diagonal)
781```
782
783* one_blob_only
784
785| param id | name | type | default | description |
786| --------- | ------------- | ----- | --------- | ----------------- |
787| 0 | diagonal | int | 0 | |
788
789# Dropout
790```
791y = x * scale
792```
793
794* one_blob_only
795
796| param id | name | type | default | description |
797| --------- | ------------- | ----- | --------- | ----------------- |
798| 0 | scale | float | 1.f | |
799
800# Eltwise
801```
802y = elementwise_op(x0, x1, ...)
803```
804
805| param id | name | type | default | description |
806| --------- | ------------- | ----- | --------- | ----------------- |
807| 0 | op_type | int | 0 | |
808| 1 | coeffs | array | [ ] | |
809
810Operation type:
811- 0 = PROD
812- 1 = SUM
813- 2 = MAX
814
815# ELU
816```
817if x < 0 y = (exp(x) - 1) * alpha
818else y = x
819```
820
821* one_blob_only
822* support_inplace
823
824| param id | name | type | default | description |
825| --------- | ------------- | ----- | --------- | ----------------- |
826| 0 | alpha | float | 0.1f | |
827
828# Embed
829```
830y = embedding(x)
831```
832
833| param id | name | type | default | description |
834| --------- | ------------- | ----- | --------- | ----------------- |
835| 0 | num_output | int | 0 | |
836| 1 | input_dim | int | 0 | |
837| 2 | bias_term | int | 0 | |
838| 3 | weight_data_size | int | 0 | |
839
840| weight | type | shape |
841| ------------- | ----- | --------------------- |
842| weight_data | float | [weight_data_size] |
843| bias_term | float | [num_output] |
844
845# Exp
846```
847if base == -1 y = exp(shift + x * scale)
848else y = pow(base, (shift + x * scale))
849```
850
851* one_blob_only
852* support_inplace
853
854| param id | name | type | default | description |
855| --------- | ------------- | ----- | --------- | ----------------- |
856| 0 | base | float | -1.f | |
857| 1 | scale | float | 1.f | |
858| 2 | shift | float | 0.f | |
859
860# Flatten
861Reshape blob to 1 dimension
862
863* one_blob_only
864
865# Fold
866```
867y = fold(x)
868```
869
870* one_blob_only
871
872| param id | name | type | default | description |
873| --------- | ------------- | ----- | --------- | ----------------- |
874| 0 | num_output | int | 0 | |
875| 1 | kernel_w | int | 0 | |
876| 2 | dilation_w | int | 1 | |
877| 3 | stride_w | int | 1 | |
878| 4 | pad_left | int | 0 | |
879| 11 | kernel_h | int | kernel_w | |
880| 12 | dilation_h | int | dilation_w | |
881| 13 | stride_h | int | stride_w | |
882| 14 | pad_top | int | pad_left | |
883| 15 | pad_right | int | pad_left | |
884| 16 | pad_bottom | int | pad_top | |
885| 20 | output_w | int | 0 | |
886| 21 | output_h | int | output_w | |
887
888# GELU
889```
890if fast_gelu == 1 y = 0.5 * x * (1 + tanh(0.79788452 * (x + 0.044715 * x * x * x)));
891else y = 0.5 * x * erfc(-0.70710678 * x)
892```
893
894* one_blob_only
895* support_inplace
896
897| param id | name | type | default | description |
898| --------- | ------------- | ----- | --------- | ----------------- |
899| 0 | fast_gelu | int | 0 | use approximation |
900
901# GLU
902
903If axis < 0, we use axis = x.dims + axis
904
905GLU(a,b)=a⊗σ(b)
906
907where a is the first half of the input matrix and b is the second half.
908
909axis specifies the dimension to split the input
910
911* one_blob_only
912
913| param id | name | type | default | description |
914| --------- | ------------- | ----- | --------- | ----------------- |
915| 0 | axis | int | 0 | |
916
917# Gemm
918```
919a = transA ? transpose(x0) : x0
920b = transb ? transpose(x1) : x1
921c = x2
922y = (gemm(a, b) + c * beta) * alpha
923```
924
925| param id | name | type | default | description |
926| --------- | ------------- | ----- | --------- | ----------------- |
927| 0 | alpha | float | 1.f | |
928| 1 | beta | float | 1.f | |
929| 2 | transA | int | 0 | |
930| 3 | transb | int | 0 | |
931| 4 | constantA | int | 0 | |
932| 5 | constantB | int | 0 | |
933| 6 | constantC | int | 0 | |
934| 7 | constantM | int | 0 | |
935| 8 | constantN | int | 0 | |
936| 9 | constantK | int | 0 | |
937| 10 | constant_broadcast_type_C | int | 0 | |
938| 11 | output_N1M | int | 0 | |
939| 12 | output_elempack | int | 0 | |
940| 13 | output_elemtype | int | 0 | |
941| 14 | output_transpose | int| 0 | |
942| 20 | constant_TILE_M | int | 0 | |
943| 21 | constant_TILE_N | int | 0 | |
944| 22 | constant_TILE_K | int | 0 | |
945
946| weight | type | shape |
947| ------------- | ----- | --------------------- |
948| A_data | float | [M, K] or [K, M] |
949| B_data | float | [N, K] or [K, N] |
950| C_data | float | [1], [M] or [N] or [1, M] or [N,1] or [N, M] |
951
952# GridSample
953```
954Given an input and a flow-field grid, computes the output using input values and pixel locations from grid.
955
956For each output location output[:, h2, w2], the size-2 vector grid[h2, w2, 2] specifies input pixel[:, h1, w1] locations x and y,
957which are used to interpolate the output value output[:, h2, w2]
958
959This function is often used in conjunction with affine_grid() to build Spatial Transformer Networks .
960```
961
962| param id | name | type | default | description |
963| --------- | ------------- | ----- | --------- | ----------------- |
964| 0 | sample_type | int | 1 | |
965| 1 | padding_mode | int | 1 | |
966| 2 | align_corner | int | 0 | |
967| 3 | permute_fusion| int | 0 | fuse with permute |
968
969
970Sample type:
971- 1 = Nearest
972- 2 = Bilinear
973- 3 = Bicubic
974
975Padding mode:
976- 1 = zeros
977- 2 = border
978- 3 = reflection
979
980
981# GroupNorm
982```
983split x along channel axis into group x0, x1 ...
984l2 normalize for each group x0, x1 ...
985y = x * gamma + beta
986```
987
988* one_blob_only
989* support_inplace
990
991| param id | name | type | default | description |
992| --------- | ------------- | ----- | --------- | ----------------- |
993| 0 | group | int | 1 | |
994| 1 | channels | int | 0 | |
995| 2 | eps | float | 0.001f | x = x / sqrt(var + eps) |
996| 3 | affine | int | 1 | |
997
998| weight | type | shape |
999| ------------- | ----- | --------------------- |
1000| gamma_data | float | [channels] |
1001| beta_data | float | [channels] |
1002
1003# GRU
1004Apply a single-layer GRU to a feature sequence of `T` timesteps. The input blob shape is `[w=input_size, h=T]` and the output blob shape is `[w=num_output, h=T]`.
1005
1006```
1007y = gru(x)
1008y0, hidden y1 = gru(x0, hidden x1)
1009```
1010
1011* one_blob_only if bidirectional
1012
1013| param id | name | type | default | description |
1014| --------- | ------------- | ----- | --------- | ----------------- |
1015| 0 | num_output | int | 0 | hidden size of output |
1016| 1 | weight_data_size| int | 0 | total size of weight matrix |
1017| 2 | direction | int | 0 | 0=forward, 1=reverse, 2=bidirectional |
1018
1019| weight | type | shape |
1020| ------------- | ----- | --------------------- |
1021| weight_xc_data| float/fp16/int8 | [input_size, num_output * 3, num_directions] |
1022| bias_c_data | float/fp16/int8 | [num_output, 4, num_directions] |
1023| weight_hc_data| float/fp16/int8 | [num_output, num_output * 3, num_directions] |
1024
1025Direction flag:
1026- 0 = forward only
1027- 1 = reverse only
1028- 2 = bidirectional
1029
1030# HardSigmoid
1031```
1032y = clamp(x * alpha + beta, 0, 1)
1033```
1034
1035* one_blob_only
1036* support_inplace
1037
1038| param id | name | type | default | description |
1039| --------- | ------------- | ----- | --------- | ----------------- |
1040| 0 | alpha | float | 0.2f | |
1041| 1 | beta | float | 0.5f | |
1042
1043# HardSwish
1044```
1045y = x * clamp(x * alpha + beta, 0, 1)
1046```
1047
1048* one_blob_only
1049* support_inplace
1050
1051| param id | name | type | default | description |
1052| --------- | ------------- | ----- | --------- | ----------------- |
1053| 0 | alpha | float | 0.2f | |
1054| 1 | beta | float | 0.5f | |
1055
1056# InnerProduct
1057```
1058x2 = innerproduct(x, weight) + bias
1059y = activation(x2, act_type, act_params)
1060```
1061
1062* one_blob_only
1063
1064| param id | name | type | default | description |
1065| --------- | ------------- | ----- | --------- | ----------------- |
1066| 0 | num_output | int | 0 | |
1067| 1 | bias_term | int | 0 | |
1068| 2 | weight_data_size| int | 0 | |
1069| 8 | int8_scale_term| int | 0 | |
1070| 9 | activation_type| int | 0 | |
1071| 10 | activation_params| array | [ ] | |
1072
1073| weight | type | shape |
1074| ------------- | ----- | --------------------- |
1075| weight_data | float/fp16/int8 | [num_input, num_output] |
1076| bias_data | float | [num_output] |
1077| weight_data_int8_scales| float | [num_output] |
1078| bottom_blob_int8_scales| float | [1] |
1079
1080# Input
1081```
1082y = input
1083```
1084
1085* support_inplace
1086
1087| param id | name | type | default | description |
1088| --------- | ------------- | ----- | --------- | ----------------- |
1089| 0 | w | int | 0 | |
1090| 1 | h | int | 0 | |
1091| 11 | d | int | 0 | |
1092| 2 | c | int | 0 | |
1093
1094# InstanceNorm
1095```
1096split x along channel axis into instance x0, x1 ...
1097l2 normalize for each channel instance x0, x1 ...
1098y = x * gamma + beta
1099```
1100
1101* one_blob_only
1102* support_inplace
1103
1104| param id | name | type | default | description |
1105| --------- | ------------- | ----- | --------- | ----------------- |
1106| 0 | channels | int | 0 | |
1107| 1 | eps | float | 0.001f | x = x / sqrt(var + eps) |
1108| 2 | affine | int | 1 | |
1109
1110| weight | type | shape |
1111| ------------- | ----- | --------------------- |
1112| gamma_data | float | [channels] |
1113| beta_data | float | [channels] |
1114
1115# Interp
1116```
1117if dynamic_target_size == 0 y = resize(x) by fixed size or scale
1118else y = resize(x0, size(x1))
1119```
1120
1121* one_blob_only if dynamic_target_size == 0
1122
1123| param id | name | type | default | description |
1124| --------- | ------------- | ----- | --------- | ----------------- |
1125| 0 | resize_type | int | 0 | |
1126| 1 | height_scale | float | 1.f | |
1127| 2 | width_scale | float | 1.f | |
1128| 3 | output_height | int | 0 | |
1129| 4 | output_width | int | 0 | |
1130| 5 | dynamic_target_size| int | 0 | |
1131| 6 | align_corner | int | 0 | |
1132
1133Resize type:
1134- 1 = Nearest
1135- 2 = Bilinear
1136- 3 = Bicubic
1137
1138# LayerNorm
1139```
1140split x along outmost axis into part x0, x1 ...
1141l2 normalize for each part x0, x1 ...
1142y = x * gamma + beta by elementwise
1143```
1144
1145* one_blob_only
1146* support_inplace
1147
1148| param id | name | type | default | description |
1149| --------- | ------------- | ----- | --------- | ----------------- |
1150| 0 | affine_size | int | 0 | |
1151| 1 | eps | float | 0.001f | x = x / sqrt(var + eps) |
1152| 2 | affine | int | 1 | |
1153
1154| weight | type | shape |
1155| ------------- | ----- | --------------------- |
1156| gamma_data | float | [affine_size] |
1157| beta_data | float | [affine_size] |
1158
1159# Log
1160```
1161if base == -1 y = log(shift + x * scale)
1162else y = log(shift + x * scale) / log(base)
1163```
1164
1165* one_blob_only
1166* support_inplace
1167
1168| param id | name | type | default | description |
1169| --------- | ------------- | ----- | --------- | ----------------- |
1170| 0 | base | float | -1.f | |
1171| 1 | scale | float | 1.f | |
1172| 2 | shift | float | 0.f | |
1173
1174# LRN
1175```
1176if region_type == ACROSS_CHANNELS square_sum = sum of channel window of local_size
1177if region_type == WITHIN_CHANNEL square_sum = sum of spatial window of local_size
1178y = x * pow(bias + alpha * square_sum / (local_size * local_size), -beta)
1179```
1180
1181* one_blob_only
1182* support_inplace
1183
1184| param id | name | type | default | description |
1185| --------- | ------------- | ----- | --------- | ----------------- |
1186| 0 | region_type | int | 0 | |
1187| 1 | local_size | int | 5 | |
1188| 2 | alpha | float | 1.f | |
1189| 3 | beta | float | 0.75f | |
1190| 4 | bias | float | 1.f | |
1191
1192Region type:
1193- 0 = ACROSS_CHANNELS
1194- 1 = WITHIN_CHANNEL
1195
1196# LSTM
1197Apply a single-layer LSTM to a feature sequence of `T` timesteps. The input blob shape is `[w=input_size, h=T]` and the output blob shape is `[w=num_output, h=T]`.
1198
1199```
1200y = lstm(x)
1201y0, hidden y1, cell y2 = lstm(x0, hidden x1, cell x2)
1202```
1203
1204* one_blob_only if bidirectional
1205
1206| param id | name | type | default | description |
1207| --------- | ------------- | ----- | --------- | ----------------- |
1208| 0 | num_output | int | 0 | output size of output |
1209| 1 | weight_data_size| int | 0 | total size of IFOG weight matrix |
1210| 2 | direction | int | 0 | 0=forward, 1=reverse, 2=bidirectional |
1211| 3 | hidden_size | int | num_output| hidden size |
1212
1213| weight | type | shape |
1214| ------------- | ----- | --------------------- |
1215| weight_xc_data| float/fp16/int8 | [input_size, hidden_size * 4, num_directions] |
1216| bias_c_data | float/fp16/int8 | [hidden_size, 4, num_directions] |
1217| weight_hc_data| float/fp16/int8 | [num_output, hidden_size * 4, num_directions] |
1218| weight_hr_data| float/fp16/int8 | [hidden_size, num_output, num_directions] |
1219
1220Direction flag:
1221- 0 = forward only
1222- 1 = reverse only
1223- 2 = bidirectional
1224
1225# MemoryData
1226```
1227y = data
1228```
1229
1230| param id | name | type | default | description |
1231| --------- | ------------- | ----- | --------- | ----------------- |
1232| 0 | w | int | 0 | |
1233| 1 | h | int | 0 | |
1234| 11 | d | int | 0 | |
1235| 2 | c | int | 0 | |
1236| 21 | load_type | int | 1 | 1=fp32 |
1237
1238| weight | type | shape |
1239| ------------- | ----- | --------------------- |
1240| data | float | [w, h, d, c] |
1241
1242# Mish
1243```
1244y = x * tanh(log(exp(x) + 1))
1245```
1246
1247* one_blob_only
1248* support_inplace
1249
1250# MultiHeadAttention
1251```
1252split q k v into num_head part q0, k0, v0, q1, k1, v1 ...
1253for each num_head part
1254 xq = affine(q) / (embed_dim / num_head)
1255 xk = affine(k)
1256 xv = affine(v)
1257 xqk = xq * xk
1258 xqk = xqk + attn_mask if attn_mask exists
1259 softmax_inplace(xqk)
1260 xqkv = xqk * xv
1261 merge xqkv to out
1262y = affine(out)
1263```
1264
1265| param id | name | type | default | description |
1266| --------- | ------------- | ----- | --------- | ----------------- |
1267| 0 | embed_dim | int | 0 | |
1268| 1 | num_heads | int | 1 | |
1269| 2 | weight_data_size| int | 0 | qdim = weight_data_size / embed_dim |
1270| 3 | kdim | int | embed_dim | |
1271| 4 | vdim | int | embed_dim | |
1272| 5 | attn_mask | int | 0 | |
1273| 6 | scale | float | 1.f / sqrt(embed_dim / num_heads) | |
1274
1275| weight | type | shape |
1276| ------------- | ----- | --------------------- |
1277| q_weight_data | float/fp16/int8 | [embed_dim * qdim] |
1278| q_bias_data | float | [embed_dim] |
1279| k_weight_data | float/fp16/int8 | [embed_dim * kdim] |
1280| k_bias_data | float | [embed_dim] |
1281| v_weight_data | float/fp16/int8 | [embed_dim * vdim] |
1282| v_bias_data | float | [embed_dim] |
1283| out_weight_data| float/fp16/int8 | [qdim * embed_dim] |
1284| out_bias_data | float | [qdim] |
1285
1286# MVN
1287```
1288if normalize_variance == 1 && across_channels == 1 y = (x - mean) / (sqrt(var) + eps) of whole blob
1289if normalize_variance == 1 && across_channels == 0 y = (x - mean) / (sqrt(var) + eps) of each channel
1290if normalize_variance == 0 && across_channels == 1 y = x - mean of whole blob
1291if normalize_variance == 0 && across_channels == 0 y = x - mean of each channel
1292```
1293
1294* one_blob_only
1295
1296| param id | name | type | default | description |
1297| --------- | ------------- | ----- | --------- | ----------------- |
1298| 0 | normalize_variance| int | 0 | |
1299| 1 | across_channels| int | 0 | |
1300| 2 | eps | float | 0.0001f | x = x / (sqrt(var) + eps) |
1301
1302# Noop
1303```
1304y = x
1305```
1306
1307# Normalize
1308```
1309if across_spatial == 1 && across_channel == 1 x2 = normalize(x) of whole blob
1310if across_spatial == 1 && across_channel == 0 x2 = normalize(x) of each channel
1311if across_spatial == 0 && across_channel == 1 x2 = normalize(x) of each position
1312y = x2 * scale
1313```
1314
1315* one_blob_only
1316* support_inplace
1317
1318| param id | name | type | default | description |
1319| --------- | ------------- | ----- | --------- | ----------------- |
1320| 0 | across_spatial| int | 0 | |
1321| 1 | channel_shared| int | 0 | |
1322| 2 | eps | float | 0.0001f | see eps mode |
1323| 3 | scale_data_size| int | 0 | |
1324| 4 | across_channel| int | 0 | |
1325| 9 | eps_mode | int | 0 | |
1326
1327| weight | type | shape |
1328| ------------- | ----- | --------------------- |
1329| scale_data | float | [scale_data_size] |
1330
1331Eps Mode:
1332- 0 = caffe/mxnet x = x / sqrt(var + eps)
1333- 1 = pytorch x = x / max(sqrt(var), eps)
1334- 2 = tensorflow x = x / sqrt(max(var, eps))
1335
1336# Packing
1337```
1338y = wrap_packing(x)
1339```
1340
1341* one_blob_only
1342
1343| param id | name | type | default | description |
1344| --------- | ------------- | ----- | --------- | ----------------- |
1345| 0 | out_elempack | int | 1 | |
1346| 1 | use_padding | int | 0 | |
1347| 2 | cast_type_from| int | 0 | |
1348| 3 | cast_type_to | int | 0 | |
1349| 4 | storage_type_from| int | 0 | |
1350| 5 | storage_type_to| int | 0 | |
1351
1352# Padding
1353```
1354y = pad(x, pads)
1355```
1356
1357| param id | name | type | default | description |
1358| --------- | ------------- | ---- | --------- | ----------------- |
1359| 0 | top | int | 0 | |
1360| 1 | bottom | int | 0 | |
1361| 2 | left | int | 0 | |
1362| 3 | right | int | 0 | |
1363| 4 | type | int | 0 | |
1364| 5 | value | float | 0 | |
1365| 6 | per_channel_pad_data_size| int | 0 | |
1366| 7 | front | int | stride_w | |
1367| 8 | behind | int | pad_left | |
1368
1369| weight | type | shape |
1370| ------------- | ----- | --------------------- |
1371| per_channel_pad_data| float | [per_channel_pad_data_size] |
1372
1373Padding type:
1374- 0 = CONSTANT
1375- 1 = REPLICATE
1376- 2 = REFLECT
1377
1378# Permute
1379```
1380y = reorder(x)
1381```
1382
1383| param id | name | type | default | description |
1384| --------- | ------------- | ---- | --------- | ----------------- |
1385| 0 | order_type | int | 0 | |
1386
1387Order Type:
1388- 0 = WH WHC WHDC
1389- 1 = HW HWC HWDC
1390- 2 = WCH WDHC
1391- 3 = CWH DWHC
1392- 4 = HCW HDWC
1393- 5 = CHW DHWC
1394- 6 = WHCD
1395- 7 = HWCD
1396- 8 = WCHD
1397- 9 = CWHD
1398- 10 = HCWD
1399- 11 = CHWD
1400- 12 = WDCH
1401- 13 = DWCH
1402- 14 = WCDH
1403- 15 = CWDH
1404- 16 = DCWH
1405- 17 = CDWH
1406- 18 = HDCW
1407- 19 = DHCW
1408- 20 = HCDW
1409- 21 = CHDW
1410- 22 = DCHW
1411- 23 = CDHW
1412
1413# PixelShuffle
1414```
1415if mode == 0 y = depth_to_space(x) where x channel order is sw-sh-outc
1416if mode == 1 y = depth_to_space(x) where x channel order is outc-sw-sh
1417```
1418
1419* one_blob_only
1420
1421| param id | name | type | default | description |
1422| --------- | ------------- | ---- | --------- | ----------------- |
1423| 0 | upscale_factor| int | 1 | |
1424| 1 | mode | int | 0 | |
1425
1426# Pooling
1427```
1428x2 = pad(x, pads)
1429x3 = pooling(x2, kernel, stride)
1430```
1431
1432| param id | name | type | default | description |
1433| --------- | --------------| ---- | --------- | ----------------- |
1434| 0 | pooling_type | int | 0 | |
1435| 1 | kernel_w | int | 0 | |
1436| 2 | stride_w | int | 1 | |
1437| 3 | pad_left | int | 0 | |
1438| 4 | global_pooling| int | 0 | |
1439| 5 | pad_mode | int | 0 | |
1440| 6 | avgpool_count_include_pad| int | 0 | |
1441| 7 | adaptive_pooling| int | 0 | |
1442| 8 | out_w | int | 0 | |
1443| 11 | kernel_h | int | kernel_w | |
1444| 12 | stride_h | int | stride_w | |
1445| 13 | pad_top | int | pad_left | |
1446| 14 | pad_right | int | pad_left | |
1447| 15 | pad_bottom | int | pad_top | |
1448| 18 | out_h | int | out_w | |
1449
1450Pooling type:
1451- 0 = MAX
1452- 1 = AVG
1453
1454Pad mode:
1455- 0 = full padding
1456- 1 = valid padding
1457- 2 = tensorflow padding=SAME or onnx padding=SAME_UPPER
1458- 3 = onnx padding=SAME_LOWER
1459
1460# Pooling1D
1461```
1462x2 = pad(x, pads)
1463x3 = pooling1d(x2, kernel, stride)
1464```
1465
1466| param id | name | type | default | description |
1467| --------- | --------------| ---- | --------- | ----------------- |
1468| 0 | pooling_type | int | 0 | |
1469| 1 | kernel_w | int | 0 | |
1470| 2 | stride_w | int | 1 | |
1471| 3 | pad_left | int | 0 | |
1472| 4 | global_pooling| int | 0 | |
1473| 5 | pad_mode | int | 0 | |
1474| 6 | avgpool_count_include_pad| int | 0 | |
1475| 7 | adaptive_pooling| int | 0 | |
1476| 8 | out_w | int | 0 | |
1477| 14 | pad_right | int | pad_left | |
1478
1479Pooling type:
1480- 0 = MAX
1481- 1 = AVG
1482
1483Pad mode:
1484- 0 = full padding
1485- 1 = valid padding
1486- 2 = tensorflow padding=SAME or onnx padding=SAME_UPPER
1487- 3 = onnx padding=SAME_LOWER
1488
1489# Pooling3D
1490```
1491x2 = pad(x, pads)
1492x3 = pooling3d(x2, kernel, stride)
1493```
1494
1495| param id | name | type | default | description |
1496| --------- | --------------| ---- | --------- | ----------------- |
1497| 0 | pooling_type | int | 0 | |
1498| 1 | kernel_w | int | 0 | |
1499| 2 | stride_w | int | 1 | |
1500| 3 | pad_left | int | 0 | |
1501| 4 | global_pooling| int | 0 | |
1502| 5 | pad_mode | int | 0 | |
1503| 6 | avgpool_count_include_pad| int | 0 | |
1504| 7 | adaptive_pooling| int | 0 | |
1505| 8 | out_w | int | 0 | |
1506| 11 | kernel_h | int | kernel_w | |
1507| 12 | stride_h | int | stride_w | |
1508| 13 | pad_top | int | pad_left | |
1509| 14 | pad_right | int | pad_left | |
1510| 15 | pad_bottom | int | pad_top | |
1511| 16 | pad_behind | int | pad_front | |
1512| 18 | out_h | int | out_w | |
1513| 21 | kernel_d | int | kernel_w | |
1514| 22 | stride_d | int | stride_w | |
1515| 23 | pad_front | int | pad_left | |
1516| 28 | out_d | int | out_w | |
1517
1518Pooling type:
1519- 0 = MAX
1520- 1 = AVG
1521
1522Pad mode:
1523- 0 = full padding
1524- 1 = valid padding
1525- 2 = tensorflow padding=SAME or onnx padding=SAME_UPPER
1526- 3 = onnx padding=SAME_LOWER
1527
1528# Power
1529```
1530y = pow((shift + x * scale), power)
1531```
1532
1533* one_blob_only
1534* support_inplace
1535
1536| param id | name | type | default | description |
1537| --------- | ------------- | ----- | --------- | ----------------- |
1538| 0 | power | float | 1.f | |
1539| 1 | scale | float | 1.f | |
1540| 2 | shift | float | 0.f | |
1541
1542# PReLU
1543```
1544if x < 0 y = x * slope
1545else y = x
1546```
1547
1548* one_blob_only
1549* support_inplace
1550
1551| param id | name | type | default | description |
1552| --------- | ------------- | ----- | --------- | ----------------- |
1553| 0 | num_slope | int | 0 | |
1554
1555| weight | type | shape |
1556| ------------- | ----- | --------------------- |
1557| slope_data | float | [num_slope] |
1558
1559# Quantize
1560```
1561y = float2int8(x * scale)
1562```
1563
1564* one_blob_only
1565
1566| param id | name | type | default | description |
1567| --------- | ------------- | ----- | --------- | ----------------- |
1568| 0 | scale_data_size| int | 1 | |
1569
1570| weight | type | shape |
1571| ------------- | ----- | --------------------- |
1572| scale_data | float | [scale_data_size] |
1573
1574# Reduction
1575```
1576y = reduce_op(x * coeff)
1577```
1578
1579* one_blob_only
1580
1581| param id | name | type | default | description |
1582| --------- | ------------- | ----- | --------- | ----------------- |
1583| 0 | operation | int | 0 | |
1584| 1 | reduce_all | int | 1 | |
1585| 2 | coeff | float | 1.f | |
1586| 3 | axes | array | [ ] | |
1587| 4 | keepdims | int | 0 | |
1588| 5 | fixbug0 | int | 0 | hack for bug fix, should be 1 |
1589
1590Operation type:
1591- 0 = SUM
1592- 1 = ASUM
1593- 2 = SUMSQ
1594- 3 = MEAN
1595- 4 = MAX
1596- 5 = MIN
1597- 6 = PROD
1598- 7 = L1
1599- 8 = L2
1600- 9 = LogSum
1601- 10 = LogSumExp
1602
1603# ReLU
1604```
1605if x < 0 y = x * slope
1606else y = x
1607```
1608
1609* one_blob_only
1610* support_inplace
1611
1612| param id | name | type | default | description |
1613| --------- | ------------- | ----- | --------- | ----------------- |
1614| 0 | slope | float | 0.f | |
1615
1616# Reorg
1617```
1618if mode == 0 y = space_to_depth(x) where x channel order is sw-sh-outc
1619if mode == 1 y = space_to_depth(x) where x channel order is outc-sw-sh
1620```
1621
1622* one_blob_only
1623
1624| param id | name | type | default | description |
1625| --------- | ------------- | ---- | --------- | ----------------- |
1626| 0 | stride | int | 1 | |
1627| 1 | mode | int | 0 | |
1628
1629# Requantize
1630```
1631x2 = x * scale_in + bias
1632x3 = activation(x2)
1633y = float2int8(x3 * scale_out)
1634```
1635
1636* one_blob_only
1637
1638| param id | name | type | default | description |
1639| --------- | ------------- | ----- | --------- | ----------------- |
1640| 0 | scale_in_data_size| int | 1 | |
1641| 1 | scale_out_data_size| int | 1 | |
1642| 2 | bias_data_size| int | 0 | |
1643| 3 | activation_type| int | 0 | |
1644| 4 | activation_params| int | [ ] | |
1645
1646| weight | type | shape |
1647| ------------- | ----- | --------------------- |
1648| scale_in_data | float | [scale_in_data_size] |
1649| scale_out_data| float | [scale_out_data_size] |
1650| bias_data | float | [bias_data_size] |
1651
1652# Reshape
1653```
1654if permute == 1 y = hwc2chw(reshape(chw2hwc(x)))
1655else y = reshape(x)
1656```
1657
1658* one_blob_only
1659
1660| param id | name | type | default | description |
1661| --------- | ------------- | ----- | --------- | ----------------- |
1662| 0 | w | int | -233 | |
1663| 1 | h | int | -233 | |
1664| 11 | d | int | -233 | |
1665| 2 | c | int | -233 | |
1666| 3 | permute | int | 0 | |
1667
1668Reshape flag:
1669- 0 = copy from bottom
1670- -1 = remaining
1671- -233 = drop this dim(default)
1672
1673# RNN
1674Apply a single-layer RNN to a feature sequence of `T` timesteps. The input blob shape is `[w=input_size, h=T]` and the output blob shape is `[w=num_output, h=T]`.
1675
1676```
1677y = rnn(x)
1678y0, hidden y1 = rnn(x0, hidden x1)
1679```
1680
1681* one_blob_only if bidirectional
1682
1683| param id | name | type | default | description |
1684| --------- | ------------- | ----- | --------- | ----------------- |
1685| 0 | num_output | int | 0 | hidden size of output |
1686| 1 | weight_data_size| int | 0 | total size of weight matrix |
1687| 2 | direction | int | 0 | 0=forward, 1=reverse, 2=bidirectional |
1688
1689| weight | type | shape |
1690| ------------- | ----- | --------------------- |
1691| weight_xc_data| float/fp16/int8 | [input_size, num_output, num_directions] |
1692| bias_c_data | float/fp16/int8 | [num_output, 1, num_directions] |
1693| weight_hc_data| float/fp16/int8 | [num_output, num_output, num_directions] |
1694
1695Direction flag:
1696- 0 = forward only
1697- 1 = reverse only
1698- 2 = bidirectional
1699
1700# Scale
1701```
1702if scale_data_size == -233 y = x0 * x1
1703else y = x * scale + bias
1704```
1705
1706* one_blob_only if scale_data_size != -233
1707* support_inplace
1708
1709| param id | name | type | default | description |
1710| --------- | ------------- | ----- | --------- | ----------------- |
1711| 0 | scale_data_size| int | 0 | |
1712| 1 | bias_term | int | 0 | |
1713
1714| weight | type | shape |
1715| ------------- | ----- | --------------------- |
1716| scale_data | float | [scale_data_size] |
1717| bias_data | float | [scale_data_size] |
1718
1719# SELU
1720```
1721if x < 0 y = (exp(x) - 1.f) * alpha * lambda
1722else y = x * lambda
1723```
1724
1725* one_blob_only
1726* support_inplace
1727
1728| param id | name | type | default | description |
1729| --------- | ------------- | ----- | --------- | ----------------- |
1730| 0 | alpha | float | 1.67326324f| |
1731| 1 | lambda | float | 1.050700987f| |
1732
1733# Shrink
1734```
1735if x < -lambd y = x + bias
1736if x > lambd y = x - bias
1737else y = x
1738```
1739
1740* one_blob_only
1741* support_inplace
1742
1743| param id | name | type | default | description |
1744| --------- | ------------- | ----- | --------- | ----------------- |
1745| 0 | bias | float | 0.0f | |
1746| 1 | lambd | float | 0.5f | |
1747
1748# ShuffleChannel
1749```
1750if reverse == 0 y = shufflechannel(x) by group
1751if reverse == 1 y = shufflechannel(x) by channel / group
1752```
1753
1754* one_blob_only
1755
1756| param id | name | type | default | description |
1757| --------- | ------------- | ---- | --------- | ----------------- |
1758| 0 | group | int | 1 | |
1759| 1 | reverse | int | 0 | |
1760
1761# Sigmoid
1762```
1763y = 1 / (1 + exp(-x))
1764```
1765
1766* one_blob_only
1767* support_inplace
1768
1769# Slice
1770```
1771split x along axis into slices, each part slice size is based on slices array
1772```
1773
1774| param id | name | type | default | description |
1775| --------- | ------------- | ----- | --------- | ----------------- |
1776| 0 | slices | array | [ ] | |
1777| 1 | axis | int | 0 | |
1778| 2 | indices | array | [ ] | |
1779
1780# Softmax
1781```
1782softmax(x, axis)
1783```
1784
1785* one_blob_only
1786* support_inplace
1787
1788| param id | name | type | default | description |
1789| --------- | ------------- | ----- | --------- | ----------------- |
1790| 0 | axis | int | 0 | |
1791| 1 | fixbug0 | int | 0 | hack for bug fix, should be 1 |
1792
1793# Softplus
1794```
1795y = log(exp(x) + 1)
1796```
1797
1798* one_blob_only
1799* support_inplace
1800
1801# Split
1802```
1803y0, y1 ... = x
1804```
1805
1806# Swish
1807```
1808y = x / (1 + exp(-x))
1809```
1810
1811* one_blob_only
1812* support_inplace
1813
1814# TanH
1815```
1816y = tanh(x)
1817```
1818
1819* one_blob_only
1820* support_inplace
1821
1822# Threshold
1823```
1824if x > threshold y = 1
1825else y = 0
1826```
1827
1828* one_blob_only
1829* support_inplace
1830
1831| param id | name | type | default | description |
1832| --------- | ------------- | ----- | --------- | ----------------- |
1833| 0 | threshold | float | 0.f | |
1834
1835# Tile
1836```
1837y = repeat tiles along axis for x
1838```
1839
1840* one_blob_only
1841
1842| param id | name | type | default | description |
1843| --------- | ------------- | ----- | --------- | ----------------- |
1844| 0 | axis | int | 0 | |
1845| 1 | tiles | int | 1 | |
1846| 2 | repeats | array | [ ] | |
1847
1848# UnaryOp
1849```
1850y = unaryop(x)
1851```
1852
1853- one_blob_only
1854- support_inplace
1855
1856| param id | name | type | default | description |
1857| --------- | ------------- | ----- | --------- | ----------------- |
1858| 0 | op_type | int | 0 | Operation type as follows |
1859
1860Operation type:
1861- 0 = ABS
1862- 1 = NEG
1863- 2 = FLOOR
1864- 3 = CEIL
1865- 4 = SQUARE
1866- 5 = SQRT
1867- 6 = RSQ
1868- 7 = EXP
1869- 8 = LOG
1870- 9 = SIN
1871- 10 = COS
1872- 11 = TAN
1873- 12 = ASIN
1874- 13 = ACOS
1875- 14 = ATAN
1876- 15 = RECIPROCAL
1877- 16 = TANH
1878- 17 = LOG10
1879- 18 = ROUND
1880- 19 = TRUNC
1881
1882# Unfold
1883```
1884y = unfold(x)
1885```
1886
1887* one_blob_only
1888
1889| param id | name | type | default | description |
1890| --------- | ------------- | ----- | --------- | ----------------- |
1891| 0 | num_output | int | 0 | |
1892| 1 | kernel_w | int | 0 | |
1893| 2 | dilation_w | int | 1 | |
1894| 3 | stride_w | int | 1 | |
1895| 4 | pad_left | int | 0 | |
1896| 11 | kernel_h | int | kernel_w | |
1897| 12 | dilation_h | int | dilation_w | |
1898| 13 | stride_h | int | stride_w | |
1899| 14 | pad_top | int | pad_left | |
1900| 15 | pad_right | int | pad_left | |
1901| 16 | pad_bottom | int | pad_top | |