Elffuss BraidHub

kikocis/ncnn public

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