You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

operators.md 62 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675
  1. * [AbsVal](#absval)
  2. * [ArgMax](#argmax)
  3. * [BatchNorm](#batchnorm)
  4. * [Bias](#bias)
  5. * [BinaryOp](#binaryop)
  6. * [BNLL](#bnll)
  7. * [Cast](#cast)
  8. * [Clip](#clip)
  9. * [Concat](#concat)
  10. * [Convolution](#convolution)
  11. * [Convolution1D](#convolution1d)
  12. * [Convolution3D](#convolution3d)
  13. * [ConvolutionDepthWise](#convolutiondepthwise)
  14. * [ConvolutionDepthWise1D](#convolutiondepthwise1d)
  15. * [ConvolutionDepthWise3D](#convolutiondepthwise3d)
  16. * [Crop](#crop)
  17. * [Deconvolution](#deconvolution)
  18. * [Deconvolution1D](#deconvolution1d)
  19. * [Deconvolution3D](#deconvolution3d)
  20. * [DeconvolutionDepthWise](#deconvolutiondepthwise)
  21. * [DeconvolutionDepthWise1D](#deconvolutiondepthwise1d)
  22. * [DeconvolutionDepthWise3D](#deconvolutiondepthwise3d)
  23. * [DeformableConv2D](#deformableconv2d)
  24. * [Dequantize](#dequantize)
  25. * [Dropout](#dropout)
  26. * [Eltwise](#eltwise)
  27. * [ELU](#elu)
  28. * [Exp](#exp)
  29. * [Flatten](#flatten)
  30. * [GELU](#gelu)
  31. * [Gemm](#gemm)
  32. * [GroupNorm](#groupnorm)
  33. * [GRU](#gru)
  34. * [HardSigmoid](#hardsigmoid)
  35. * [HardSwish](#hardswish)
  36. * [InnerProduct](#innerproduct)
  37. * [Input](#input)
  38. * [InstanceNorm](#instancenorm)
  39. * [Interp](#interp)
  40. * [LayerNorm](#layernorm)
  41. * [Log](#log)
  42. * [LRN](#lrn)
  43. * [LSTM](#lstm)
  44. * [MemoryData](#memorydata)
  45. * [Mish](#mish)
  46. * [MultiHeadAttention](#multiheadattention)
  47. * [MVN](#mvn)
  48. * [Noop](#noop)
  49. * [Normalize](#normalize)
  50. * [Packing](#packing)
  51. * [Padding](#padding)
  52. * [Permute](#permute)
  53. * [PixelShuffle](#pixelshuffle)
  54. * [Pooling](#pooling)
  55. * [Pooling1D](#pooling1d)
  56. * [Pooling3D](#pooling3d)
  57. * [Power](#power)
  58. * [PReLU](#prelu)
  59. * [Quantize](#quantize)
  60. * [Reduction](#reduction)
  61. * [ReLU](#relu)
  62. * [Reorg](#reorg)
  63. * [Requantize](#requantize)
  64. * [Reshape](#reshape)
  65. * [RNN](#rnn)
  66. * [Scale](#scale)
  67. * [SELU](#selu)
  68. * [ShuffleChannel](#shufflechannel)
  69. * [Sigmoid](#sigmoid)
  70. * [Slice](#slice)
  71. * [Softmax](#softmax)
  72. * [Softplus](#softplus)
  73. * [Split](#split)
  74. * [Swish](#swish)
  75. * [TanH](#tanh)
  76. * [Threshold](#threshold)
  77. * [Tile](#tile)
  78. * [UnaryOp](#unaryop)
  79. # AbsVal
  80. ```
  81. y = abs(x)
  82. ```
  83. * one_blob_only
  84. * support_inplace
  85. # ArgMax
  86. ```
  87. y = argmax(x, out_max_val, topk)
  88. ```
  89. * one_blob_only
  90. | param id | name | type | default | description |
  91. | --------- | ------------- | ----- | --------- | ----------------- |
  92. | 0 | out_max_val | int | 0 | |
  93. | 1 | topk | int | 1 | |
  94. # BatchNorm
  95. ```
  96. y = (x - mean) / sqrt(var + eps) * slope + bias
  97. ```
  98. * one_blob_only
  99. * support_inplace
  100. | param id | name | type | default | description |
  101. | --------- | ------------- | ----- | --------- | ----------------- |
  102. | 0 | channels | int | 0 | |
  103. | 1 | eps | float | 0.f | |
  104. | weight | type | shape |
  105. | ------------- | ----- | --------------------- |
  106. | slope_data | float | [channels] |
  107. | mean_data | float | [channels] |
  108. | var_data | float | [channels] |
  109. | bias_data | float | [channels] |
  110. # Bias
  111. ```
  112. y = x + bias
  113. ```
  114. * one_blob_only
  115. * support_inplace
  116. | param id | name | type | default | description |
  117. | --------- | ------------- | ----- | --------- | ----------------- |
  118. | 0 | bias_data_size| int | 0 | |
  119. | weight | type | shape |
  120. | ------------- | ----- | --------------------- |
  121. | bias_data | float | [channels] |
  122. # BinaryOp
  123. This operation is used for binary computation, and the calculation rule depends on the [broadcasting rule](https://github.com/Tencent/ncnn/wiki/binaryop-broadcasting).
  124. ```
  125. C = binaryop(A, B)
  126. ```
  127. if with_scalar = 1:
  128. - one_blob_only
  129. - support_inplace
  130. | param id | name | type | default | description |
  131. | --------- | ------------- | ----- | --------- | ----------------- |
  132. | 0 | op_type | int | 0 | Operation type as follows |
  133. | 1 | with_scalar | int | 0 | with_scalar=0 B is a matrix, with_scalar=1 B is a scalar |
  134. | 2 | b | float | 0.f | When B is a scalar, B = b |
  135. Operation type:
  136. - 0 = ADD
  137. - 1 = SUB
  138. - 2 = MUL
  139. - 3 = DIV
  140. - 4 = MAX
  141. - 5 = MIN
  142. - 6 = POW
  143. - 7 = RSUB
  144. - 8 = RDIV
  145. # BNLL
  146. ```
  147. y = log(1 + e^(-x)) , x > 0
  148. y = log(1 + e^x), x < 0
  149. ```
  150. * one_blob_only
  151. * support_inplace
  152. # Cast
  153. ```
  154. y = cast(x)
  155. ```
  156. * one_blob_only
  157. * support_packing
  158. | param id | name | type | default | description |
  159. | --------- | ------------- | ----- | --------- | ----------------- |
  160. | 0 | type_from | int | 0 | |
  161. | 1 | type_to | int | 0 | |
  162. Element type:
  163. - 0 = auto
  164. - 1 = float32
  165. - 2 = float16
  166. - 3 = int8
  167. - 4 = bfloat16
  168. # Clip
  169. ```
  170. y = clamp(x, min, max)
  171. ```
  172. * one_blob_only
  173. * support_inplace
  174. | param id | name | type | default | description |
  175. | --------- | ------------- | ----- | --------- | ----------------- |
  176. | 0 | min | float | -FLT_MAX | |
  177. | 1 | max | float | FLT_MAX | |
  178. # Concat
  179. ```
  180. y = concat(x0, x1, x2, ...) by axis
  181. ```
  182. | param id | name | type | default | description |
  183. | --------- | ------------- | ----- | --------- | ----------------- |
  184. | 0 | axis | int | 0 | |
  185. # Convolution
  186. ```
  187. x2 = pad(x, pads, pad_value)
  188. x3 = conv(x2, weight, kernel, stride, dilation) + bias
  189. y = activation(x3, act_type, act_params)
  190. ```
  191. * one_blob_only
  192. | param id | name | type | default | description |
  193. | --------- | ------------- | ----- | --------- | ----------------- |
  194. | 0 | num_output | int | 0 | |
  195. | 1 | kernel_w | int | 0 | |
  196. | 2 | dilation_w | int | 1 | |
  197. | 3 | stride_w | int | 1 | |
  198. | 4 | pad_left | int | 0 | |
  199. | 5 | bias_term | int | 0 | |
  200. | 6 | weight_data_size| int | 0 | |
  201. | 8 | int8_scale_term| int | 0 | |
  202. | 9 | activation_type| int | 0 | |
  203. | 10 | activation_params| array | [ ] | |
  204. | 11 | kernel_h | int | kernel_w | |
  205. | 12 | dilation_h | int | dilation_w | |
  206. | 13 | stride_h | int | stride_w | |
  207. | 14 | pad_top | int | pad_left | |
  208. | 15 | pad_right | int | pad_left | |
  209. | 16 | pad_bottom | int | pad_top | |
  210. | 18 | pad_value | float | 0.f | |
  211. | 19 | dynamic_weight| int | 0 | |
  212. | weight | type | shape |
  213. | ------------- | ----- | --------------------- |
  214. | weight_data | float/fp16/int8 | [kernel_w, kernel_h, num_input, num_output] |
  215. | bias_data | float | [num_output] |
  216. | weight_data_int8_scales| float | [num_output] |
  217. | bottom_blob_int8_scales| float | [1] |
  218. | top_blob_int8_scales| float | [1] |
  219. # Convolution1D
  220. ```
  221. x2 = pad(x, pads, pad_value)
  222. x3 = conv1d(x2, weight, kernel, stride, dilation) + bias
  223. y = activation(x3, act_type, act_params)
  224. ```
  225. * one_blob_only
  226. | param id | name | type | default | description |
  227. | --------- | ------------- | ----- | --------- | ----------------- |
  228. | 0 | num_output | int | 0 | |
  229. | 1 | kernel_w | int | 0 | |
  230. | 2 | dilation_w | int | 1 | |
  231. | 3 | stride_w | int | 1 | |
  232. | 4 | pad_left | int | 0 | |
  233. | 5 | bias_term | int | 0 | |
  234. | 6 | weight_data_size| int | 0 | |
  235. | 9 | activation_type| int | 0 | |
  236. | 10 | activation_params| array | [ ] | |
  237. | 15 | pad_right | int | pad_left | |
  238. | 18 | pad_value | float | 0.f | |
  239. | 19 | dynamic_weight| int | 0 | |
  240. | weight | type | shape |
  241. | ------------- | ----- | --------------------- |
  242. | weight_data | float/fp16/int8 | [kernel_w, num_input, num_output] |
  243. | bias_data | float | [num_output] |
  244. # Convolution3D
  245. ```
  246. x2 = pad(x, pads, pad_value)
  247. x3 = conv3d(x2, weight, kernel, stride, dilation) + bias
  248. y = activation(x3, act_type, act_params)
  249. ```
  250. * one_blob_only
  251. | param id | name | type | default | description |
  252. | --------- | ------------- | ----- | --------- | ----------------- |
  253. | 0 | num_output | int | 0 | |
  254. | 1 | kernel_w | int | 0 | |
  255. | 2 | dilation_w | int | 1 | |
  256. | 3 | stride_w | int | 1 | |
  257. | 4 | pad_left | int | 0 | |
  258. | 5 | bias_term | int | 0 | |
  259. | 6 | weight_data_size| 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. | 17 | pad_behind | int | pad_front | |
  269. | 18 | pad_value | float | 0.f | |
  270. | 21 | kernel_d | int | kernel_w | |
  271. | 22 | dilation_d | int | dilation_w | |
  272. | 23 | stride_d | int | stride_w | |
  273. | 24 | pad_front | int | pad_left | |
  274. | weight | type | shape |
  275. | ------------- | ----- | --------------------- |
  276. | weight_data | float/fp16/int8 | [kernel_w, kernel_h, kernel_d, num_input, num_output] |
  277. | bias_data | float | [num_output] |
  278. # ConvolutionDepthWise
  279. ```
  280. x2 = pad(x, pads, pad_value)
  281. x3 = conv(x2, weight, kernel, stride, dilation, group) + bias
  282. y = activation(x3, act_type, act_params)
  283. ```
  284. * one_blob_only
  285. | param id | name | type | default | description |
  286. | --------- | ------------- | ----- | --------- | ----------------- |
  287. | 0 | num_output | int | 0 | |
  288. | 1 | kernel_w | int | 0 | |
  289. | 2 | dilation_w | int | 1 | |
  290. | 3 | stride_w | int | 1 | |
  291. | 4 | pad_left | int | 0 | |
  292. | 5 | bias_term | int | 0 | |
  293. | 6 | weight_data_size| int | 0 | |
  294. | 7 | group | int | 1 | |
  295. | 8 | int8_scale_term| int | 0 | |
  296. | 9 | activation_type| int | 0 | |
  297. | 10 | activation_params| array | [ ] | |
  298. | 11 | kernel_h | int | kernel_w | |
  299. | 12 | dilation_h | int | dilation_w | |
  300. | 13 | stride_h | int | stride_w | |
  301. | 14 | pad_top | int | pad_left | |
  302. | 15 | pad_right | int | pad_left | |
  303. | 16 | pad_bottom | int | pad_top | |
  304. | 18 | pad_value | float | 0.f | |
  305. | 19 | dynamic_weight| int | 0 | |
  306. | weight | type | shape |
  307. | ------------- | ----- | --------------------- |
  308. | weight_data | float/fp16/int8 | [kernel_w, kernel_h, num_input / group, num_output / group, group] |
  309. | bias_data | float | [num_output] |
  310. | weight_data_int8_scales| float | [group] |
  311. | bottom_blob_int8_scales| float | [1] |
  312. | top_blob_int8_scales| float | [1] |
  313. # ConvolutionDepthWise1D
  314. ```
  315. x2 = pad(x, pads, pad_value)
  316. x3 = conv1d(x2, weight, kernel, stride, dilation, group) + bias
  317. y = activation(x3, act_type, act_params)
  318. ```
  319. * one_blob_only
  320. | param id | name | type | default | description |
  321. | --------- | ------------- | ----- | --------- | ----------------- |
  322. | 0 | num_output | int | 0 | |
  323. | 1 | kernel_w | int | 0 | |
  324. | 2 | dilation_w | int | 1 | |
  325. | 3 | stride_w | int | 1 | |
  326. | 4 | pad_left | int | 0 | |
  327. | 5 | bias_term | int | 0 | |
  328. | 6 | weight_data_size| int | 0 | |
  329. | 7 | group | int | 1 | |
  330. | 9 | activation_type| int | 0 | |
  331. | 10 | activation_params| array | [ ] | |
  332. | 15 | pad_right | int | pad_left | |
  333. | 18 | pad_value | float | 0.f | |
  334. | 19 | dynamic_weight| int | 0 | |
  335. | weight | type | shape |
  336. | ------------- | ----- | --------------------- |
  337. | weight_data | float/fp16/int8 | [kernel_w, num_input / group, num_output / group, group] |
  338. | bias_data | float | [num_output] |
  339. # ConvolutionDepthWise3D
  340. ```
  341. x2 = pad(x, pads, pad_value)
  342. x3 = conv3d(x2, weight, kernel, stride, dilation, group) + bias
  343. y = activation(x3, act_type, act_params)
  344. ```
  345. * one_blob_only
  346. | param id | name | type | default | description |
  347. | --------- | ------------- | ----- | --------- | ----------------- |
  348. | 0 | num_output | int | 0 | |
  349. | 1 | kernel_w | int | 0 | |
  350. | 2 | dilation_w | int | 1 | |
  351. | 3 | stride_w | int | 1 | |
  352. | 4 | pad_left | int | 0 | |
  353. | 5 | bias_term | int | 0 | |
  354. | 6 | weight_data_size| int | 0 | |
  355. | 7 | group | int | 1 | |
  356. | 9 | activation_type| int | 0 | |
  357. | 10 | activation_params| array | [ ] | |
  358. | 11 | kernel_h | int | kernel_w | |
  359. | 12 | dilation_h | int | dilation_w | |
  360. | 13 | stride_h | int | stride_w | |
  361. | 14 | pad_top | int | pad_left | |
  362. | 15 | pad_right | int | pad_left | |
  363. | 16 | pad_bottom | int | pad_top | |
  364. | 17 | pad_behind | int | pad_front | |
  365. | 18 | pad_value | float | 0.f | |
  366. | 21 | kernel_d | int | kernel_w | |
  367. | 22 | dilation_d | int | dilation_w | |
  368. | 23 | stride_d | int | stride_w | |
  369. | 24 | pad_front | int | pad_left | |
  370. | weight | type | shape |
  371. | ------------- | ----- | --------------------- |
  372. | weight_data | float/fp16/int8 | [kernel_w, kernel_h, kernel_d, num_input / group, num_output / group, group] |
  373. | bias_data | float | [num_output] |
  374. # Crop
  375. ```
  376. y = crop(x)
  377. ```
  378. * one_blob_only
  379. | param id | name | type | default | description |
  380. | --------- | ------------- | ----- | --------- | ----------------- |
  381. | 0 | woffset | int | 0 | |
  382. | 1 | hoffset | int | 0 | |
  383. | 2 | coffset | int | 1 | |
  384. | 3 | outw | int | 1 | |
  385. | 4 | outh | int | 0 | |
  386. | 5 | outc | int | 0 | |
  387. | 6 | woffset2 | int | 0 | |
  388. | 7 | hoffset2 | int | 1 | |
  389. | 8 | coffset2 | int | 0 | |
  390. | 9 | starts | array | [ ] | |
  391. | 10 | ends | array | [ ] | |
  392. | 11 | axes | array | [ ] | |
  393. # Deconvolution
  394. ```
  395. x2 = deconv(x, weight, kernel, stride, dilation) + bias
  396. x3 = depad(x2, pads, pad_value)
  397. y = activation(x3, act_type, act_params)
  398. ```
  399. * one_blob_only
  400. | param id | name | type | default | description |
  401. | --------- | ------------- | ----- | --------- | ----------------- |
  402. | 0 | num_output | int | 0 | |
  403. | 1 | kernel_w | int | 0 | |
  404. | 2 | dilation_w | int | 1 | |
  405. | 3 | stride_w | int | 1 | |
  406. | 4 | pad_left | int | 0 | |
  407. | 5 | bias_term | int | 0 | |
  408. | 6 | weight_data_size| int | 0 | |
  409. | 9 | activation_type| int | 0 | |
  410. | 10 | activation_params| array | [ ] | |
  411. | 11 | kernel_h | int | kernel_w | |
  412. | 12 | dilation_h | int | dilation_w | |
  413. | 13 | stride_h | int | stride_w | |
  414. | 14 | pad_top | int | pad_left | |
  415. | 15 | pad_right | int | pad_left | |
  416. | 16 | pad_bottom | int | pad_top | |
  417. | 18 | output_pad_right| int | 0 | |
  418. | 19 | output_pad_bottom| int | output_pad_right | |
  419. | 20 | output_w | int | 0 | |
  420. | 21 | output_h | int | output_w | |
  421. | weight | type | shape |
  422. | ------------- | ----- | --------------------- |
  423. | weight_data | float/fp16 | [kernel_w, kernel_h, num_input, num_output] |
  424. | bias_data | float | [num_output] |
  425. # Deconvolution1D
  426. ```
  427. x2 = deconv1d(x, weight, kernel, stride, dilation) + bias
  428. x3 = depad(x2, pads, pad_value)
  429. y = activation(x3, act_type, act_params)
  430. ```
  431. * one_blob_only
  432. | param id | name | type | default | description |
  433. | --------- | ------------- | ----- | --------- | ----------------- |
  434. | 0 | num_output | int | 0 | |
  435. | 1 | kernel_w | int | 0 | |
  436. | 2 | dilation_w | int | 1 | |
  437. | 3 | stride_w | int | 1 | |
  438. | 4 | pad_left | int | 0 | |
  439. | 5 | bias_term | int | 0 | |
  440. | 6 | weight_data_size| int | 0 | |
  441. | 9 | activation_type| int | 0 | |
  442. | 10 | activation_params| array | [ ] | |
  443. | 15 | pad_right | int | pad_left | |
  444. | 18 | output_pad_right| int | 0 | |
  445. | 20 | output_w | int | 0 | |
  446. | weight | type | shape |
  447. | ------------- | ----- | --------------------- |
  448. | weight_data | float/fp16 | [kernel_w, num_input, num_output] |
  449. | bias_data | float | [num_output] |
  450. # Deconvolution3D
  451. ```
  452. x2 = deconv3d(x, weight, kernel, stride, dilation) + bias
  453. x3 = depad(x2, pads, pad_value)
  454. y = activation(x3, act_type, act_params)
  455. ```
  456. * one_blob_only
  457. | param id | name | type | default | description |
  458. | --------- | ------------- | ----- | --------- | ----------------- |
  459. | 0 | num_output | int | 0 | |
  460. | 1 | kernel_w | int | 0 | |
  461. | 2 | dilation_w | int | 1 | |
  462. | 3 | stride_w | int | 1 | |
  463. | 4 | pad_left | int | 0 | |
  464. | 5 | bias_term | int | 0 | |
  465. | 6 | weight_data_size| int | 0 | |
  466. | 9 | activation_type| int | 0 | |
  467. | 10 | activation_params| array | [ ] | |
  468. | 11 | kernel_h | int | kernel_w | |
  469. | 12 | dilation_h | int | dilation_w | |
  470. | 13 | stride_h | int | stride_w | |
  471. | 14 | pad_top | int | pad_left | |
  472. | 15 | pad_right | int | pad_left | |
  473. | 16 | pad_bottom | int | pad_top | |
  474. | 17 | pad_behind | int | pad_front | |
  475. | 18 | output_pad_right| int | 0 | |
  476. | 19 | output_pad_bottom| int | output_pad_right | |
  477. | 20 | output_pad_behind| int | output_pad_right | |
  478. | 21 | kernel_d | int | kernel_w | |
  479. | 22 | dilation_d | int | dilation_w | |
  480. | 23 | stride_d | int | stride_w | |
  481. | 24 | pad_front | int | pad_left | |
  482. | 25 | output_w | int | 0 | |
  483. | 26 | output_h | int | output_w | |
  484. | 27 | output_d | int | output_w | |
  485. | weight | type | shape |
  486. | ------------- | ----- | --------------------- |
  487. | weight_data | float/fp16 | [kernel_w, kernel_h, kernel_d, num_input, num_output] |
  488. | bias_data | float | [num_output] |
  489. # DeconvolutionDepthWise
  490. ```
  491. x2 = deconv(x, weight, kernel, stride, dilation, group) + bias
  492. x3 = depad(x2, pads, pad_value)
  493. y = activation(x3, act_type, act_params)
  494. ```
  495. * one_blob_only
  496. | param id | name | type | default | description |
  497. | --------- | ------------- | ----- | --------- | ----------------- |
  498. | 0 | num_output | int | 0 | |
  499. | 1 | kernel_w | int | 0 | |
  500. | 2 | dilation_w | int | 1 | |
  501. | 3 | stride_w | int | 1 | |
  502. | 4 | pad_left | int | 0 | |
  503. | 5 | bias_term | int | 0 | |
  504. | 6 | weight_data_size| int | 0 | |
  505. | 7 | group | int | 1 | |
  506. | 9 | activation_type| int | 0 | |
  507. | 10 | activation_params| array | [ ] | |
  508. | 11 | kernel_h | int | kernel_w | |
  509. | 12 | dilation_h | int | dilation_w | |
  510. | 13 | stride_h | int | stride_w | |
  511. | 14 | pad_top | int | pad_left | |
  512. | 15 | pad_right | int | pad_left | |
  513. | 16 | pad_bottom | int | pad_top | |
  514. | 18 | output_pad_right| int | 0 | |
  515. | 19 | output_pad_bottom| int | output_pad_right | |
  516. | 20 | output_w | int | 0 | |
  517. | 21 | output_h | int | output_w | |
  518. | weight | type | shape |
  519. | ------------- | ----- | --------------------- |
  520. | weight_data | float/fp16 | [kernel_w, kernel_h, num_input / group, num_output / group, group] |
  521. | bias_data | float | [num_output] |
  522. # DeconvolutionDepthWise1D
  523. ```
  524. x2 = deconv1d(x, weight, kernel, stride, dilation, group) + bias
  525. x3 = depad(x2, pads, pad_value)
  526. y = activation(x3, act_type, act_params)
  527. ```
  528. * one_blob_only
  529. | param id | name | type | default | description |
  530. | --------- | ------------- | ----- | --------- | ----------------- |
  531. | 0 | num_output | int | 0 | |
  532. | 1 | kernel_w | int | 0 | |
  533. | 2 | dilation_w | int | 1 | |
  534. | 3 | stride_w | int | 1 | |
  535. | 4 | pad_left | int | 0 | |
  536. | 5 | bias_term | int | 0 | |
  537. | 6 | weight_data_size| int | 0 | |
  538. | 7 | group | int | 1 | |
  539. | 9 | activation_type| int | 0 | |
  540. | 10 | activation_params| array | [ ] | |
  541. | 15 | pad_right | int | pad_left | |
  542. | 18 | output_pad_right| int | 0 | |
  543. | 20 | output_w | int | 0 | |
  544. | weight | type | shape |
  545. | ------------- | ----- | --------------------- |
  546. | weight_data | float/fp16 | [kernel_w, num_input / group, num_output / group, group] |
  547. | bias_data | float | [num_output] |
  548. # DeconvolutionDepthWise3D
  549. ```
  550. x2 = deconv3d(x, weight, kernel, stride, dilation, group) + bias
  551. x3 = depad(x2, pads, pad_value)
  552. y = activation(x3, act_type, act_params)
  553. ```
  554. * one_blob_only
  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. | 7 | group | int | 1 | |
  565. | 9 | activation_type| int | 0 | |
  566. | 10 | activation_params| array | [ ] | |
  567. | 11 | kernel_h | int | kernel_w | |
  568. | 12 | dilation_h | int | dilation_w | |
  569. | 13 | stride_h | int | stride_w | |
  570. | 14 | pad_top | int | pad_left | |
  571. | 15 | pad_right | int | pad_left | |
  572. | 16 | pad_bottom | int | pad_top | |
  573. | 17 | pad_behind | int | pad_front | |
  574. | 18 | output_pad_right| int | 0 | |
  575. | 19 | output_pad_bottom| int | output_pad_right | |
  576. | 20 | output_pad_behind| int | output_pad_right | |
  577. | 21 | kernel_d | int | kernel_w | |
  578. | 22 | dilation_d | int | dilation_w | |
  579. | 23 | stride_d | int | stride_w | |
  580. | 24 | pad_front | int | pad_left | |
  581. | 25 | output_w | int | 0 | |
  582. | 26 | output_h | int | output_w | |
  583. | 27 | output_d | int | output_w | |
  584. | weight | type | shape |
  585. | ------------- | ----- | --------------------- |
  586. | weight_data | float/fp16 | [kernel_w, kernel_h, kernel_d, num_input / group, num_output / group, group] |
  587. | bias_data | float | [num_output] |
  588. # DeformableConv2D
  589. ```
  590. x2 = deformableconv2d(x, offset, mask, weight, kernel, stride, dilation) + bias
  591. y = activation(x2, act_type, act_params)
  592. ```
  593. | param id | name | type | default | description |
  594. | --------- | ------------- | ----- | --------- | ----------------- |
  595. | 0 | num_output | int | 0 | |
  596. | 1 | kernel_w | int | 0 | |
  597. | 2 | dilation_w | int | 1 | |
  598. | 3 | stride_w | int | 1 | |
  599. | 4 | pad_left | int | 0 | |
  600. | 5 | bias_term | int | 0 | |
  601. | 6 | weight_data_size| int | 0 | |
  602. | 9 | activation_type| int | 0 | |
  603. | 10 | activation_params| array | [ ] | |
  604. | 11 | kernel_h | int | kernel_w | |
  605. | 12 | dilation_h | int | dilation_w | |
  606. | 13 | stride_h | int | stride_w | |
  607. | 14 | pad_top | int | pad_left | |
  608. | 15 | pad_right | int | pad_left | |
  609. | 16 | pad_bottom | int | pad_top | |
  610. | weight | type | shape |
  611. | ------------- | ----- | --------------------- |
  612. | weight_data | float/fp16/int8 | [kernel_w, kernel_h, num_input, num_output] |
  613. | bias_data | float | [num_output] |
  614. # Dequantize
  615. ```
  616. y = x * scale + bias
  617. ```
  618. * one_blob_only
  619. * support_inplace
  620. | param id | name | type | default | description |
  621. | --------- | ------------- | ----- | --------- | ----------------- |
  622. | 0 | scale_data_size| int | 1 | |
  623. | 1 | bias_data_size| int | 0 | |
  624. | weight | type | shape |
  625. | ------------- | ----- | --------------------- |
  626. | scale_data | float | [scale_data_size] |
  627. | bias_data | float | [bias_data_size] |
  628. # Dropout
  629. ```
  630. y = x * scale
  631. ```
  632. * one_blob_only
  633. | param id | name | type | default | description |
  634. | --------- | ------------- | ----- | --------- | ----------------- |
  635. | 0 | scale | float | 1.f | |
  636. # Eltwise
  637. ```
  638. y = elementwise_op(x0, x1, ...)
  639. ```
  640. | param id | name | type | default | description |
  641. | --------- | ------------- | ----- | --------- | ----------------- |
  642. | 0 | op_type | int | 0 | |
  643. | 1 | coeffs | array | [ ] | |
  644. Operation type:
  645. - 0 = PROD
  646. - 1 = SUM
  647. - 2 = MAX
  648. # ELU
  649. ```
  650. if x < 0 y = (exp(x) - 1) * alpha
  651. else y = x
  652. ```
  653. * one_blob_only
  654. * support_inplace
  655. | param id | name | type | default | description |
  656. | --------- | ------------- | ----- | --------- | ----------------- |
  657. | 0 | alpha | float | 0.1f | |
  658. # Exp
  659. ```
  660. if base == -1 y = exp(shift + x * scale)
  661. else y = pow(base, (shift + x * scale))
  662. ```
  663. * one_blob_only
  664. * support_inplace
  665. | param id | name | type | default | description |
  666. | --------- | ------------- | ----- | --------- | ----------------- |
  667. | 0 | base | float | -1.f | |
  668. | 1 | scale | float | 1.f | |
  669. | 2 | shift | float | 0.f | |
  670. # Flatten
  671. Reshape blob to 1 dimension
  672. * one_blob_only
  673. # GELU
  674. ```
  675. if fast_gelu == 1 y = 0.5 * x * (1 + tanh(0.79788452 * (x + 0.044715 * x * x * x)));
  676. else y = 0.5 * x * erfc(-0.70710678 * x)
  677. ```
  678. * one_blob_only
  679. * support_inplace
  680. | param id | name | type | default | description |
  681. | --------- | ------------- | ----- | --------- | ----------------- |
  682. | 0 | fast_gelu | int | 0 | use approximation |
  683. # Gemm
  684. ```
  685. a = transA ? transpose(x0) : x0
  686. b = transb ? transpose(x1) : x1
  687. c = x2
  688. y = gemm(a, b) * alpha + c * beta
  689. ```
  690. | param id | name | type | default | description |
  691. | --------- | ------------- | ----- | --------- | ----------------- |
  692. | 0 | alpha | float | 1.f | |
  693. | 1 | beta | float | 1.f | |
  694. | 2 | transA | int | 0 | |
  695. | 3 | transb | int | 0 | |
  696. # GroupNorm
  697. ```
  698. split x along channel axis into group x0, x1 ...
  699. l2 normalize for each group x0, x1 ...
  700. y = x * gamma + beta
  701. ```
  702. * one_blob_only
  703. * support_inplace
  704. | param id | name | type | default | description |
  705. | --------- | ------------- | ----- | --------- | ----------------- |
  706. | 0 | group | int | 1 | |
  707. | 1 | channels | int | 0 | |
  708. | 2 | eps | float | 0.001f | x = x / sqrt(var + eps) |
  709. | 3 | affine | int | 1 | |
  710. | weight | type | shape |
  711. | ------------- | ----- | --------------------- |
  712. | gamma_data | float | [channels] |
  713. | beta_data | float | [channels] |
  714. # GRU
  715. Apply 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]`.
  716. ```
  717. y = gru(x)
  718. y0, hidden y1 = gru(x0, hidden x1)
  719. ```
  720. * one_blob_only if bidirectional
  721. | param id | name | type | default | description |
  722. | --------- | ------------- | ----- | --------- | ----------------- |
  723. | 0 | num_output | int | 0 | hidden size of output |
  724. | 1 | weight_data_size| int | 0 | total size of weight matrix |
  725. | 2 | direction | int | 0 | 0=forward, 1=reverse, 2=bidirectional |
  726. | weight | type | shape |
  727. | ------------- | ----- | --------------------- |
  728. | weight_xc_data| float/fp16/int8 | [input_size, num_output * 3, num_directions] |
  729. | bias_c_data | float/fp16/int8 | [num_output, 4, num_directions] |
  730. | weight_hc_data| float/fp16/int8 | [num_output, num_output * 3, num_directions] |
  731. Direction flag:
  732. - 0 = forward only
  733. - 1 = reverse only
  734. - 2 = bidirectional
  735. # HardSigmoid
  736. ```
  737. y = clamp(x * alpha + beta, 0, 1)
  738. ```
  739. * one_blob_only
  740. * support_inplace
  741. | param id | name | type | default | description |
  742. | --------- | ------------- | ----- | --------- | ----------------- |
  743. | 0 | alpha | float | 0.2f | |
  744. | 1 | beta | float | 0.5f | |
  745. # HardSwish
  746. ```
  747. y = x * clamp(x * alpha + beta, 0, 1)
  748. ```
  749. * one_blob_only
  750. * support_inplace
  751. | param id | name | type | default | description |
  752. | --------- | ------------- | ----- | --------- | ----------------- |
  753. | 0 | alpha | float | 0.2f | |
  754. | 1 | beta | float | 0.5f | |
  755. # InnerProduct
  756. ```
  757. x2 = innerproduct(x, weight) + bias
  758. y = activation(x2, act_type, act_params)
  759. ```
  760. * one_blob_only
  761. | param id | name | type | default | description |
  762. | --------- | ------------- | ----- | --------- | ----------------- |
  763. | 0 | num_output | int | 0 | |
  764. | 1 | bias_term | int | 0 | |
  765. | 2 | weight_data_size| int | 0 | |
  766. | 8 | int8_scale_term| int | 0 | |
  767. | 9 | activation_type| int | 0 | |
  768. | 10 | activation_params| array | [ ] | |
  769. | weight | type | shape |
  770. | ------------- | ----- | --------------------- |
  771. | weight_data | float/fp16/int8 | [num_input, num_output] |
  772. | bias_data | float | [num_output] |
  773. | weight_data_int8_scales| float | [num_output] |
  774. | bottom_blob_int8_scales| float | [1] |
  775. # Input
  776. ```
  777. y = input
  778. ```
  779. * support_inplace
  780. | param id | name | type | default | description |
  781. | --------- | ------------- | ----- | --------- | ----------------- |
  782. | 0 | w | int | 0 | |
  783. | 1 | h | int | 0 | |
  784. | 11 | d | int | 0 | |
  785. | 2 | c | int | 0 | |
  786. # InstanceNorm
  787. ```
  788. split x along channel axis into instance x0, x1 ...
  789. l2 normalize for each channel instance x0, x1 ...
  790. y = x * gamma + beta
  791. ```
  792. * one_blob_only
  793. * support_inplace
  794. | param id | name | type | default | description |
  795. | --------- | ------------- | ----- | --------- | ----------------- |
  796. | 0 | channels | int | 0 | |
  797. | 1 | eps | float | 0.001f | x = x / sqrt(var + eps) |
  798. | 2 | affine | int | 1 | |
  799. | weight | type | shape |
  800. | ------------- | ----- | --------------------- |
  801. | gamma_data | float | [channels] |
  802. | beta_data | float | [channels] |
  803. # Interp
  804. ```
  805. if dynamic_target_size == 0 y = resize(x) by fixed size or scale
  806. else y = resize(x0, size(x1))
  807. ```
  808. * one_blob_only if dynamic_target_size == 0
  809. | param id | name | type | default | description |
  810. | --------- | ------------- | ----- | --------- | ----------------- |
  811. | 0 | resize_type | int | 0 | |
  812. | 1 | height_scale | float | 1.f | |
  813. | 2 | width_scale | float | 1.f | |
  814. | 3 | output_height | int | 0 | |
  815. | 4 | output_width | int | 0 | |
  816. | 5 | dynamic_target_size| int | 0 | |
  817. | 6 | align_corner | int | 0 | |
  818. Resize type:
  819. - 1 = Nearest
  820. - 2 = Bilinear
  821. - 3 = Bicubic
  822. # LayerNorm
  823. ```
  824. split x along outmost axis into part x0, x1 ...
  825. l2 normalize for each part x0, x1 ...
  826. y = x * gamma + beta by elementwise
  827. ```
  828. * one_blob_only
  829. * support_inplace
  830. | param id | name | type | default | description |
  831. | --------- | ------------- | ----- | --------- | ----------------- |
  832. | 0 | affine_size | int | 0 | |
  833. | 1 | eps | float | 0.001f | x = x / sqrt(var + eps) |
  834. | 2 | affine | int | 1 | |
  835. | weight | type | shape |
  836. | ------------- | ----- | --------------------- |
  837. | gamma_data | float | [affine_size] |
  838. | beta_data | float | [affine_size] |
  839. # Log
  840. ```
  841. if base == -1 y = log(shift + x * scale)
  842. else y = log(shift + x * scale) / log(base)
  843. ```
  844. * one_blob_only
  845. * support_inplace
  846. | param id | name | type | default | description |
  847. | --------- | ------------- | ----- | --------- | ----------------- |
  848. | 0 | base | float | -1.f | |
  849. | 1 | scale | float | 1.f | |
  850. | 2 | shift | float | 0.f | |
  851. # LRN
  852. ```
  853. if region_type == ACROSS_CHANNELS square_sum = sum of channel window of local_size
  854. if region_type == WITHIN_CHANNEL square_sum = sum of spatial window of local_size
  855. y = x * pow(bias + alpha * square_sum / (local_size * local_size), -beta)
  856. ```
  857. * one_blob_only
  858. * support_inplace
  859. | param id | name | type | default | description |
  860. | --------- | ------------- | ----- | --------- | ----------------- |
  861. | 0 | region_type | int | 0 | |
  862. | 1 | local_size | int | 5 | |
  863. | 2 | alpha | float | 1.f | |
  864. | 3 | beta | float | 0.75f | |
  865. | 4 | bias | float | 1.f | |
  866. Region type:
  867. - 0 = ACROSS_CHANNELS
  868. - 1 = WITHIN_CHANNEL
  869. # LSTM
  870. Apply 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]`.
  871. ```
  872. y = lstm(x)
  873. y0, hidden y1, cell y2 = lstm(x0, hidden x1, cell x2)
  874. ```
  875. * one_blob_only if bidirectional
  876. | param id | name | type | default | description |
  877. | --------- | ------------- | ----- | --------- | ----------------- |
  878. | 0 | num_output | int | 0 | output size of output |
  879. | 1 | weight_data_size| int | 0 | total size of IFOG weight matrix |
  880. | 2 | direction | int | 0 | 0=forward, 1=reverse, 2=bidirectional |
  881. | 3 | hidden_size | int | num_output| hidden size |
  882. | weight | type | shape |
  883. | ------------- | ----- | --------------------- |
  884. | weight_xc_data| float/fp16/int8 | [input_size, hidden_size * 4, num_directions] |
  885. | bias_c_data | float/fp16/int8 | [hidden_size, 4, num_directions] |
  886. | weight_hc_data| float/fp16/int8 | [num_output, hidden_size * 4, num_directions] |
  887. | weight_hr_data| float/fp16/int8 | [hidden_size, num_output, num_directions] |
  888. Direction flag:
  889. - 0 = forward only
  890. - 1 = reverse only
  891. - 2 = bidirectional
  892. # MemoryData
  893. ```
  894. y = data
  895. ```
  896. | param id | name | type | default | description |
  897. | --------- | ------------- | ----- | --------- | ----------------- |
  898. | 0 | w | int | 0 | |
  899. | 1 | h | int | 0 | |
  900. | 11 | d | int | 0 | |
  901. | 2 | c | int | 0 | |
  902. | weight | type | shape |
  903. | ------------- | ----- | --------------------- |
  904. | data | float | [w, h, d, c] |
  905. # Mish
  906. ```
  907. y = x * tanh(log(exp(x) + 1))
  908. ```
  909. * one_blob_only
  910. * support_inplace
  911. # MultiHeadAttention
  912. ```
  913. split q k v into num_head part q0, k0, v0, q1, k1, v1 ...
  914. for each num_head part
  915. xq = affine(q) / (embed_dim / num_head)
  916. xk = affine(k)
  917. xv = affine(v)
  918. xqk = xq * xk
  919. softmax_inplace(xqk)
  920. xqkv = xqk * xv
  921. merge xqkv to out
  922. y = affine(out)
  923. ```
  924. | param id | name | type | default | description |
  925. | --------- | ------------- | ----- | --------- | ----------------- |
  926. | 0 | embed_dim | int | 0 | |
  927. | 1 | num_head | int | 1 | |
  928. | 2 | weight_data_size| int | 0 | |
  929. | weight | type | shape |
  930. | ------------- | ----- | --------------------- |
  931. | q_weight_data | float/fp16/int8 | [weight_data_size] |
  932. | q_bias_data | float | [embed_dim] |
  933. | k_weight_data | float/fp16/int8 | [weight_data_size] |
  934. | k_bias_data | float | [embed_dim] |
  935. | v_weight_data | float/fp16/int8 | [weight_data_size] |
  936. | v_bias_data | float | [embed_dim] |
  937. | out_weight_data| float/fp16/int8 | [weight_data_size] |
  938. | out_bias_data | float | [embed_dim] |
  939. # MVN
  940. ```
  941. if normalize_variance == 1 && across_channels == 1 y = (x - mean) / (sqrt(var) + eps) of whole blob
  942. if normalize_variance == 1 && across_channels == 0 y = (x - mean) / (sqrt(var) + eps) of each channel
  943. if normalize_variance == 0 && across_channels == 1 y = x - mean of whole blob
  944. if normalize_variance == 0 && across_channels == 0 y = x - mean of each channel
  945. ```
  946. * one_blob_only
  947. | param id | name | type | default | description |
  948. | --------- | ------------- | ----- | --------- | ----------------- |
  949. | 0 | normalize_variance| int | 0 | |
  950. | 1 | across_channels| int | 0 | |
  951. | 2 | eps | float | 0.0001f | x = x / (sqrt(var) + eps) |
  952. # Noop
  953. ```
  954. y = x
  955. ```
  956. # Normalize
  957. ```
  958. if across_spatial == 1 && across_channel == 1 x2 = normalize(x) of whole blob
  959. if across_spatial == 1 && across_channel == 0 x2 = normalize(x) of each channel
  960. if across_spatial == 0 && across_channel == 1 x2 = normalize(x) of each position
  961. y = x2 * scale
  962. ```
  963. * one_blob_only
  964. * support_inplace
  965. | param id | name | type | default | description |
  966. | --------- | ------------- | ----- | --------- | ----------------- |
  967. | 0 | across_spatial| int | 0 | |
  968. | 1 | channel_shared| int | 0 | |
  969. | 2 | eps | float | 0.0001f | see eps mode |
  970. | 3 | scale_data_size| int | 0 | |
  971. | 4 | across_channel| int | 0 | |
  972. | 9 | eps_mode | int | 0 | |
  973. | weight | type | shape |
  974. | ------------- | ----- | --------------------- |
  975. | scale_data | float | [scale_data_size] |
  976. Eps Mode:
  977. - 0 = caffe/mxnet x = x / sqrt(var + eps)
  978. - 1 = pytorch x = x / max(sqrt(var), eps)
  979. - 2 = tensorflow x = x / sqrt(max(var, eps))
  980. # Packing
  981. ```
  982. y = wrap_packing(x)
  983. ```
  984. * one_blob_only
  985. | param id | name | type | default | description |
  986. | --------- | ------------- | ----- | --------- | ----------------- |
  987. | 0 | out_elempack | int | 1 | |
  988. | 1 | use_padding | int | 0 | |
  989. | 2 | cast_type_from| int | 0 | |
  990. | 3 | cast_type_to | int | 0 | |
  991. | 4 | storage_type_from| int | 0 | |
  992. | 5 | storage_type_to| int | 0 | |
  993. # Padding
  994. ```
  995. y = pad(x, pads)
  996. ```
  997. | param id | name | type | default | description |
  998. | --------- | ------------- | ---- | --------- | ----------------- |
  999. | 0 | top | int | 0 | |
  1000. | 1 | bottom | int | 0 | |
  1001. | 2 | left | int | 0 | |
  1002. | 3 | right | int | 0 | |
  1003. | 4 | type | int | 0 | |
  1004. | 5 | value | float | 0 | |
  1005. | 6 | per_channel_pad_data_size| int | 0 | |
  1006. | 7 | front | int | stride_w | |
  1007. | 8 | behind | int | pad_left | |
  1008. | weight | type | shape |
  1009. | ------------- | ----- | --------------------- |
  1010. | per_channel_pad_data| float | [per_channel_pad_data_size] |
  1011. Padding type:
  1012. - 0 = CONSTANT
  1013. - 1 = REPLICATE
  1014. - 2 = REFLECT
  1015. # Permute
  1016. ```
  1017. y = reorder(x)
  1018. ```
  1019. | param id | name | type | default | description |
  1020. | --------- | ------------- | ---- | --------- | ----------------- |
  1021. | 0 | order_type | int | 0 | |
  1022. Order Type:
  1023. - 0 = WH WHC WHDC
  1024. - 1 = HW HWC HWDC
  1025. - 2 = WCH WDHC
  1026. - 3 = CWH DWHC
  1027. - 4 = HCW HDWC
  1028. - 5 = CHW DHWC
  1029. - 6 = WHCD
  1030. - 7 = HWCD
  1031. - 8 = WCHD
  1032. - 9 = CWHD
  1033. - 10 = HCWD
  1034. - 11 = CHWD
  1035. - 12 = WDCH
  1036. - 13 = DWCH
  1037. - 14 = WCDH
  1038. - 15 = CWDH
  1039. - 16 = DCWH
  1040. - 17 = CDWH
  1041. - 18 = HDCW
  1042. - 19 = DHCW
  1043. - 20 = HCDW
  1044. - 21 = CHDW
  1045. - 22 = DCHW
  1046. - 23 = CDHW
  1047. # PixelShuffle
  1048. ```
  1049. if mode == 0 y = depth_to_space(x) where x channel order is sw-sh-outc
  1050. if mode == 1 y = depth_to_space(x) where x channel order is outc-sw-sh
  1051. ```
  1052. * one_blob_only
  1053. | param id | name | type | default | description |
  1054. | --------- | ------------- | ---- | --------- | ----------------- |
  1055. | 0 | upscale_factor| int | 1 | |
  1056. | 1 | mode | int | 0 | |
  1057. # Pooling
  1058. ```
  1059. x2 = pad(x, pads)
  1060. x3 = pooling(x2, kernel, stride)
  1061. ```
  1062. | param id | name | type | default | description |
  1063. | --------- | --------------| ---- | --------- | ----------------- |
  1064. | 0 | pooling_type | int | 0 | |
  1065. | 1 | kernel_w | int | 0 | |
  1066. | 2 | stride_w | int | 1 | |
  1067. | 3 | pad_left | int | 0 | |
  1068. | 4 | global_pooling| int | 0 | |
  1069. | 5 | pad_mode | int | 0 | |
  1070. | 6 | avgpool_count_include_pad| int | 0 | |
  1071. | 7 | adaptive_pooling| int | 0 | |
  1072. | 8 | out_w | int | 0 | |
  1073. | 11 | kernel_h | int | kernel_w | |
  1074. | 12 | stride_h | int | stride_w | |
  1075. | 13 | pad_top | int | pad_left | |
  1076. | 14 | pad_right | int | pad_left | |
  1077. | 15 | pad_bottom | int | pad_top | |
  1078. | 18 | out_h | int | out_w | |
  1079. Pooling type:
  1080. - 0 = MAX
  1081. - 1 = AVG
  1082. Pad mode:
  1083. - 0 = full padding
  1084. - 1 = valid padding
  1085. - 2 = tensorflow padding=SAME or onnx padding=SAME_UPPER
  1086. - 3 = onnx padding=SAME_LOWER
  1087. # Pooling1D
  1088. ```
  1089. x2 = pad(x, pads)
  1090. x3 = pooling1d(x2, kernel, stride)
  1091. ```
  1092. | param id | name | type | default | description |
  1093. | --------- | --------------| ---- | --------- | ----------------- |
  1094. | 0 | pooling_type | int | 0 | |
  1095. | 1 | kernel_w | int | 0 | |
  1096. | 2 | stride_w | int | 1 | |
  1097. | 3 | pad_left | int | 0 | |
  1098. | 4 | global_pooling| int | 0 | |
  1099. | 5 | pad_mode | int | 0 | |
  1100. | 6 | avgpool_count_include_pad| int | 0 | |
  1101. | 7 | adaptive_pooling| int | 0 | |
  1102. | 8 | out_w | int | 0 | |
  1103. | 14 | pad_right | int | pad_left | |
  1104. Pooling type:
  1105. - 0 = MAX
  1106. - 1 = AVG
  1107. Pad mode:
  1108. - 0 = full padding
  1109. - 1 = valid padding
  1110. - 2 = tensorflow padding=SAME or onnx padding=SAME_UPPER
  1111. - 3 = onnx padding=SAME_LOWER
  1112. # Pooling3D
  1113. ```
  1114. x2 = pad(x, pads)
  1115. x3 = pooling3d(x2, kernel, stride)
  1116. ```
  1117. | param id | name | type | default | description |
  1118. | --------- | --------------| ---- | --------- | ----------------- |
  1119. | 0 | pooling_type | int | 0 | |
  1120. | 1 | kernel_w | int | 0 | |
  1121. | 2 | stride_w | int | 1 | |
  1122. | 3 | pad_left | int | 0 | |
  1123. | 4 | global_pooling| int | 0 | |
  1124. | 5 | pad_mode | int | 0 | |
  1125. | 6 | avgpool_count_include_pad| int | 0 | |
  1126. | 7 | adaptive_pooling| int | 0 | |
  1127. | 8 | out_w | int | 0 | |
  1128. | 11 | kernel_h | int | kernel_w | |
  1129. | 12 | stride_h | int | stride_w | |
  1130. | 13 | pad_top | int | pad_left | |
  1131. | 14 | pad_right | int | pad_left | |
  1132. | 15 | pad_bottom | int | pad_top | |
  1133. | 16 | pad_behind | int | pad_front | |
  1134. | 18 | out_h | int | out_w | |
  1135. | 21 | kernel_d | int | kernel_w | |
  1136. | 22 | stride_d | int | stride_w | |
  1137. | 23 | pad_front | int | pad_left | |
  1138. | 28 | out_d | int | out_w | |
  1139. Pooling type:
  1140. - 0 = MAX
  1141. - 1 = AVG
  1142. Pad mode:
  1143. - 0 = full padding
  1144. - 1 = valid padding
  1145. - 2 = tensorflow padding=SAME or onnx padding=SAME_UPPER
  1146. - 3 = onnx padding=SAME_LOWER
  1147. # Power
  1148. ```
  1149. y = pow((shift + x * scale), power)
  1150. ```
  1151. * one_blob_only
  1152. * support_inplace
  1153. | param id | name | type | default | description |
  1154. | --------- | ------------- | ----- | --------- | ----------------- |
  1155. | 0 | power | float | 1.f | |
  1156. | 1 | scale | float | 1.f | |
  1157. | 2 | shift | float | 0.f | |
  1158. # PReLU
  1159. ```
  1160. if x < 0 y = x * slope
  1161. else y = x
  1162. ```
  1163. * one_blob_only
  1164. * support_inplace
  1165. | param id | name | type | default | description |
  1166. | --------- | ------------- | ----- | --------- | ----------------- |
  1167. | 0 | num_slope | int | 0 | |
  1168. | weight | type | shape |
  1169. | ------------- | ----- | --------------------- |
  1170. | slope_data | float | [num_slope] |
  1171. # Quantize
  1172. ```
  1173. y = float2int8(x * scale)
  1174. ```
  1175. * one_blob_only
  1176. | param id | name | type | default | description |
  1177. | --------- | ------------- | ----- | --------- | ----------------- |
  1178. | 0 | scale_data_size| int | 1 | |
  1179. | weight | type | shape |
  1180. | ------------- | ----- | --------------------- |
  1181. | scale_data | float | [scale_data_size] |
  1182. # Reduction
  1183. ```
  1184. y = reduce_op(x * coeff)
  1185. ```
  1186. * one_blob_only
  1187. | param id | name | type | default | description |
  1188. | --------- | ------------- | ----- | --------- | ----------------- |
  1189. | 0 | operation | int | 0 | |
  1190. | 1 | reduce_all | int | 1 | |
  1191. | 2 | coeff | float | 1.f | |
  1192. | 3 | axes | array | [ ] | |
  1193. | 4 | keepdims | int | 0 | |
  1194. Operation type:
  1195. - 0 = SUM
  1196. - 1 = ASUM
  1197. - 2 = SUMSQ
  1198. - 3 = MEAN
  1199. - 4 = MAX
  1200. - 5 = MIN
  1201. - 6 = PROD
  1202. - 7 = L1
  1203. - 8 = L2
  1204. - 9 = LogSum
  1205. - 10 = LogSumExp
  1206. # ReLU
  1207. ```
  1208. if x < 0 y = x * slope
  1209. else y = x
  1210. ```
  1211. * one_blob_only
  1212. * support_inplace
  1213. | param id | name | type | default | description |
  1214. | --------- | ------------- | ----- | --------- | ----------------- |
  1215. | 0 | slope | float | 0.f | |
  1216. # Reorg
  1217. ```
  1218. if mode == 0 y = space_to_depth(x) where x channel order is sw-sh-outc
  1219. if mode == 1 y = space_to_depth(x) where x channel order is outc-sw-sh
  1220. ```
  1221. * one_blob_only
  1222. | param id | name | type | default | description |
  1223. | --------- | ------------- | ---- | --------- | ----------------- |
  1224. | 0 | stride | int | 1 | |
  1225. | 1 | mode | int | 0 | |
  1226. # Requantize
  1227. ```
  1228. x2 = x * scale_in + bias
  1229. x3 = activation(x2)
  1230. y = float2int8(x3 * scale_out)
  1231. ```
  1232. * one_blob_only
  1233. | param id | name | type | default | description |
  1234. | --------- | ------------- | ----- | --------- | ----------------- |
  1235. | 0 | scale_in_data_size| int | 1 | |
  1236. | 1 | scale_out_data_size| int | 1 | |
  1237. | 2 | bias_data_size| int | 0 | |
  1238. | 3 | activation_type| int | 0 | |
  1239. | 4 | activation_params| int | [ ] | |
  1240. | weight | type | shape |
  1241. | ------------- | ----- | --------------------- |
  1242. | scale_in_data | float | [scale_in_data_size] |
  1243. | scale_out_data| float | [scale_out_data_size] |
  1244. | bias_data | float | [bias_data_size] |
  1245. # Reshape
  1246. ```
  1247. if permute == 1 y = hwc2chw(reshape(chw2hwc(x)))
  1248. else y = reshape(x)
  1249. ```
  1250. * one_blob_only
  1251. | param id | name | type | default | description |
  1252. | --------- | ------------- | ----- | --------- | ----------------- |
  1253. | 0 | w | int | -233 | |
  1254. | 1 | h | int | -233 | |
  1255. | 11 | d | int | -233 | |
  1256. | 2 | c | int | -233 | |
  1257. | 3 | permute | int | 0 | |
  1258. Reshape flag:
  1259. - 0 = copy from bottom
  1260. - -1 = remaining
  1261. - -233 = drop this dim(default)
  1262. # RNN
  1263. Apply 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]`.
  1264. ```
  1265. y = rnn(x)
  1266. y0, hidden y1 = rnn(x0, hidden x1)
  1267. ```
  1268. * one_blob_only if bidirectional
  1269. | param id | name | type | default | description |
  1270. | --------- | ------------- | ----- | --------- | ----------------- |
  1271. | 0 | num_output | int | 0 | hidden size of output |
  1272. | 1 | weight_data_size| int | 0 | total size of weight matrix |
  1273. | 2 | direction | int | 0 | 0=forward, 1=reverse, 2=bidirectional |
  1274. | weight | type | shape |
  1275. | ------------- | ----- | --------------------- |
  1276. | weight_xc_data| float/fp16/int8 | [input_size, num_output, num_directions] |
  1277. | bias_c_data | float/fp16/int8 | [num_output, 1, num_directions] |
  1278. | weight_hc_data| float/fp16/int8 | [num_output, num_output, num_directions] |
  1279. Direction flag:
  1280. - 0 = forward only
  1281. - 1 = reverse only
  1282. - 2 = bidirectional
  1283. # Scale
  1284. ```
  1285. if scale_data_size == -233 y = x0 * x1
  1286. else y = x * scale + bias
  1287. ```
  1288. * one_blob_only if scale_data_size != -233
  1289. * support_inplace
  1290. | param id | name | type | default | description |
  1291. | --------- | ------------- | ----- | --------- | ----------------- |
  1292. | 0 | scale_data_size| int | 0 | |
  1293. | 1 | bias_term | int | 0 | |
  1294. | weight | type | shape |
  1295. | ------------- | ----- | --------------------- |
  1296. | scale_data | float | [scale_data_size] |
  1297. | bias_data | float | [scale_data_size] |
  1298. # SELU
  1299. ```
  1300. if x < 0 y = (exp(x) - 1.f) * alpha * lambda
  1301. else y = x * lambda
  1302. ```
  1303. * one_blob_only
  1304. * support_inplace
  1305. | param id | name | type | default | description |
  1306. | --------- | ------------- | ----- | --------- | ----------------- |
  1307. | 0 | alpha | float | 1.67326324f| |
  1308. | 1 | lambda | float | 1.050700987f| |
  1309. # ShuffleChannel
  1310. ```
  1311. if reverse == 0 y = shufflechannel(x) by group
  1312. if reverse == 1 y = shufflechannel(x) by channel / group
  1313. ```
  1314. * one_blob_only
  1315. | param id | name | type | default | description |
  1316. | --------- | ------------- | ---- | --------- | ----------------- |
  1317. | 0 | group | int | 1 | |
  1318. | 1 | reverse | int | 0 | |
  1319. # Sigmoid
  1320. ```
  1321. y = 1 / (1 + exp(-x))
  1322. ```
  1323. * one_blob_only
  1324. * support_inplace
  1325. # Slice
  1326. ```
  1327. split x along axis into slices, each part slice size is based on slices array
  1328. ```
  1329. | param id | name | type | default | description |
  1330. | --------- | ------------- | ----- | --------- | ----------------- |
  1331. | 0 | slices | array | [ ] | |
  1332. | 1 | axis | int | 0 | |
  1333. # Softmax
  1334. ```
  1335. softmax(x, axis)
  1336. ```
  1337. * one_blob_only
  1338. * support_inplace
  1339. | param id | name | type | default | description |
  1340. | --------- | ------------- | ----- | --------- | ----------------- |
  1341. | 0 | axis | int | 0 | |
  1342. | 1 | fixbug0 | int | 0 | hack for bug fix, should be 1 |
  1343. # Softplus
  1344. ```
  1345. y = log(exp(x) + 1)
  1346. ```
  1347. * one_blob_only
  1348. * support_inplace
  1349. # Split
  1350. ```
  1351. y0, y1 ... = x
  1352. ```
  1353. # Swish
  1354. ```
  1355. y = x / (1 + exp(-x))
  1356. ```
  1357. * one_blob_only
  1358. * support_inplace
  1359. # TanH
  1360. ```
  1361. y = tanh(x)
  1362. ```
  1363. * one_blob_only
  1364. * support_inplace
  1365. # Threshold
  1366. ```
  1367. if x > threshold y = 1
  1368. else y = 0
  1369. ```
  1370. * one_blob_only
  1371. * support_inplace
  1372. | param id | name | type | default | description |
  1373. | --------- | ------------- | ----- | --------- | ----------------- |
  1374. | 0 | threshold | float | 0.f | |
  1375. # Tile
  1376. ```
  1377. y = repeat tiles along axis for x
  1378. ```
  1379. * one_blob_only
  1380. | param id | name | type | default | description |
  1381. | --------- | ------------- | ----- | --------- | ----------------- |
  1382. | 0 | axis | int | 0 | |
  1383. | 1 | tiles | int | 1 | |
  1384. | 2 | repeats | array | [ ] | |
  1385. # UnaryOp
  1386. ```
  1387. y = unaryop(x)
  1388. ```
  1389. - one_blob_only
  1390. - support_inplace
  1391. | param id | name | type | default | description |
  1392. | --------- | ------------- | ----- | --------- | ----------------- |
  1393. | 0 | op_type | int | 0 | Operation type as follows |
  1394. Operation type:
  1395. - 0 = ABS
  1396. - 1 = NEG
  1397. - 2 = FLOOR
  1398. - 3 = CEIL
  1399. - 4 = SQUARE
  1400. - 5 = SQRT
  1401. - 6 = RSQ
  1402. - 7 = EXP
  1403. - 8 = LOG
  1404. - 9 = SIN
  1405. - 10 = COS
  1406. - 11 = TAN
  1407. - 12 = ASIN
  1408. - 13 = ACOS
  1409. - 14 = ATAN
  1410. - 15 = RECIPROCAL
  1411. - 16 = TANH