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 68 kB

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