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

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