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

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