Elffuss BraidHub

kikocis/ncnn public

b2ca57dc6b91 · 70.2 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
841| weight | type | shape |
842| ------------- | ----- | --------------------- |
843| weight_data | float | [weight_data_size] |
844| bias_term | float | [num_output] |
845
846# Exp
847```
848if base == -1 y = exp(shift + x * scale)
849else y = pow(base, (shift + x * scale))
850```
851
852* one_blob_only
853* support_inplace
854
855| param id | name | type | default | description |
856| --------- | ------------- | ----- | --------- | ----------------- |
857| 0 | base | float | -1.f | |
858| 1 | scale | float | 1.f | |
859| 2 | shift | float | 0.f | |
860
861# Flatten
862Reshape blob to 1 dimension
863
864* one_blob_only
865
866# Fold
867```
868y = fold(x)
869```
870
871* one_blob_only
872
873| param id | name | type | default | description |
874| --------- | ------------- | ----- | --------- | ----------------- |
875| 0 | num_output | int | 0 | |
876| 1 | kernel_w | int | 0 | |
877| 2 | dilation_w | int | 1 | |
878| 3 | stride_w | int | 1 | |
879| 4 | pad_left | int | 0 | |
880| 11 | kernel_h | int | kernel_w | |
881| 12 | dilation_h | int | dilation_w | |
882| 13 | stride_h | int | stride_w | |
883| 14 | pad_top | int | pad_left | |
884| 15 | pad_right | int | pad_left | |
885| 16 | pad_bottom | int | pad_top | |
886| 20 | output_w | int | 0 | |
887| 21 | output_h | int | output_w | |
888
889# GELU
890```
891if fast_gelu == 1 y = 0.5 * x * (1 + tanh(0.79788452 * (x + 0.044715 * x * x * x)));
892else y = 0.5 * x * erfc(-0.70710678 * x)
893```
894
895* one_blob_only
896* support_inplace
897
898| param id | name | type | default | description |
899| --------- | ------------- | ----- | --------- | ----------------- |
900| 0 | fast_gelu | int | 0 | use approximation |
901
902# GLU
903
904If axis < 0, we use axis = x.dims + axis
905
906GLU(a,b)=a⊗σ(b)
907
908where a is the first half of the input matrix and b is the second half.
909
910axis specifies the dimension to split the input
911
912* one_blob_only
913
914| param id | name | type | default | description |
915| --------- | ------------- | ----- | --------- | ----------------- |
916| 0 | axis | int | 0 | |
917
918# Gemm
919```
920a = transA ? transpose(x0) : x0
921b = transb ? transpose(x1) : x1
922c = x2
923y = (gemm(a, b) + c * beta) * alpha
924```
925
926| param id | name | type | default | description |
927| --------- | ------------- | ----- | --------- | ----------------- |
928| 0 | alpha | float | 1.f | |
929| 1 | beta | float | 1.f | |
930| 2 | transA | int | 0 | |
931| 3 | transb | int | 0 | |
932| 4 | constantA | int | 0 | |
933| 5 | constantB | int | 0 | |
934| 6 | constantC | int | 0 | |
935| 7 | constantM | int | 0 | |
936| 8 | constantN | int | 0 | |
937| 9 | constantK | int | 0 | |
938| 10 | constant_broadcast_type_C | int | 0 | |
939| 11 | output_N1M | int | 0 | |
940| 12 | output_elempack | int | 0 | |
941| 13 | output_elemtype | int | 0 | |
942| 14 | output_transpose | int| 0 | |
943| 20 | constant_TILE_M | int | 0 | |
944| 21 | constant_TILE_N | int | 0 | |
945| 22 | constant_TILE_K | int | 0 | |
946
947| weight | type | shape |
948| ------------- | ----- | --------------------- |
949| A_data | float | [M, K] or [K, M] |
950| B_data | float | [N, K] or [K, N] |
951| C_data | float | [1], [M] or [N] or [1, M] or [N,1] or [N, M] |
952
953# GridSample
954```
955Given an input and a flow-field grid, computes the output using input values and pixel locations from grid.
956
957For each output location output[:, h2, w2], the size-2 vector grid[h2, w2, 2] specifies input pixel[:, h1, w1] locations x and y,
958which are used to interpolate the output value output[:, h2, w2]
959
960This function is often used in conjunction with affine_grid() to build Spatial Transformer Networks .
961```
962
963| param id | name | type | default | description |
964| --------- | ------------- | ----- | --------- | ----------------- |
965| 0 | sample_type | int | 1 | |
966| 1 | padding_mode | int | 1 | |
967| 2 | align_corner | int | 0 | |
968| 3 | permute_fusion| int | 0 | fuse with permute |
969
970
971Sample type:
972- 1 = Nearest
973- 2 = Bilinear
974- 3 = Bicubic
975
976Padding mode:
977- 1 = zeros
978- 2 = border
979- 3 = reflection
980
981
982# GroupNorm
983```
984split x along channel axis into group x0, x1 ...
985l2 normalize for each group x0, x1 ...
986y = x * gamma + beta
987```
988
989* one_blob_only
990* support_inplace
991
992| param id | name | type | default | description |
993| --------- | ------------- | ----- | --------- | ----------------- |
994| 0 | group | int | 1 | |
995| 1 | channels | int | 0 | |
996| 2 | eps | float | 0.001f | x = x / sqrt(var + eps) |
997| 3 | affine | int | 1 | |
998
999| weight | type | shape |
1000| ------------- | ----- | --------------------- |
1001| gamma_data | float | [channels] |
1002| beta_data | float | [channels] |
1003
1004# GRU
1005Apply 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]`.
1006
1007```
1008y = gru(x)
1009y0, hidden y1 = gru(x0, hidden x1)
1010```
1011
1012* one_blob_only if bidirectional
1013
1014| param id | name | type | default | description |
1015| --------- | ------------- | ----- | --------- | ----------------- |
1016| 0 | num_output | int | 0 | hidden size of output |
1017| 1 | weight_data_size| int | 0 | total size of weight matrix |
1018| 2 | direction | int | 0 | 0=forward, 1=reverse, 2=bidirectional |
1019
1020| weight | type | shape |
1021| ------------- | ----- | --------------------- |
1022| weight_xc_data| float/fp16/int8 | [input_size, num_output * 3, num_directions] |
1023| bias_c_data | float/fp16/int8 | [num_output, 4, num_directions] |
1024| weight_hc_data| float/fp16/int8 | [num_output, num_output * 3, num_directions] |
1025
1026Direction flag:
1027- 0 = forward only
1028- 1 = reverse only
1029- 2 = bidirectional
1030
1031# HardSigmoid
1032```
1033y = clamp(x * alpha + beta, 0, 1)
1034```
1035
1036* one_blob_only
1037* support_inplace
1038
1039| param id | name | type | default | description |
1040| --------- | ------------- | ----- | --------- | ----------------- |
1041| 0 | alpha | float | 0.2f | |
1042| 1 | beta | float | 0.5f | |
1043
1044# HardSwish
1045```
1046y = x * clamp(x * alpha + beta, 0, 1)
1047```
1048
1049* one_blob_only
1050* support_inplace
1051
1052| param id | name | type | default | description |
1053| --------- | ------------- | ----- | --------- | ----------------- |
1054| 0 | alpha | float | 0.2f | |
1055| 1 | beta | float | 0.5f | |
1056
1057# InnerProduct
1058```
1059x2 = innerproduct(x, weight) + bias
1060y = activation(x2, act_type, act_params)
1061```
1062
1063* one_blob_only
1064
1065| param id | name | type | default | description |
1066| --------- | ------------- | ----- | --------- | ----------------- |
1067| 0 | num_output | int | 0 | |
1068| 1 | bias_term | int | 0 | |
1069| 2 | weight_data_size| int | 0 | |
1070| 8 | int8_scale_term| int | 0 | |
1071| 9 | activation_type| int | 0 | |
1072| 10 | activation_params| array | [ ] | |
1073
1074| weight | type | shape |
1075| ------------- | ----- | --------------------- |
1076| weight_data | float/fp16/int8 | [num_input, num_output] |
1077| bias_data | float | [num_output] |
1078| weight_data_int8_scales| float | [num_output] |
1079| bottom_blob_int8_scales| float | [1] |
1080
1081# Input
1082```
1083y = input
1084```
1085
1086* support_inplace
1087
1088| param id | name | type | default | description |
1089| --------- | ------------- | ----- | --------- | ----------------- |
1090| 0 | w | int | 0 | |
1091| 1 | h | int | 0 | |
1092| 11 | d | int | 0 | |
1093| 2 | c | int | 0 | |
1094
1095# InstanceNorm
1096```
1097split x along channel axis into instance x0, x1 ...
1098l2 normalize for each channel instance x0, x1 ...
1099y = x * gamma + beta
1100```
1101
1102* one_blob_only
1103* support_inplace
1104
1105| param id | name | type | default | description |
1106| --------- | ------------- | ----- | --------- | ----------------- |
1107| 0 | channels | int | 0 | |
1108| 1 | eps | float | 0.001f | x = x / sqrt(var + eps) |
1109| 2 | affine | int | 1 | |
1110
1111| weight | type | shape |
1112| ------------- | ----- | --------------------- |
1113| gamma_data | float | [channels] |
1114| beta_data | float | [channels] |
1115
1116# Interp
1117```
1118if dynamic_target_size == 0 y = resize(x) by fixed size or scale
1119else y = resize(x0, size(x1))
1120```
1121
1122* one_blob_only if dynamic_target_size == 0
1123
1124| param id | name | type | default | description |
1125| --------- | ------------- | ----- | --------- | ----------------- |
1126| 0 | resize_type | int | 0 | |
1127| 1 | height_scale | float | 1.f | |
1128| 2 | width_scale | float | 1.f | |
1129| 3 | output_height | int | 0 | |
1130| 4 | output_width | int | 0 | |
1131| 5 | dynamic_target_size| int | 0 | |
1132| 6 | align_corner | int | 0 | |
1133
1134Resize type:
1135- 1 = Nearest
1136- 2 = Bilinear
1137- 3 = Bicubic
1138
1139# LayerNorm
1140```
1141split x along outmost axis into part x0, x1 ...
1142l2 normalize for each part x0, x1 ...
1143y = x * gamma + beta by elementwise
1144```
1145
1146* one_blob_only
1147* support_inplace
1148
1149| param id | name | type | default | description |
1150| --------- | ------------- | ----- | --------- | ----------------- |
1151| 0 | affine_size | int | 0 | |
1152| 1 | eps | float | 0.001f | x = x / sqrt(var + eps) |
1153| 2 | affine | int | 1 | |
1154
1155| weight | type | shape |
1156| ------------- | ----- | --------------------- |
1157| gamma_data | float | [affine_size] |
1158| beta_data | float | [affine_size] |
1159
1160# Log
1161```
1162if base == -1 y = log(shift + x * scale)
1163else y = log(shift + x * scale) / log(base)
1164```
1165
1166* one_blob_only
1167* support_inplace
1168
1169| param id | name | type | default | description |
1170| --------- | ------------- | ----- | --------- | ----------------- |
1171| 0 | base | float | -1.f | |
1172| 1 | scale | float | 1.f | |
1173| 2 | shift | float | 0.f | |
1174
1175# LRN
1176```
1177if region_type == ACROSS_CHANNELS square_sum = sum of channel window of local_size
1178if region_type == WITHIN_CHANNEL square_sum = sum of spatial window of local_size
1179y = x * pow(bias + alpha * square_sum / (local_size * local_size), -beta)
1180```
1181
1182* one_blob_only
1183* support_inplace
1184
1185| param id | name | type | default | description |
1186| --------- | ------------- | ----- | --------- | ----------------- |
1187| 0 | region_type | int | 0 | |
1188| 1 | local_size | int | 5 | |
1189| 2 | alpha | float | 1.f | |
1190| 3 | beta | float | 0.75f | |
1191| 4 | bias | float | 1.f | |
1192
1193Region type:
1194- 0 = ACROSS_CHANNELS
1195- 1 = WITHIN_CHANNEL
1196
1197# LSTM
1198Apply 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]`.
1199
1200```
1201y = lstm(x)
1202y0, hidden y1, cell y2 = lstm(x0, hidden x1, cell x2)
1203```
1204
1205* one_blob_only if bidirectional
1206
1207| param id | name | type | default | description |
1208| --------- | ------------- | ----- | --------- | ----------------- |
1209| 0 | num_output | int | 0 | output size of output |
1210| 1 | weight_data_size| int | 0 | total size of IFOG weight matrix |
1211| 2 | direction | int | 0 | 0=forward, 1=reverse, 2=bidirectional |
1212| 3 | hidden_size | int | num_output| hidden size |
1213
1214| weight | type | shape |
1215| ------------- | ----- | --------------------- |
1216| weight_xc_data| float/fp16/int8 | [input_size, hidden_size * 4, num_directions] |
1217| bias_c_data | float/fp16/int8 | [hidden_size, 4, num_directions] |
1218| weight_hc_data| float/fp16/int8 | [num_output, hidden_size * 4, num_directions] |
1219| weight_hr_data| float/fp16/int8 | [hidden_size, num_output, num_directions] |
1220
1221Direction flag:
1222- 0 = forward only
1223- 1 = reverse only
1224- 2 = bidirectional
1225
1226# MemoryData
1227```
1228y = data
1229```
1230
1231| param id | name | type | default | description |
1232| --------- | ------------- | ----- | --------- | ----------------- |
1233| 0 | w | int | 0 | |
1234| 1 | h | int | 0 | |
1235| 11 | d | int | 0 | |
1236| 2 | c | int | 0 | |
1237| 21 | load_type | int | 1 | 1=fp32 |
1238
1239| weight | type | shape |
1240| ------------- | ----- | --------------------- |
1241| data | float | [w, h, d, c] |
1242
1243# Mish
1244```
1245y = x * tanh(log(exp(x) + 1))
1246```
1247
1248* one_blob_only
1249* support_inplace
1250
1251# MultiHeadAttention
1252```
1253split q k v into num_head part q0, k0, v0, q1, k1, v1 ...
1254for each num_head part
1255 xq = affine(q) / (embed_dim / num_head)
1256 xk = affine(k)
1257 xv = affine(v)
1258 xqk = xq * xk
1259 xqk = xqk + attn_mask if attn_mask exists
1260 softmax_inplace(xqk)
1261 xqkv = xqk * xv
1262 merge xqkv to out
1263y = affine(out)
1264```
1265
1266| param id | name | type | default | description |
1267| --------- | ------------- | ----- | --------- | ----------------- |
1268| 0 | embed_dim | int | 0 | |
1269| 1 | num_heads | int | 1 | |
1270| 2 | weight_data_size| int | 0 | qdim = weight_data_size / embed_dim |
1271| 3 | kdim | int | embed_dim | |
1272| 4 | vdim | int | embed_dim | |
1273| 5 | attn_mask | int | 0 | |
1274| 6 | scale | float | 1.f / sqrt(embed_dim / num_heads) | |
1275
1276| weight | type | shape |
1277| ------------- | ----- | --------------------- |
1278| q_weight_data | float/fp16/int8 | [embed_dim * qdim] |
1279| q_bias_data | float | [embed_dim] |
1280| k_weight_data | float/fp16/int8 | [embed_dim * kdim] |
1281| k_bias_data | float | [embed_dim] |
1282| v_weight_data | float/fp16/int8 | [embed_dim * vdim] |
1283| v_bias_data | float | [embed_dim] |
1284| out_weight_data| float/fp16/int8 | [qdim * embed_dim] |
1285| out_bias_data | float | [qdim] |
1286
1287# MVN
1288```
1289if normalize_variance == 1 && across_channels == 1 y = (x - mean) / (sqrt(var) + eps) of whole blob
1290if normalize_variance == 1 && across_channels == 0 y = (x - mean) / (sqrt(var) + eps) of each channel
1291if normalize_variance == 0 && across_channels == 1 y = x - mean of whole blob
1292if normalize_variance == 0 && across_channels == 0 y = x - mean of each channel
1293```
1294
1295* one_blob_only
1296
1297| param id | name | type | default | description |
1298| --------- | ------------- | ----- | --------- | ----------------- |
1299| 0 | normalize_variance| int | 0 | |
1300| 1 | across_channels| int | 0 | |
1301| 2 | eps | float | 0.0001f | x = x / (sqrt(var) + eps) |
1302
1303# Noop
1304```
1305y = x
1306```
1307
1308# Normalize
1309```
1310if across_spatial == 1 && across_channel == 1 x2 = normalize(x) of whole blob
1311if across_spatial == 1 && across_channel == 0 x2 = normalize(x) of each channel
1312if across_spatial == 0 && across_channel == 1 x2 = normalize(x) of each position
1313y = x2 * scale
1314```
1315
1316* one_blob_only
1317* support_inplace
1318
1319| param id | name | type | default | description |
1320| --------- | ------------- | ----- | --------- | ----------------- |
1321| 0 | across_spatial| int | 0 | |
1322| 1 | channel_shared| int | 0 | |
1323| 2 | eps | float | 0.0001f | see eps mode |
1324| 3 | scale_data_size| int | 0 | |
1325| 4 | across_channel| int | 0 | |
1326| 9 | eps_mode | int | 0 | |
1327
1328| weight | type | shape |
1329| ------------- | ----- | --------------------- |
1330| scale_data | float | [scale_data_size] |
1331
1332Eps Mode:
1333- 0 = caffe/mxnet x = x / sqrt(var + eps)
1334- 1 = pytorch x = x / max(sqrt(var), eps)
1335- 2 = tensorflow x = x / sqrt(max(var, eps))
1336
1337# Packing
1338```
1339y = wrap_packing(x)
1340```
1341
1342* one_blob_only
1343
1344| param id | name | type | default | description |
1345| --------- | ------------- | ----- | --------- | ----------------- |
1346| 0 | out_elempack | int | 1 | |
1347| 1 | use_padding | int | 0 | |
1348| 2 | cast_type_from| int | 0 | |
1349| 3 | cast_type_to | int | 0 | |
1350| 4 | storage_type_from| int | 0 | |
1351| 5 | storage_type_to| int | 0 | |
1352
1353# Padding
1354```
1355y = pad(x, pads)
1356```
1357
1358| param id | name | type | default | description |
1359| --------- | ------------- | ---- | --------- | ----------------- |
1360| 0 | top | int | 0 | |
1361| 1 | bottom | int | 0 | |
1362| 2 | left | int | 0 | |
1363| 3 | right | int | 0 | |
1364| 4 | type | int | 0 | |
1365| 5 | value | float | 0 | |
1366| 6 | per_channel_pad_data_size| int | 0 | |
1367| 7 | front | int | stride_w | |
1368| 8 | behind | int | pad_left | |
1369
1370| weight | type | shape |
1371| ------------- | ----- | --------------------- |
1372| per_channel_pad_data| float | [per_channel_pad_data_size] |
1373
1374Padding type:
1375- 0 = CONSTANT
1376- 1 = REPLICATE
1377- 2 = REFLECT
1378
1379# Permute
1380```
1381y = reorder(x)
1382```
1383
1384| param id | name | type | default | description |
1385| --------- | ------------- | ---- | --------- | ----------------- |
1386| 0 | order_type | int | 0 | |
1387
1388Order Type:
1389- 0 = WH WHC WHDC
1390- 1 = HW HWC HWDC
1391- 2 = WCH WDHC
1392- 3 = CWH DWHC
1393- 4 = HCW HDWC
1394- 5 = CHW DHWC
1395- 6 = WHCD
1396- 7 = HWCD
1397- 8 = WCHD
1398- 9 = CWHD
1399- 10 = HCWD
1400- 11 = CHWD
1401- 12 = WDCH
1402- 13 = DWCH
1403- 14 = WCDH
1404- 15 = CWDH
1405- 16 = DCWH
1406- 17 = CDWH
1407- 18 = HDCW
1408- 19 = DHCW
1409- 20 = HCDW
1410- 21 = CHDW
1411- 22 = DCHW
1412- 23 = CDHW
1413
1414# PixelShuffle
1415```
1416if mode == 0 y = depth_to_space(x) where x channel order is sw-sh-outc
1417if mode == 1 y = depth_to_space(x) where x channel order is outc-sw-sh
1418```
1419
1420* one_blob_only
1421
1422| param id | name | type | default | description |
1423| --------- | ------------- | ---- | --------- | ----------------- |
1424| 0 | upscale_factor| int | 1 | |
1425| 1 | mode | int | 0 | |
1426
1427# Pooling
1428```
1429x2 = pad(x, pads)
1430x3 = pooling(x2, kernel, stride)
1431```
1432
1433| param id | name | type | default | description |
1434| --------- | --------------| ---- | --------- | ----------------- |
1435| 0 | pooling_type | int | 0 | |
1436| 1 | kernel_w | int | 0 | |
1437| 2 | stride_w | int | 1 | |
1438| 3 | pad_left | int | 0 | |
1439| 4 | global_pooling| int | 0 | |
1440| 5 | pad_mode | int | 0 | |
1441| 6 | avgpool_count_include_pad| int | 0 | |
1442| 7 | adaptive_pooling| int | 0 | |
1443| 8 | out_w | int | 0 | |
1444| 11 | kernel_h | int | kernel_w | |
1445| 12 | stride_h | int | stride_w | |
1446| 13 | pad_top | int | pad_left | |
1447| 14 | pad_right | int | pad_left | |
1448| 15 | pad_bottom | int | pad_top | |
1449| 18 | out_h | int | out_w | |
1450
1451Pooling type:
1452- 0 = MAX
1453- 1 = AVG
1454
1455Pad mode:
1456- 0 = full padding
1457- 1 = valid padding
1458- 2 = tensorflow padding=SAME or onnx padding=SAME_UPPER
1459- 3 = onnx padding=SAME_LOWER
1460
1461# Pooling1D
1462```
1463x2 = pad(x, pads)
1464x3 = pooling1d(x2, kernel, stride)
1465```
1466
1467| param id | name | type | default | description |
1468| --------- | --------------| ---- | --------- | ----------------- |
1469| 0 | pooling_type | int | 0 | |
1470| 1 | kernel_w | int | 0 | |
1471| 2 | stride_w | int | 1 | |
1472| 3 | pad_left | int | 0 | |
1473| 4 | global_pooling| int | 0 | |
1474| 5 | pad_mode | int | 0 | |
1475| 6 | avgpool_count_include_pad| int | 0 | |
1476| 7 | adaptive_pooling| int | 0 | |
1477| 8 | out_w | int | 0 | |
1478| 14 | pad_right | int | pad_left | |
1479
1480Pooling type:
1481- 0 = MAX
1482- 1 = AVG
1483
1484Pad mode:
1485- 0 = full padding
1486- 1 = valid padding
1487- 2 = tensorflow padding=SAME or onnx padding=SAME_UPPER
1488- 3 = onnx padding=SAME_LOWER
1489
1490# Pooling3D
1491```
1492x2 = pad(x, pads)
1493x3 = pooling3d(x2, kernel, stride)
1494```
1495
1496| param id | name | type | default | description |
1497| --------- | --------------| ---- | --------- | ----------------- |
1498| 0 | pooling_type | int | 0 | |
1499| 1 | kernel_w | int | 0 | |
1500| 2 | stride_w | int | 1 | |
1501| 3 | pad_left | int | 0 | |
1502| 4 | global_pooling| int | 0 | |
1503| 5 | pad_mode | int | 0 | |
1504| 6 | avgpool_count_include_pad| int | 0 | |
1505| 7 | adaptive_pooling| int | 0 | |
1506| 8 | out_w | int | 0 | |
1507| 11 | kernel_h | int | kernel_w | |
1508| 12 | stride_h | int | stride_w | |
1509| 13 | pad_top | int | pad_left | |
1510| 14 | pad_right | int | pad_left | |
1511| 15 | pad_bottom | int | pad_top | |
1512| 16 | pad_behind | int | pad_front | |
1513| 18 | out_h | int | out_w | |
1514| 21 | kernel_d | int | kernel_w | |
1515| 22 | stride_d | int | stride_w | |
1516| 23 | pad_front | int | pad_left | |
1517| 28 | out_d | int | out_w | |
1518
1519Pooling type:
1520- 0 = MAX
1521- 1 = AVG
1522
1523Pad mode:
1524- 0 = full padding
1525- 1 = valid padding
1526- 2 = tensorflow padding=SAME or onnx padding=SAME_UPPER
1527- 3 = onnx padding=SAME_LOWER
1528
1529# Power
1530```
1531y = pow((shift + x * scale), power)
1532```
1533
1534* one_blob_only
1535* support_inplace
1536
1537| param id | name | type | default | description |
1538| --------- | ------------- | ----- | --------- | ----------------- |
1539| 0 | power | float | 1.f | |
1540| 1 | scale | float | 1.f | |
1541| 2 | shift | float | 0.f | |
1542
1543# PReLU
1544```
1545if x < 0 y = x * slope
1546else y = x
1547```
1548
1549* one_blob_only
1550* support_inplace
1551
1552| param id | name | type | default | description |
1553| --------- | ------------- | ----- | --------- | ----------------- |
1554| 0 | num_slope | int | 0 | |
1555
1556| weight | type | shape |
1557| ------------- | ----- | --------------------- |
1558| slope_data | float | [num_slope] |
1559
1560# Quantize
1561```
1562y = float2int8(x * scale)
1563```
1564
1565* one_blob_only
1566
1567| param id | name | type | default | description |
1568| --------- | ------------- | ----- | --------- | ----------------- |
1569| 0 | scale_data_size| int | 1 | |
1570
1571| weight | type | shape |
1572| ------------- | ----- | --------------------- |
1573| scale_data | float | [scale_data_size] |
1574
1575# Reduction
1576```
1577y = reduce_op(x * coeff)
1578```
1579
1580* one_blob_only
1581
1582| param id | name | type | default | description |
1583| --------- | ------------- | ----- | --------- | ----------------- |
1584| 0 | operation | int | 0 | |
1585| 1 | reduce_all | int | 1 | |
1586| 2 | coeff | float | 1.f | |
1587| 3 | axes | array | [ ] | |
1588| 4 | keepdims | int | 0 | |
1589| 5 | fixbug0 | int | 0 | hack for bug fix, should be 1 |
1590
1591Operation type:
1592- 0 = SUM
1593- 1 = ASUM
1594- 2 = SUMSQ
1595- 3 = MEAN
1596- 4 = MAX
1597- 5 = MIN
1598- 6 = PROD
1599- 7 = L1
1600- 8 = L2
1601- 9 = LogSum
1602- 10 = LogSumExp
1603
1604# ReLU
1605```
1606if x < 0 y = x * slope
1607else y = x
1608```
1609
1610* one_blob_only
1611* support_inplace
1612
1613| param id | name | type | default | description |
1614| --------- | ------------- | ----- | --------- | ----------------- |
1615| 0 | slope | float | 0.f | |
1616
1617# Reorg
1618```
1619if mode == 0 y = space_to_depth(x) where x channel order is sw-sh-outc
1620if mode == 1 y = space_to_depth(x) where x channel order is outc-sw-sh
1621```
1622
1623* one_blob_only
1624
1625| param id | name | type | default | description |
1626| --------- | ------------- | ---- | --------- | ----------------- |
1627| 0 | stride | int | 1 | |
1628| 1 | mode | int | 0 | |
1629
1630# Requantize
1631```
1632x2 = x * scale_in + bias
1633x3 = activation(x2)
1634y = float2int8(x3 * scale_out)
1635```
1636
1637* one_blob_only
1638
1639| param id | name | type | default | description |
1640| --------- | ------------- | ----- | --------- | ----------------- |
1641| 0 | scale_in_data_size| int | 1 | |
1642| 1 | scale_out_data_size| int | 1 | |
1643| 2 | bias_data_size| int | 0 | |
1644| 3 | activation_type| int | 0 | |
1645| 4 | activation_params| int | [ ] | |
1646
1647| weight | type | shape |
1648| ------------- | ----- | --------------------- |
1649| scale_in_data | float | [scale_in_data_size] |
1650| scale_out_data| float | [scale_out_data_size] |
1651| bias_data | float | [bias_data_size] |
1652
1653# Reshape
1654```
1655if permute == 1 y = hwc2chw(reshape(chw2hwc(x)))
1656else y = reshape(x)
1657```
1658
1659* one_blob_only
1660
1661| param id | name | type | default | description |
1662| --------- | ------------- | ----- | --------- | ----------------- |
1663| 0 | w | int | -233 | |
1664| 1 | h | int | -233 | |
1665| 11 | d | int | -233 | |
1666| 2 | c | int | -233 | |
1667| 3 | permute | int | 0 | |
1668
1669Reshape flag:
1670- 0 = copy from bottom
1671- -1 = remaining
1672- -233 = drop this dim(default)
1673
1674# RMSNorm
1675```
1676split x along outmost axis into part x0, x1 ...
1677root mean square normalize for each part x0, x1 ...
1678y = x * gamma by elementwise
1679```
1680
1681* one_blob_only
1682* support_inplace
1683
1684| param id | name | type | default | description |
1685| --------- | ------------- | ----- | --------- | ----------------- |
1686| 0 | affine_size | int | 0 | |
1687| 1 | eps | float | 0.001f | x = x / sqrt(var + eps) |
1688| 2 | affine | int | 1 | |
1689
1690| weight | type | shape |
1691| ------------- | ----- | --------------------- |
1692| gamma_data | float | [affine_size] |
1693
1694# RNN
1695Apply 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]`.
1696
1697```
1698y = rnn(x)
1699y0, hidden y1 = rnn(x0, hidden x1)
1700```
1701
1702* one_blob_only if bidirectional
1703
1704| param id | name | type | default | description |
1705| --------- | ------------- | ----- | --------- | ----------------- |
1706| 0 | num_output | int | 0 | hidden size of output |
1707| 1 | weight_data_size| int | 0 | total size of weight matrix |
1708| 2 | direction | int | 0 | 0=forward, 1=reverse, 2=bidirectional |
1709
1710| weight | type | shape |
1711| ------------- | ----- | --------------------- |
1712| weight_xc_data| float/fp16/int8 | [input_size, num_output, num_directions] |
1713| bias_c_data | float/fp16/int8 | [num_output, 1, num_directions] |
1714| weight_hc_data| float/fp16/int8 | [num_output, num_output, num_directions] |
1715
1716Direction flag:
1717- 0 = forward only
1718- 1 = reverse only
1719- 2 = bidirectional
1720
1721# Scale
1722```
1723if scale_data_size == -233 y = x0 * x1
1724else y = x * scale + bias
1725```
1726
1727* one_blob_only if scale_data_size != -233
1728* support_inplace
1729
1730| param id | name | type | default | description |
1731| --------- | ------------- | ----- | --------- | ----------------- |
1732| 0 | scale_data_size| int | 0 | |
1733| 1 | bias_term | int | 0 | |
1734
1735| weight | type | shape |
1736| ------------- | ----- | --------------------- |
1737| scale_data | float | [scale_data_size] |
1738| bias_data | float | [scale_data_size] |
1739
1740# SELU
1741```
1742if x < 0 y = (exp(x) - 1.f) * alpha * lambda
1743else y = x * lambda
1744```
1745
1746* one_blob_only
1747* support_inplace
1748
1749| param id | name | type | default | description |
1750| --------- | ------------- | ----- | --------- | ----------------- |
1751| 0 | alpha | float | 1.67326324f| |
1752| 1 | lambda | float | 1.050700987f| |
1753
1754# Shrink
1755```
1756if x < -lambd y = x + bias
1757if x > lambd y = x - bias
1758else y = x
1759```
1760
1761* one_blob_only
1762* support_inplace
1763
1764| param id | name | type | default | description |
1765| --------- | ------------- | ----- | --------- | ----------------- |
1766| 0 | bias | float | 0.0f | |
1767| 1 | lambd | float | 0.5f | |
1768
1769# ShuffleChannel
1770```
1771if reverse == 0 y = shufflechannel(x) by group
1772if reverse == 1 y = shufflechannel(x) by channel / group
1773```
1774
1775* one_blob_only
1776
1777| param id | name | type | default | description |
1778| --------- | ------------- | ---- | --------- | ----------------- |
1779| 0 | group | int | 1 | |
1780| 1 | reverse | int | 0 | |
1781
1782# Sigmoid
1783```
1784y = 1 / (1 + exp(-x))
1785```
1786
1787* one_blob_only
1788* support_inplace
1789
1790# Slice
1791```
1792split x along axis into slices, each part slice size is based on slices array
1793```
1794
1795| param id | name | type | default | description |
1796| --------- | ------------- | ----- | --------- | ----------------- |
1797| 0 | slices | array | [ ] | |
1798| 1 | axis | int | 0 | |
1799| 2 | indices | array | [ ] | |
1800
1801# Softmax
1802```
1803softmax(x, axis)
1804```
1805
1806* one_blob_only
1807* support_inplace
1808
1809| param id | name | type | default | description |
1810| --------- | ------------- | ----- | --------- | ----------------- |
1811| 0 | axis | int | 0 | |
1812| 1 | fixbug0 | int | 0 | hack for bug fix, should be 1 |
1813
1814# Softplus
1815```
1816y = log(exp(x) + 1)
1817```
1818
1819* one_blob_only
1820* support_inplace
1821
1822# Split
1823```
1824y0, y1 ... = x
1825```
1826
1827# Swish
1828```
1829y = x / (1 + exp(-x))
1830```
1831
1832* one_blob_only
1833* support_inplace
1834
1835# TanH
1836```
1837y = tanh(x)
1838```
1839
1840* one_blob_only
1841* support_inplace
1842
1843# Threshold
1844```
1845if x > threshold y = 1
1846else y = 0
1847```
1848
1849* one_blob_only
1850* support_inplace
1851
1852| param id | name | type | default | description |
1853| --------- | ------------- | ----- | --------- | ----------------- |
1854| 0 | threshold | float | 0.f | |
1855
1856# Tile
1857```
1858y = repeat tiles along axis for x
1859```
1860
1861* one_blob_only
1862
1863| param id | name | type | default | description |
1864| --------- | ------------- | ----- | --------- | ----------------- |
1865| 0 | axis | int | 0 | |
1866| 1 | tiles | int | 1 | |
1867| 2 | repeats | array | [ ] | |
1868
1869# UnaryOp
1870```
1871y = unaryop(x)
1872```
1873
1874- one_blob_only
1875- support_inplace
1876
1877| param id | name | type | default | description |
1878| --------- | ------------- | ----- | --------- | ----------------- |
1879| 0 | op_type | int | 0 | Operation type as follows |
1880
1881Operation type:
1882- 0 = ABS
1883- 1 = NEG
1884- 2 = FLOOR
1885- 3 = CEIL
1886- 4 = SQUARE
1887- 5 = SQRT
1888- 6 = RSQ
1889- 7 = EXP
1890- 8 = LOG
1891- 9 = SIN
1892- 10 = COS
1893- 11 = TAN
1894- 12 = ASIN
1895- 13 = ACOS
1896- 14 = ATAN
1897- 15 = RECIPROCAL
1898- 16 = TANH
1899- 17 = LOG10
1900- 18 = ROUND
1901- 19 = TRUNC
1902
1903# Unfold
1904```
1905y = unfold(x)
1906```
1907
1908* one_blob_only
1909
1910| param id | name | type | default | description |
1911| --------- | ------------- | ----- | --------- | ----------------- |
1912| 0 | num_output | int | 0 | |
1913| 1 | kernel_w | int | 0 | |
1914| 2 | dilation_w | int | 1 | |
1915| 3 | stride_w | int | 1 | |
1916| 4 | pad_left | int | 0 | |
1917| 11 | kernel_h | int | kernel_w | |
1918| 12 | dilation_h | int | dilation_w | |
1919| 13 | stride_h | int | stride_w | |
1920| 14 | pad_top | int | pad_left | |
1921| 15 | pad_right | int | pad_left | |
1922| 16 | pad_bottom | int | pad_top | |