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

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