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

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