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

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