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

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102
  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. # CumulativeSum
  437. If axis < 0, we use axis = x.dims + axis
  438. It implements https://pytorch.org/docs/stable/generated/torch.cumsum.html
  439. - one_blob_only
  440. - support_inplace
  441. | param id | name | type | default | description |
  442. | -------- | ---- | ---- | ------- | ----------- |
  443. | 0 | axis | int | 0 | |
  444. # Deconvolution
  445. ```
  446. x2 = deconv(x, weight, kernel, stride, dilation) + bias
  447. x3 = depad(x2, pads, pad_value)
  448. y = activation(x3, act_type, act_params)
  449. ```
  450. - one_blob_only
  451. | param id | name | type | default | description |
  452. | -------- | ----------------- | ----- | ---------------- | ----------- |
  453. | 0 | num_output | int | 0 | |
  454. | 1 | kernel_w | int | 0 | |
  455. | 2 | dilation_w | int | 1 | |
  456. | 3 | stride_w | int | 1 | |
  457. | 4 | pad_left | int | 0 | |
  458. | 5 | bias_term | int | 0 | |
  459. | 6 | weight_data_size | int | 0 | |
  460. | 9 | activation_type | int | 0 | |
  461. | 10 | activation_params | array | [ ] | |
  462. | 11 | kernel_h | int | kernel_w | |
  463. | 12 | dilation_h | int | dilation_w | |
  464. | 13 | stride_h | int | stride_w | |
  465. | 14 | pad_top | int | pad_left | |
  466. | 15 | pad_right | int | pad_left | |
  467. | 16 | pad_bottom | int | pad_top | |
  468. | 18 | output_pad_right | int | 0 | |
  469. | 19 | output_pad_bottom | int | output_pad_right | |
  470. | 20 | output_w | int | 0 | |
  471. | 21 | output_h | int | output_w | |
  472. | 28 | dynamic_weight | int | 0 | |
  473. | weight | type | shape |
  474. | ----------- | ---------- | ------------------------------------------- |
  475. | weight_data | float/fp16 | [kernel_w, kernel_h, num_input, num_output] |
  476. | bias_data | float | [num_output] |
  477. # Deconvolution1D
  478. ```
  479. x2 = deconv1d(x, weight, kernel, stride, dilation) + bias
  480. x3 = depad(x2, pads, pad_value)
  481. y = activation(x3, act_type, act_params)
  482. ```
  483. - one_blob_only
  484. | param id | name | type | default | description |
  485. | -------- | ----------------- | ----- | -------- | ----------- |
  486. | 0 | num_output | int | 0 | |
  487. | 1 | kernel_w | int | 0 | |
  488. | 2 | dilation_w | int | 1 | |
  489. | 3 | stride_w | int | 1 | |
  490. | 4 | pad_left | int | 0 | |
  491. | 5 | bias_term | int | 0 | |
  492. | 6 | weight_data_size | int | 0 | |
  493. | 9 | activation_type | int | 0 | |
  494. | 10 | activation_params | array | [ ] | |
  495. | 15 | pad_right | int | pad_left | |
  496. | 18 | output_pad_right | int | 0 | |
  497. | 20 | output_w | int | 0 | |
  498. | 28 | dynamic_weight | int | 0 | |
  499. | weight | type | shape |
  500. | ----------- | ---------- | --------------------------------- |
  501. | weight_data | float/fp16 | [kernel_w, num_input, num_output] |
  502. | bias_data | float | [num_output] |
  503. # Deconvolution3D
  504. ```
  505. x2 = deconv3d(x, weight, kernel, stride, dilation) + bias
  506. x3 = depad(x2, pads, pad_value)
  507. y = activation(x3, act_type, act_params)
  508. ```
  509. - one_blob_only
  510. | param id | name | type | default | description |
  511. | -------- | ----------------- | ----- | ---------------- | ----------- |
  512. | 0 | num_output | int | 0 | |
  513. | 1 | kernel_w | int | 0 | |
  514. | 2 | dilation_w | int | 1 | |
  515. | 3 | stride_w | int | 1 | |
  516. | 4 | pad_left | int | 0 | |
  517. | 5 | bias_term | int | 0 | |
  518. | 6 | weight_data_size | int | 0 | |
  519. | 9 | activation_type | int | 0 | |
  520. | 10 | activation_params | array | [ ] | |
  521. | 11 | kernel_h | int | kernel_w | |
  522. | 12 | dilation_h | int | dilation_w | |
  523. | 13 | stride_h | int | stride_w | |
  524. | 14 | pad_top | int | pad_left | |
  525. | 15 | pad_right | int | pad_left | |
  526. | 16 | pad_bottom | int | pad_top | |
  527. | 17 | pad_behind | int | pad_front | |
  528. | 18 | output_pad_right | int | 0 | |
  529. | 19 | output_pad_bottom | int | output_pad_right | |
  530. | 20 | output_pad_behind | int | output_pad_right | |
  531. | 21 | kernel_d | int | kernel_w | |
  532. | 22 | dilation_d | int | dilation_w | |
  533. | 23 | stride_d | int | stride_w | |
  534. | 24 | pad_front | int | pad_left | |
  535. | 25 | output_w | int | 0 | |
  536. | 26 | output_h | int | output_w | |
  537. | 27 | output_d | int | output_w | |
  538. | weight | type | shape |
  539. | ----------- | ---------- | ----------------------------------------------------- |
  540. | weight_data | float/fp16 | [kernel_w, kernel_h, kernel_d, num_input, num_output] |
  541. | bias_data | float | [num_output] |
  542. # DeconvolutionDepthWise
  543. ```
  544. x2 = deconv(x, weight, kernel, stride, dilation, group) + bias
  545. x3 = depad(x2, pads, pad_value)
  546. y = activation(x3, act_type, act_params)
  547. ```
  548. - one_blob_only
  549. | param id | name | type | default | description |
  550. | -------- | ----------------- | ----- | ---------------- | ----------- |
  551. | 0 | num_output | int | 0 | |
  552. | 1 | kernel_w | int | 0 | |
  553. | 2 | dilation_w | int | 1 | |
  554. | 3 | stride_w | int | 1 | |
  555. | 4 | pad_left | int | 0 | |
  556. | 5 | bias_term | int | 0 | |
  557. | 6 | weight_data_size | int | 0 | |
  558. | 7 | group | int | 1 | |
  559. | 9 | activation_type | int | 0 | |
  560. | 10 | activation_params | array | [ ] | |
  561. | 11 | kernel_h | int | kernel_w | |
  562. | 12 | dilation_h | int | dilation_w | |
  563. | 13 | stride_h | int | stride_w | |
  564. | 14 | pad_top | int | pad_left | |
  565. | 15 | pad_right | int | pad_left | |
  566. | 16 | pad_bottom | int | pad_top | |
  567. | 18 | output_pad_right | int | 0 | |
  568. | 19 | output_pad_bottom | int | output_pad_right | |
  569. | 20 | output_w | int | 0 | |
  570. | 21 | output_h | int | output_w | |
  571. | 28 | dynamic_weight | int | 0 | |
  572. | weight | type | shape |
  573. | ----------- | ---------- | ------------------------------------------------------------------ |
  574. | weight_data | float/fp16 | [kernel_w, kernel_h, num_input / group, num_output / group, group] |
  575. | bias_data | float | [num_output] |
  576. # DeconvolutionDepthWise1D
  577. ```
  578. x2 = deconv1d(x, weight, kernel, stride, dilation, group) + bias
  579. x3 = depad(x2, pads, pad_value)
  580. y = activation(x3, act_type, act_params)
  581. ```
  582. - one_blob_only
  583. | param id | name | type | default | description |
  584. | -------- | ----------------- | ----- | -------- | ----------- |
  585. | 0 | num_output | int | 0 | |
  586. | 1 | kernel_w | int | 0 | |
  587. | 2 | dilation_w | int | 1 | |
  588. | 3 | stride_w | int | 1 | |
  589. | 4 | pad_left | int | 0 | |
  590. | 5 | bias_term | int | 0 | |
  591. | 6 | weight_data_size | int | 0 | |
  592. | 7 | group | int | 1 | |
  593. | 9 | activation_type | int | 0 | |
  594. | 10 | activation_params | array | [ ] | |
  595. | 15 | pad_right | int | pad_left | |
  596. | 18 | output_pad_right | int | 0 | |
  597. | 20 | output_w | int | 0 | |
  598. | 28 | dynamic_weight | int | 0 | |
  599. | weight | type | shape |
  600. | ----------- | ---------- | -------------------------------------------------------- |
  601. | weight_data | float/fp16 | [kernel_w, num_input / group, num_output / group, group] |
  602. | bias_data | float | [num_output] |
  603. # DeconvolutionDepthWise3D
  604. ```
  605. x2 = deconv3d(x, weight, kernel, stride, dilation, group) + bias
  606. x3 = depad(x2, pads, pad_value)
  607. y = activation(x3, act_type, act_params)
  608. ```
  609. - one_blob_only
  610. | param id | name | type | default | description |
  611. | -------- | ----------------- | ----- | ---------------- | ----------- |
  612. | 0 | num_output | int | 0 | |
  613. | 1 | kernel_w | int | 0 | |
  614. | 2 | dilation_w | int | 1 | |
  615. | 3 | stride_w | int | 1 | |
  616. | 4 | pad_left | int | 0 | |
  617. | 5 | bias_term | int | 0 | |
  618. | 6 | weight_data_size | int | 0 | |
  619. | 7 | group | int | 1 | |
  620. | 9 | activation_type | int | 0 | |
  621. | 10 | activation_params | array | [ ] | |
  622. | 11 | kernel_h | int | kernel_w | |
  623. | 12 | dilation_h | int | dilation_w | |
  624. | 13 | stride_h | int | stride_w | |
  625. | 14 | pad_top | int | pad_left | |
  626. | 15 | pad_right | int | pad_left | |
  627. | 16 | pad_bottom | int | pad_top | |
  628. | 17 | pad_behind | int | pad_front | |
  629. | 18 | output_pad_right | int | 0 | |
  630. | 19 | output_pad_bottom | int | output_pad_right | |
  631. | 20 | output_pad_behind | int | output_pad_right | |
  632. | 21 | kernel_d | int | kernel_w | |
  633. | 22 | dilation_d | int | dilation_w | |
  634. | 23 | stride_d | int | stride_w | |
  635. | 24 | pad_front | int | pad_left | |
  636. | 25 | output_w | int | 0 | |
  637. | 26 | output_h | int | output_w | |
  638. | 27 | output_d | int | output_w | |
  639. | weight | type | shape |
  640. | ----------- | ---------- | ---------------------------------------------------------------------------- |
  641. | weight_data | float/fp16 | [kernel_w, kernel_h, kernel_d, num_input / group, num_output / group, group] |
  642. | bias_data | float | [num_output] |
  643. # DeformableConv2D
  644. ```
  645. x2 = deformableconv2d(x, offset, mask, weight, kernel, stride, dilation) + bias
  646. y = activation(x2, act_type, act_params)
  647. ```
  648. | param id | name | type | default | description |
  649. | -------- | ----------------- | ----- | ---------- | ----------- |
  650. | 0 | num_output | int | 0 | |
  651. | 1 | kernel_w | int | 0 | |
  652. | 2 | dilation_w | int | 1 | |
  653. | 3 | stride_w | int | 1 | |
  654. | 4 | pad_left | int | 0 | |
  655. | 5 | bias_term | int | 0 | |
  656. | 6 | weight_data_size | int | 0 | |
  657. | 9 | activation_type | int | 0 | |
  658. | 10 | activation_params | array | [ ] | |
  659. | 11 | kernel_h | int | kernel_w | |
  660. | 12 | dilation_h | int | dilation_w | |
  661. | 13 | stride_h | int | stride_w | |
  662. | 14 | pad_top | int | pad_left | |
  663. | 15 | pad_right | int | pad_left | |
  664. | 16 | pad_bottom | int | pad_top | |
  665. | weight | type | shape |
  666. | ----------- | --------------- | ------------------------------------------- |
  667. | weight_data | float/fp16/int8 | [kernel_w, kernel_h, num_input, num_output] |
  668. | bias_data | float | [num_output] |
  669. # Dequantize
  670. ```
  671. y = x * scale + bias
  672. ```
  673. - one_blob_only
  674. - support_inplace
  675. | param id | name | type | default | description |
  676. | -------- | --------------- | ---- | ------- | ----------- |
  677. | 0 | scale_data_size | int | 1 | |
  678. | 1 | bias_data_size | int | 0 | |
  679. | weight | type | shape |
  680. | ---------- | ----- | ----------------- |
  681. | scale_data | float | [scale_data_size] |
  682. | bias_data | float | [bias_data_size] |
  683. # Diag
  684. ```
  685. y = diag(x, diagonal)
  686. ```
  687. - one_blob_only
  688. | param id | name | type | default | description |
  689. | -------- | -------- | ---- | ------- | ----------- |
  690. | 0 | diagonal | int | 0 | |
  691. # Dropout
  692. ```
  693. y = x * scale
  694. ```
  695. - one_blob_only
  696. | param id | name | type | default | description |
  697. | -------- | ----- | ----- | ------- | ----------- |
  698. | 0 | scale | float | 1.f | |
  699. # Eltwise
  700. ```
  701. y = elementwise_op(x0, x1, ...)
  702. ```
  703. | param id | name | type | default | description |
  704. | -------- | ------- | ----- | ------- | ----------- |
  705. | 0 | op_type | int | 0 | |
  706. | 1 | coeffs | array | [ ] | |
  707. Operation type:
  708. - 0 = PROD
  709. - 1 = SUM
  710. - 2 = MAX
  711. # ELU
  712. ```
  713. if x < 0 y = (exp(x) - 1) * alpha
  714. else y = x
  715. ```
  716. - one_blob_only
  717. - support_inplace
  718. | param id | name | type | default | description |
  719. | -------- | ----- | ----- | ------- | ----------- |
  720. | 0 | alpha | float | 0.1f | |
  721. # Embed
  722. ```
  723. y = embedding(x)
  724. ```
  725. | param id | name | type | default | description |
  726. | -------- | ---------------- | ---- | ------- | ----------- |
  727. | 0 | num_output | int | 0 | |
  728. | 1 | input_dim | int | 0 | |
  729. | 2 | bias_term | int | 0 | |
  730. | 3 | weight_data_size | int | 0 | |
  731. | 18 | int8_scale_term | int | 0 | |
  732. | weight | type | shape |
  733. | ----------------------- | ----- | ------------------ |
  734. | weight_data | float | [weight_data_size] |
  735. | bias_term | float | [num_output] |
  736. | weight_data_int8_scales | float | [1] |
  737. # Exp
  738. ```
  739. if base == -1 y = exp(shift + x * scale)
  740. else y = pow(base, (shift + x * scale))
  741. ```
  742. - one_blob_only
  743. - support_inplace
  744. | param id | name | type | default | description |
  745. | -------- | ----- | ----- | ------- | ----------- |
  746. | 0 | base | float | -1.f | |
  747. | 1 | scale | float | 1.f | |
  748. | 2 | shift | float | 0.f | |
  749. # Flatten
  750. Reshape blob to 1 dimension
  751. - one_blob_only
  752. # Flip
  753. - one_blob_only
  754. | param id | name | type | default | description |
  755. | -------- | ---- | ----- | ------- | ----------- |
  756. | 0 | axis | array | [] | |
  757. # Fold
  758. ```
  759. y = fold(x)
  760. ```
  761. - one_blob_only
  762. | param id | name | type | default | description |
  763. | -------- | ---------- | ---- | ---------- | ----------- |
  764. | 0 | num_output | int | 0 | |
  765. | 1 | kernel_w | int | 0 | |
  766. | 2 | dilation_w | int | 1 | |
  767. | 3 | stride_w | int | 1 | |
  768. | 4 | pad_left | int | 0 | |
  769. | 11 | kernel_h | int | kernel_w | |
  770. | 12 | dilation_h | int | dilation_w | |
  771. | 13 | stride_h | int | stride_w | |
  772. | 14 | pad_top | int | pad_left | |
  773. | 15 | pad_right | int | pad_left | |
  774. | 16 | pad_bottom | int | pad_top | |
  775. | 20 | output_w | int | 0 | |
  776. | 21 | output_h | int | output_w | |
  777. # GELU
  778. ```
  779. if fast_gelu == 1 y = 0.5 * x * (1 + tanh(0.79788452 * (x + 0.044715 * x * x * x)));
  780. else y = 0.5 * x * erfc(-0.70710678 * x)
  781. ```
  782. - one_blob_only
  783. - support_inplace
  784. | param id | name | type | default | description |
  785. | -------- | --------- | ---- | ------- | ----------------- |
  786. | 0 | fast_gelu | int | 0 | use approximation |
  787. # GLU
  788. If axis < 0, we use axis = x.dims + axis
  789. GLU(a,b)=a⊗σ(b)
  790. where a is the first half of the input matrix and b is the second half.
  791. axis specifies the dimension to split the input
  792. - one_blob_only
  793. | param id | name | type | default | description |
  794. | -------- | ---- | ---- | ------- | ----------- |
  795. | 0 | axis | int | 0 | |
  796. # Gemm
  797. ```
  798. a = transA ? transpose(x0) : x0
  799. b = transb ? transpose(x1) : x1
  800. c = x2
  801. y = (gemm(a, b) + c * beta) * alpha
  802. ```
  803. | param id | name | type | default | description |
  804. | -------- | ------------------------- | ----- | ------- | ----------- |
  805. | 0 | alpha | float | 1.f | |
  806. | 1 | beta | float | 1.f | |
  807. | 2 | transA | int | 0 | |
  808. | 3 | transb | int | 0 | |
  809. | 4 | constantA | int | 0 | |
  810. | 5 | constantB | int | 0 | |
  811. | 6 | constantC | int | 0 | |
  812. | 7 | constantM | int | 0 | |
  813. | 8 | constantN | int | 0 | |
  814. | 9 | constantK | int | 0 | |
  815. | 10 | constant_broadcast_type_C | int | 0 | |
  816. | 11 | output_N1M | int | 0 | |
  817. | 12 | output_elempack | int | 0 | |
  818. | 13 | output_elemtype | int | 0 | |
  819. | 14 | output_transpose | int | 0 | |
  820. | 18 | int8_scale_term | int | 0 | |
  821. | 20 | constant_TILE_M | int | 0 | |
  822. | 21 | constant_TILE_N | int | 0 | |
  823. | 22 | constant_TILE_K | int | 0 | |
  824. | weight | type | shape |
  825. | ------------------ | --------------- | -------------------------------------------- |
  826. | A_data | float/fp16/int8 | [M, K] or [K, M] |
  827. | B_data | float/fp16/int8 | [N, K] or [K, N] |
  828. | C_data | float | [1], [M] or [N] or [1, M] or [N,1] or [N, M] |
  829. | A_data_int8_scales | float | [M] |
  830. | B_data_int8_scales | float | [1] |
  831. # GridSample
  832. ```
  833. Given an input and a flow-field grid, computes the output using input values and pixel locations from grid.
  834. For each output location output[:, h2, w2], the size-2 vector grid[h2, w2, 2] specifies input pixel[:, h1, w1] locations x and y,
  835. which are used to interpolate the output value output[:, h2, w2]
  836. This function is often used in conjunction with affine_grid() to build Spatial Transformer Networks .
  837. ```
  838. | param id | name | type | default | description |
  839. | -------- | -------------- | ---- | ------- | ----------------- |
  840. | 0 | sample_type | int | 1 | |
  841. | 1 | padding_mode | int | 1 | |
  842. | 2 | align_corner | int | 0 | |
  843. | 3 | permute_fusion | int | 0 | fuse with permute |
  844. Sample type:
  845. - 1 = Nearest
  846. - 2 = Bilinear
  847. - 3 = Bicubic
  848. Padding mode:
  849. - 1 = zeros
  850. - 2 = border
  851. - 3 = reflection
  852. # GroupNorm
  853. ```
  854. split x along channel axis into group x0, x1 ...
  855. l2 normalize for each group x0, x1 ...
  856. y = x * gamma + beta
  857. ```
  858. - one_blob_only
  859. - support_inplace
  860. | param id | name | type | default | description |
  861. | -------- | -------- | ----- | ------- | ----------------------- |
  862. | 0 | group | int | 1 | |
  863. | 1 | channels | int | 0 | |
  864. | 2 | eps | float | 0.001f | x = x / sqrt(var + eps) |
  865. | 3 | affine | int | 1 | |
  866. | weight | type | shape |
  867. | ---------- | ----- | ---------- |
  868. | gamma_data | float | [channels] |
  869. | beta_data | float | [channels] |
  870. # GRU
  871. 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]`.
  872. ```
  873. y = gru(x)
  874. y0, hidden y1 = gru(x0, hidden x1)
  875. ```
  876. - one_blob_only if bidirectional
  877. | param id | name | type | default | description |
  878. | -------- | ---------------- | ---- | ------- | ------------------------------------- |
  879. | 0 | num_output | int | 0 | hidden size of output |
  880. | 1 | weight_data_size | int | 0 | total size of weight matrix |
  881. | 2 | direction | int | 0 | 0=forward, 1=reverse, 2=bidirectional |
  882. | weight | type | shape |
  883. | -------------- | --------------- | -------------------------------------------- |
  884. | weight_xc_data | float/fp16/int8 | [input_size, num_output * 3, num_directions] |
  885. | bias_c_data | float/fp16/int8 | [num_output, 4, num_directions] |
  886. | weight_hc_data | float/fp16/int8 | [num_output, num_output * 3, num_directions] |
  887. Direction flag:
  888. - 0 = forward only
  889. - 1 = reverse only
  890. - 2 = bidirectional
  891. # HardSigmoid
  892. ```
  893. y = clamp(x * alpha + beta, 0, 1)
  894. ```
  895. - one_blob_only
  896. - support_inplace
  897. | param id | name | type | default | description |
  898. | -------- | ----- | ----- | ------- | ----------- |
  899. | 0 | alpha | float | 0.2f | |
  900. | 1 | beta | float | 0.5f | |
  901. # HardSwish
  902. ```
  903. y = x * clamp(x * alpha + beta, 0, 1)
  904. ```
  905. - one_blob_only
  906. - support_inplace
  907. | param id | name | type | default | description |
  908. | -------- | ----- | ----- | ------- | ----------- |
  909. | 0 | alpha | float | 0.2f | |
  910. | 1 | beta | float | 0.5f | |
  911. # InnerProduct
  912. ```
  913. x2 = innerproduct(x, weight) + bias
  914. y = activation(x2, act_type, act_params)
  915. ```
  916. - one_blob_only
  917. | param id | name | type | default | description |
  918. | -------- | ----------------- | ----- | ------- | ----------- |
  919. | 0 | num_output | int | 0 | |
  920. | 1 | bias_term | int | 0 | |
  921. | 2 | weight_data_size | int | 0 | |
  922. | 8 | int8_scale_term | int | 0 | |
  923. | 9 | activation_type | int | 0 | |
  924. | 10 | activation_params | array | [ ] | |
  925. | weight | type | shape |
  926. | ----------------------- | --------------- | ----------------------- |
  927. | weight_data | float/fp16/int8 | [num_input, num_output] |
  928. | bias_data | float | [num_output] |
  929. | weight_data_int8_scales | float | [num_output] |
  930. | bottom_blob_int8_scales | float | [1] |
  931. # Input
  932. ```
  933. y = input
  934. ```
  935. - support_inplace
  936. | param id | name | type | default | description |
  937. | -------- | ---- | ---- | ------- | ----------- |
  938. | 0 | w | int | 0 | |
  939. | 1 | h | int | 0 | |
  940. | 11 | d | int | 0 | |
  941. | 2 | c | int | 0 | |
  942. # InstanceNorm
  943. ```
  944. split x along channel axis into instance x0, x1 ...
  945. l2 normalize for each channel instance x0, x1 ...
  946. y = x * gamma + beta
  947. ```
  948. - one_blob_only
  949. - support_inplace
  950. | param id | name | type | default | description |
  951. | -------- | -------- | ----- | ------- | ----------------------- |
  952. | 0 | channels | int | 0 | |
  953. | 1 | eps | float | 0.001f | x = x / sqrt(var + eps) |
  954. | 2 | affine | int | 1 | |
  955. | weight | type | shape |
  956. | ---------- | ----- | ---------- |
  957. | gamma_data | float | [channels] |
  958. | beta_data | float | [channels] |
  959. # Interp
  960. ```
  961. if dynamic_target_size == 0 y = resize(x) by fixed size or scale
  962. else y = resize(x0, size(x1))
  963. ```
  964. - one_blob_only if dynamic_target_size == 0
  965. | param id | name | type | default | description |
  966. | -------- | ------------------- | ----- | ------- | ----------- |
  967. | 0 | resize_type | int | 0 | |
  968. | 1 | height_scale | float | 1.f | |
  969. | 2 | width_scale | float | 1.f | |
  970. | 3 | output_height | int | 0 | |
  971. | 4 | output_width | int | 0 | |
  972. | 5 | dynamic_target_size | int | 0 | |
  973. | 6 | align_corner | int | 0 | |
  974. Resize type:
  975. - 1 = Nearest
  976. - 2 = Bilinear
  977. - 3 = Bicubic
  978. # InverseSpectrogram
  979. ```
  980. x1 = x as complex
  981. x1 = x1 * sqrt(norm) if normalized
  982. y = istft(x1)
  983. y1 = unpad(y) if center
  984. if returns == 0 return y1 as complex
  985. if returns == 1 return y1 real
  986. if returns == 2 return y1 imag
  987. ```
  988. - one_blob_only
  989. | param id | name | type | default | description |
  990. | -------- | ----------- | ---- | --------- | ------------------------------- |
  991. | 0 | n_fft | int | 0 | |
  992. | 1 | returns | int | 1 | |
  993. | 2 | hoplen | int | n_fft / 4 | |
  994. | 3 | winlen | int | n_fft | |
  995. | 4 | window_type | int | 0 | 0=ones 1=hann 2=hamming |
  996. | 5 | center | int | 1 | |
  997. | 7 | normalized | int | 0 | 0=no 1=n_fft 2=window-l2-energy |
  998. # LayerNorm
  999. ```
  1000. split x along outmost axis into part x0, x1 ...
  1001. l2 normalize for each part x0, x1 ...
  1002. y = x * gamma + beta by elementwise
  1003. ```
  1004. - one_blob_only
  1005. - support_inplace
  1006. | param id | name | type | default | description |
  1007. | -------- | ----------- | ----- | ------- | ----------------------- |
  1008. | 0 | affine_size | int | 0 | |
  1009. | 1 | eps | float | 0.001f | x = x / sqrt(var + eps) |
  1010. | 2 | affine | int | 1 | |
  1011. | weight | type | shape |
  1012. | ---------- | ----- | ------------- |
  1013. | gamma_data | float | [affine_size] |
  1014. | beta_data | float | [affine_size] |
  1015. # Log
  1016. ```
  1017. if base == -1 y = log(shift + x * scale)
  1018. else y = log(shift + x * scale) / log(base)
  1019. ```
  1020. - one_blob_only
  1021. - support_inplace
  1022. | param id | name | type | default | description |
  1023. | -------- | ----- | ----- | ------- | ----------- |
  1024. | 0 | base | float | -1.f | |
  1025. | 1 | scale | float | 1.f | |
  1026. | 2 | shift | float | 0.f | |
  1027. # LRN
  1028. ```
  1029. if region_type == ACROSS_CHANNELS square_sum = sum of channel window of local_size
  1030. if region_type == WITHIN_CHANNEL square_sum = sum of spatial window of local_size
  1031. y = x * pow(bias + alpha * square_sum / (local_size * local_size), -beta)
  1032. ```
  1033. - one_blob_only
  1034. - support_inplace
  1035. | param id | name | type | default | description |
  1036. | -------- | ----------- | ----- | ------- | ----------- |
  1037. | 0 | region_type | int | 0 | |
  1038. | 1 | local_size | int | 5 | |
  1039. | 2 | alpha | float | 1.f | |
  1040. | 3 | beta | float | 0.75f | |
  1041. | 4 | bias | float | 1.f | |
  1042. Region type:
  1043. - 0 = ACROSS_CHANNELS
  1044. - 1 = WITHIN_CHANNEL
  1045. # LSTM
  1046. 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]`.
  1047. ```
  1048. y = lstm(x)
  1049. y0, hidden y1, cell y2 = lstm(x0, hidden x1, cell x2)
  1050. ```
  1051. - one_blob_only if bidirectional
  1052. | param id | name | type | default | description |
  1053. | -------- | ---------------- | ---- | ---------- | ------------------------------------- |
  1054. | 0 | num_output | int | 0 | output size of output |
  1055. | 1 | weight_data_size | int | 0 | total size of IFOG weight matrix |
  1056. | 2 | direction | int | 0 | 0=forward, 1=reverse, 2=bidirectional |
  1057. | 3 | hidden_size | int | num_output | hidden size |
  1058. | weight | type | shape |
  1059. | -------------- | --------------- | --------------------------------------------- |
  1060. | weight_xc_data | float/fp16/int8 | [input_size, hidden_size * 4, num_directions] |
  1061. | bias_c_data | float/fp16/int8 | [hidden_size, 4, num_directions] |
  1062. | weight_hc_data | float/fp16/int8 | [num_output, hidden_size * 4, num_directions] |
  1063. | weight_hr_data | float/fp16/int8 | [hidden_size, num_output, num_directions] |
  1064. Direction flag:
  1065. - 0 = forward only
  1066. - 1 = reverse only
  1067. - 2 = bidirectional
  1068. # MemoryData
  1069. ```
  1070. y = data
  1071. ```
  1072. | param id | name | type | default | description |
  1073. | -------- | --------- | ---- | ------- | ----------- |
  1074. | 0 | w | int | 0 | |
  1075. | 1 | h | int | 0 | |
  1076. | 11 | d | int | 0 | |
  1077. | 2 | c | int | 0 | |
  1078. | 21 | load_type | int | 1 | 1=fp32 |
  1079. | weight | type | shape |
  1080. | ------ | ----- | ------------ |
  1081. | data | float | [w, h, d, c] |
  1082. # Mish
  1083. ```
  1084. y = x * tanh(log(exp(x) + 1))
  1085. ```
  1086. - one_blob_only
  1087. - support_inplace
  1088. # MultiHeadAttention
  1089. ```
  1090. split q k v into num_head part q0, k0, v0, q1, k1, v1 ...
  1091. for each num_head part
  1092. xq = affine(q) / (embed_dim / num_head)
  1093. xk = affine(k)
  1094. xv = affine(v)
  1095. xqk = xq * xk
  1096. xqk = xqk + attn_mask if attn_mask exists
  1097. softmax_inplace(xqk)
  1098. xqkv = xqk * xv
  1099. merge xqkv to out
  1100. y = affine(out)
  1101. ```
  1102. | param id | name | type | default | description |
  1103. | -------- | ---------------- | ----- | --------------------------------- | ----------------------------------- |
  1104. | 0 | embed_dim | int | 0 | |
  1105. | 1 | num_heads | int | 1 | |
  1106. | 2 | weight_data_size | int | 0 | qdim = weight_data_size / embed_dim |
  1107. | 3 | kdim | int | embed_dim | |
  1108. | 4 | vdim | int | embed_dim | |
  1109. | 5 | attn_mask | int | 0 | |
  1110. | 6 | scale | float | 1.f / sqrt(embed_dim / num_heads) | |
  1111. | 18 | int8_scale_term | int | 0 | |
  1112. | weight | type | shape |
  1113. | --------------------------- | --------------- | ------------------ |
  1114. | q_weight_data | float/fp16/int8 | [embed_dim * qdim] |
  1115. | q_bias_data | float | [embed_dim] |
  1116. | k_weight_data | float/fp16/int8 | [embed_dim * kdim] |
  1117. | k_bias_data | float | [embed_dim] |
  1118. | v_weight_data | float/fp16/int8 | [embed_dim * vdim] |
  1119. | v_bias_data | float | [embed_dim] |
  1120. | out_weight_data | float/fp16/int8 | [qdim * embed_dim] |
  1121. | out_bias_data | float | [qdim] |
  1122. | q_weight_data_int8_scales | float | [embed_dim] |
  1123. | k_weight_data_int8_scales | float | [embed_dim] |
  1124. | v_weight_data_int8_scales | float | [embed_dim] |
  1125. | out_weight_data_int8_scales | float | [1] |
  1126. # MVN
  1127. ```
  1128. if normalize_variance == 1 && across_channels == 1 y = (x - mean) / (sqrt(var) + eps) of whole blob
  1129. if normalize_variance == 1 && across_channels == 0 y = (x - mean) / (sqrt(var) + eps) of each channel
  1130. if normalize_variance == 0 && across_channels == 1 y = x - mean of whole blob
  1131. if normalize_variance == 0 && across_channels == 0 y = x - mean of each channel
  1132. ```
  1133. - one_blob_only
  1134. | param id | name | type | default | description |
  1135. | -------- | ------------------ | ----- | ------- | ------------------------- |
  1136. | 0 | normalize_variance | int | 0 | |
  1137. | 1 | across_channels | int | 0 | |
  1138. | 2 | eps | float | 0.0001f | x = x / (sqrt(var) + eps) |
  1139. # Noop
  1140. ```
  1141. y = x
  1142. ```
  1143. # Normalize
  1144. ```
  1145. if across_spatial == 1 && across_channel == 1 x2 = normalize(x) of whole blob
  1146. if across_spatial == 1 && across_channel == 0 x2 = normalize(x) of each channel
  1147. if across_spatial == 0 && across_channel == 1 x2 = normalize(x) of each position
  1148. y = x2 * scale
  1149. ```
  1150. - one_blob_only
  1151. - support_inplace
  1152. | param id | name | type | default | description |
  1153. | -------- | --------------- | ----- | ------- | ------------ |
  1154. | 0 | across_spatial | int | 0 | |
  1155. | 1 | channel_shared | int | 0 | |
  1156. | 2 | eps | float | 0.0001f | see eps mode |
  1157. | 3 | scale_data_size | int | 0 | |
  1158. | 4 | across_channel | int | 0 | |
  1159. | 9 | eps_mode | int | 0 | |
  1160. | weight | type | shape |
  1161. | ---------- | ----- | ----------------- |
  1162. | scale_data | float | [scale_data_size] |
  1163. Eps Mode:
  1164. - 0 = caffe/mxnet x = x / sqrt(var + eps)
  1165. - 1 = pytorch x = x / max(sqrt(var), eps)
  1166. - 2 = tensorflow x = x / sqrt(max(var, eps))
  1167. # Packing
  1168. ```
  1169. y = wrap_packing(x)
  1170. ```
  1171. - one_blob_only
  1172. | param id | name | type | default | description |
  1173. | -------- | ----------------- | ---- | ------- | ----------- |
  1174. | 0 | out_elempack | int | 1 | |
  1175. | 1 | use_padding | int | 0 | |
  1176. | 2 | cast_type_from | int | 0 | |
  1177. | 3 | cast_type_to | int | 0 | |
  1178. | 4 | storage_type_from | int | 0 | |
  1179. | 5 | storage_type_to | int | 0 | |
  1180. # Padding
  1181. ```
  1182. y = pad(x, pads)
  1183. ```
  1184. | param id | name | type | default | description |
  1185. | -------- | ------------------------- | ----- | -------- | ----------- |
  1186. | 0 | top | int | 0 | |
  1187. | 1 | bottom | int | 0 | |
  1188. | 2 | left | int | 0 | |
  1189. | 3 | right | int | 0 | |
  1190. | 4 | type | int | 0 | |
  1191. | 5 | value | float | 0 | |
  1192. | 6 | per_channel_pad_data_size | int | 0 | |
  1193. | 7 | front | int | stride_w | |
  1194. | 8 | behind | int | pad_left | |
  1195. | weight | type | shape |
  1196. | -------------------- | ----- | --------------------------- |
  1197. | per_channel_pad_data | float | [per_channel_pad_data_size] |
  1198. Padding type:
  1199. - 0 = CONSTANT
  1200. - 1 = REPLICATE
  1201. - 2 = REFLECT
  1202. # Permute
  1203. ```
  1204. y = reorder(x)
  1205. ```
  1206. | param id | name | type | default | description |
  1207. | -------- | ---------- | ---- | ------- | ----------- |
  1208. | 0 | order_type | int | 0 | |
  1209. Order Type:
  1210. - 0 = WH WHC WHDC
  1211. - 1 = HW HWC HWDC
  1212. - 2 = WCH WDHC
  1213. - 3 = CWH DWHC
  1214. - 4 = HCW HDWC
  1215. - 5 = CHW DHWC
  1216. - 6 = WHCD
  1217. - 7 = HWCD
  1218. - 8 = WCHD
  1219. - 9 = CWHD
  1220. - 10 = HCWD
  1221. - 11 = CHWD
  1222. - 12 = WDCH
  1223. - 13 = DWCH
  1224. - 14 = WCDH
  1225. - 15 = CWDH
  1226. - 16 = DCWH
  1227. - 17 = CDWH
  1228. - 18 = HDCW
  1229. - 19 = DHCW
  1230. - 20 = HCDW
  1231. - 21 = CHDW
  1232. - 22 = DCHW
  1233. - 23 = CDHW
  1234. # PixelShuffle
  1235. ```
  1236. if mode == 0 y = depth_to_space(x) where x channel order is sw-sh-outc
  1237. if mode == 1 y = depth_to_space(x) where x channel order is outc-sw-sh
  1238. ```
  1239. - one_blob_only
  1240. | param id | name | type | default | description |
  1241. | -------- | -------------- | ---- | ------- | ----------- |
  1242. | 0 | upscale_factor | int | 1 | |
  1243. | 1 | mode | int | 0 | |
  1244. # Pooling
  1245. ```
  1246. x2 = pad(x, pads)
  1247. x3 = pooling(x2, kernel, stride)
  1248. ```
  1249. | param id | name | type | default | description |
  1250. | -------- | ------------------------- | ---- | -------- | ----------- |
  1251. | 0 | pooling_type | int | 0 | |
  1252. | 1 | kernel_w | int | 0 | |
  1253. | 2 | stride_w | int | 1 | |
  1254. | 3 | pad_left | int | 0 | |
  1255. | 4 | global_pooling | int | 0 | |
  1256. | 5 | pad_mode | int | 0 | |
  1257. | 6 | avgpool_count_include_pad | int | 0 | |
  1258. | 7 | adaptive_pooling | int | 0 | |
  1259. | 8 | out_w | int | 0 | |
  1260. | 11 | kernel_h | int | kernel_w | |
  1261. | 12 | stride_h | int | stride_w | |
  1262. | 13 | pad_top | int | pad_left | |
  1263. | 14 | pad_right | int | pad_left | |
  1264. | 15 | pad_bottom | int | pad_top | |
  1265. | 18 | out_h | int | out_w | |
  1266. Pooling type:
  1267. - 0 = MAX
  1268. - 1 = AVG
  1269. Pad mode:
  1270. - 0 = full padding
  1271. - 1 = valid padding
  1272. - 2 = tensorflow padding=SAME or onnx padding=SAME_UPPER
  1273. - 3 = onnx padding=SAME_LOWER
  1274. # Pooling1D
  1275. ```
  1276. x2 = pad(x, pads)
  1277. x3 = pooling1d(x2, kernel, stride)
  1278. ```
  1279. | param id | name | type | default | description |
  1280. | -------- | ------------------------- | ---- | -------- | ----------- |
  1281. | 0 | pooling_type | int | 0 | |
  1282. | 1 | kernel_w | int | 0 | |
  1283. | 2 | stride_w | int | 1 | |
  1284. | 3 | pad_left | int | 0 | |
  1285. | 4 | global_pooling | int | 0 | |
  1286. | 5 | pad_mode | int | 0 | |
  1287. | 6 | avgpool_count_include_pad | int | 0 | |
  1288. | 7 | adaptive_pooling | int | 0 | |
  1289. | 8 | out_w | int | 0 | |
  1290. | 14 | pad_right | int | pad_left | |
  1291. Pooling type:
  1292. - 0 = MAX
  1293. - 1 = AVG
  1294. Pad mode:
  1295. - 0 = full padding
  1296. - 1 = valid padding
  1297. - 2 = tensorflow padding=SAME or onnx padding=SAME_UPPER
  1298. - 3 = onnx padding=SAME_LOWER
  1299. # Pooling3D
  1300. ```
  1301. x2 = pad(x, pads)
  1302. x3 = pooling3d(x2, kernel, stride)
  1303. ```
  1304. | param id | name | type | default | description |
  1305. | -------- | ------------------------- | ---- | --------- | ----------- |
  1306. | 0 | pooling_type | int | 0 | |
  1307. | 1 | kernel_w | int | 0 | |
  1308. | 2 | stride_w | int | 1 | |
  1309. | 3 | pad_left | int | 0 | |
  1310. | 4 | global_pooling | int | 0 | |
  1311. | 5 | pad_mode | int | 0 | |
  1312. | 6 | avgpool_count_include_pad | int | 0 | |
  1313. | 7 | adaptive_pooling | int | 0 | |
  1314. | 8 | out_w | int | 0 | |
  1315. | 11 | kernel_h | int | kernel_w | |
  1316. | 12 | stride_h | int | stride_w | |
  1317. | 13 | pad_top | int | pad_left | |
  1318. | 14 | pad_right | int | pad_left | |
  1319. | 15 | pad_bottom | int | pad_top | |
  1320. | 16 | pad_behind | int | pad_front | |
  1321. | 18 | out_h | int | out_w | |
  1322. | 21 | kernel_d | int | kernel_w | |
  1323. | 22 | stride_d | int | stride_w | |
  1324. | 23 | pad_front | int | pad_left | |
  1325. | 28 | out_d | int | out_w | |
  1326. Pooling type:
  1327. - 0 = MAX
  1328. - 1 = AVG
  1329. Pad mode:
  1330. - 0 = full padding
  1331. - 1 = valid padding
  1332. - 2 = tensorflow padding=SAME or onnx padding=SAME_UPPER
  1333. - 3 = onnx padding=SAME_LOWER
  1334. # Power
  1335. ```
  1336. y = pow((shift + x * scale), power)
  1337. ```
  1338. - one_blob_only
  1339. - support_inplace
  1340. | param id | name | type | default | description |
  1341. | -------- | ----- | ----- | ------- | ----------- |
  1342. | 0 | power | float | 1.f | |
  1343. | 1 | scale | float | 1.f | |
  1344. | 2 | shift | float | 0.f | |
  1345. # PReLU
  1346. ```
  1347. if x < 0 y = x * slope
  1348. else y = x
  1349. ```
  1350. - one_blob_only
  1351. - support_inplace
  1352. | param id | name | type | default | description |
  1353. | -------- | --------- | ---- | ------- | ----------- |
  1354. | 0 | num_slope | int | 0 | |
  1355. | weight | type | shape |
  1356. | ---------- | ----- | ----------- |
  1357. | slope_data | float | [num_slope] |
  1358. # Quantize
  1359. ```
  1360. y = float2int8(x * scale)
  1361. ```
  1362. - one_blob_only
  1363. | param id | name | type | default | description |
  1364. | -------- | --------------- | ---- | ------- | ----------- |
  1365. | 0 | scale_data_size | int | 1 | |
  1366. | weight | type | shape |
  1367. | ---------- | ----- | ----------------- |
  1368. | scale_data | float | [scale_data_size] |
  1369. # Reduction
  1370. ```
  1371. y = reduce_op(x * coeff)
  1372. ```
  1373. - one_blob_only
  1374. | param id | name | type | default | description |
  1375. | -------- | ---------- | ----- | ------- | ----------------------------- |
  1376. | 0 | operation | int | 0 | |
  1377. | 1 | reduce_all | int | 1 | |
  1378. | 2 | coeff | float | 1.f | |
  1379. | 3 | axes | array | [ ] | |
  1380. | 4 | keepdims | int | 0 | |
  1381. | 5 | fixbug0 | int | 0 | hack for bug fix, should be 1 |
  1382. Operation type:
  1383. - 0 = SUM
  1384. - 1 = ASUM
  1385. - 2 = SUMSQ
  1386. - 3 = MEAN
  1387. - 4 = MAX
  1388. - 5 = MIN
  1389. - 6 = PROD
  1390. - 7 = L1
  1391. - 8 = L2
  1392. - 9 = LogSum
  1393. - 10 = LogSumExp
  1394. # ReLU
  1395. ```
  1396. if x < 0 y = x * slope
  1397. else y = x
  1398. ```
  1399. - one_blob_only
  1400. - support_inplace
  1401. | param id | name | type | default | description |
  1402. | -------- | ----- | ----- | ------- | ----------- |
  1403. | 0 | slope | float | 0.f | |
  1404. # Reorg
  1405. ```
  1406. if mode == 0 y = space_to_depth(x) where x channel order is sw-sh-outc
  1407. if mode == 1 y = space_to_depth(x) where x channel order is outc-sw-sh
  1408. ```
  1409. - one_blob_only
  1410. | param id | name | type | default | description |
  1411. | -------- | ------ | ---- | ------- | ----------- |
  1412. | 0 | stride | int | 1 | |
  1413. | 1 | mode | int | 0 | |
  1414. # Requantize
  1415. ```
  1416. x2 = x * scale_in + bias
  1417. x3 = activation(x2)
  1418. y = float2int8(x3 * scale_out)
  1419. ```
  1420. - one_blob_only
  1421. | param id | name | type | default | description |
  1422. | -------- | ------------------- | ---- | ------- | ----------- |
  1423. | 0 | scale_in_data_size | int | 1 | |
  1424. | 1 | scale_out_data_size | int | 1 | |
  1425. | 2 | bias_data_size | int | 0 | |
  1426. | 3 | activation_type | int | 0 | |
  1427. | 4 | activation_params | int | [ ] | |
  1428. | weight | type | shape |
  1429. | -------------- | ----- | --------------------- |
  1430. | scale_in_data | float | [scale_in_data_size] |
  1431. | scale_out_data | float | [scale_out_data_size] |
  1432. | bias_data | float | [bias_data_size] |
  1433. # Reshape
  1434. ```
  1435. if permute == 1 y = hwc2chw(reshape(chw2hwc(x)))
  1436. else y = reshape(x)
  1437. ```
  1438. - one_blob_only
  1439. | param id | name | type | default | description |
  1440. | -------- | ------- | ---- | ------- | ----------- |
  1441. | 0 | w | int | -233 | |
  1442. | 1 | h | int | -233 | |
  1443. | 11 | d | int | -233 | |
  1444. | 2 | c | int | -233 | |
  1445. | 3 | permute | int | 0 | |
  1446. Reshape flag:
  1447. - 0 = copy from bottom
  1448. - -1 = remaining
  1449. - -233 = drop this dim(default)
  1450. # RMSNorm
  1451. ```
  1452. split x along outmost axis into part x0, x1 ...
  1453. root mean square normalize for each part x0, x1 ...
  1454. y = x * gamma by elementwise
  1455. ```
  1456. - one_blob_only
  1457. - support_inplace
  1458. | param id | name | type | default | description |
  1459. | -------- | ----------- | ----- | ------- | ----------------------- |
  1460. | 0 | affine_size | int | 0 | |
  1461. | 1 | eps | float | 0.001f | x = x / sqrt(var + eps) |
  1462. | 2 | affine | int | 1 | |
  1463. | weight | type | shape |
  1464. | ---------- | ----- | ------------- |
  1465. | gamma_data | float | [affine_size] |
  1466. # RNN
  1467. 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]`.
  1468. ```
  1469. y = rnn(x)
  1470. y0, hidden y1 = rnn(x0, hidden x1)
  1471. ```
  1472. - one_blob_only if bidirectional
  1473. | param id | name | type | default | description |
  1474. | -------- | ---------------- | ---- | ------- | ------------------------------------- |
  1475. | 0 | num_output | int | 0 | hidden size of output |
  1476. | 1 | weight_data_size | int | 0 | total size of weight matrix |
  1477. | 2 | direction | int | 0 | 0=forward, 1=reverse, 2=bidirectional |
  1478. | weight | type | shape |
  1479. | -------------- | --------------- | ---------------------------------------- |
  1480. | weight_xc_data | float/fp16/int8 | [input_size, num_output, num_directions] |
  1481. | bias_c_data | float/fp16/int8 | [num_output, 1, num_directions] |
  1482. | weight_hc_data | float/fp16/int8 | [num_output, num_output, num_directions] |
  1483. Direction flag:
  1484. - 0 = forward only
  1485. - 1 = reverse only
  1486. - 2 = bidirectional
  1487. # Scale
  1488. ```
  1489. if scale_data_size == -233 y = x0 * x1
  1490. else y = x * scale + bias
  1491. ```
  1492. - one_blob_only if scale_data_size != -233
  1493. - support_inplace
  1494. | param id | name | type | default | description |
  1495. | -------- | --------------- | ---- | ------- | ----------- |
  1496. | 0 | scale_data_size | int | 0 | |
  1497. | 1 | bias_term | int | 0 | |
  1498. | weight | type | shape |
  1499. | ---------- | ----- | ----------------- |
  1500. | scale_data | float | [scale_data_size] |
  1501. | bias_data | float | [scale_data_size] |
  1502. # SELU
  1503. ```
  1504. if x < 0 y = (exp(x) - 1.f) * alpha * lambda
  1505. else y = x * lambda
  1506. ```
  1507. - one_blob_only
  1508. - support_inplace
  1509. | param id | name | type | default | description |
  1510. | -------- | ------ | ----- | ------------ | ----------- |
  1511. | 0 | alpha | float | 1.67326324f | |
  1512. | 1 | lambda | float | 1.050700987f | |
  1513. # Shrink
  1514. ```
  1515. if x < -lambd y = x + bias
  1516. if x > lambd y = x - bias
  1517. else y = x
  1518. ```
  1519. - one_blob_only
  1520. - support_inplace
  1521. | param id | name | type | default | description |
  1522. | -------- | ----- | ----- | ------- | ----------- |
  1523. | 0 | bias | float | 0.0f | |
  1524. | 1 | lambd | float | 0.5f | |
  1525. # ShuffleChannel
  1526. ```
  1527. if reverse == 0 y = shufflechannel(x) by group
  1528. if reverse == 1 y = shufflechannel(x) by channel / group
  1529. ```
  1530. - one_blob_only
  1531. | param id | name | type | default | description |
  1532. | -------- | ------- | ---- | ------- | ----------- |
  1533. | 0 | group | int | 1 | |
  1534. | 1 | reverse | int | 0 | |
  1535. # Sigmoid
  1536. ```
  1537. y = 1 / (1 + exp(-x))
  1538. ```
  1539. - one_blob_only
  1540. - support_inplace
  1541. # Slice
  1542. ```
  1543. split x along axis into slices, each part slice size is based on slices array
  1544. ```
  1545. | param id | name | type | default | description |
  1546. | -------- | ------- | ----- | ------- | ----------- |
  1547. | 0 | slices | array | [ ] | |
  1548. | 1 | axis | int | 0 | |
  1549. | 2 | indices | array | [ ] | |
  1550. # Softmax
  1551. ```
  1552. softmax(x, axis)
  1553. ```
  1554. - one_blob_only
  1555. - support_inplace
  1556. | param id | name | type | default | description |
  1557. | -------- | ------- | ---- | ------- | ----------------------------- |
  1558. | 0 | axis | int | 0 | |
  1559. | 1 | fixbug0 | int | 0 | hack for bug fix, should be 1 |
  1560. # Softplus
  1561. ```
  1562. y = log(exp(x) + 1)
  1563. ```
  1564. - one_blob_only
  1565. - support_inplace
  1566. # Spectrogram
  1567. ```
  1568. x1 = pad(x) if center
  1569. y = stft(x1)
  1570. y = y / sqrt(norm) if normalized
  1571. if power == 0 return y as real
  1572. if power == 1 return magnitude
  1573. if power == 2 return square of magnitude
  1574. ```
  1575. - one_blob_only
  1576. | param id | name | type | default | description |
  1577. | -------- | ----------- | ---- | --------- | -------------------------------- |
  1578. | 0 | n_fft | int | 0 | |
  1579. | 1 | power | int | 0 | |
  1580. | 2 | hoplen | int | n_fft / 4 | |
  1581. | 3 | winlen | int | n_fft | |
  1582. | 4 | window_type | int | 0 | 0=ones 1=hann 2=hamming |
  1583. | 5 | center | int | 1 | |
  1584. | 6 | pad_type | int | 2 | 0=CONSTANT 1=REPLICATE 2=REFLECT |
  1585. | 7 | normalized | int | 0 | 0=no 1=n_fft 2=window-l2-energy |
  1586. | 8 | onesided | int | 1 | |
  1587. # Split
  1588. ```
  1589. y0, y1 ... = x
  1590. ```
  1591. # Swish
  1592. ```
  1593. y = x / (1 + exp(-x))
  1594. ```
  1595. - one_blob_only
  1596. - support_inplace
  1597. # TanH
  1598. ```
  1599. y = tanh(x)
  1600. ```
  1601. - one_blob_only
  1602. - support_inplace
  1603. # Threshold
  1604. ```
  1605. if x > threshold y = 1
  1606. else y = 0
  1607. ```
  1608. - one_blob_only
  1609. - support_inplace
  1610. | param id | name | type | default | description |
  1611. | -------- | --------- | ----- | ------- | ----------- |
  1612. | 0 | threshold | float | 0.f | |
  1613. # Tile
  1614. ```
  1615. y = repeat tiles along axis for x
  1616. ```
  1617. - one_blob_only
  1618. | param id | name | type | default | description |
  1619. | -------- | ------- | ----- | ------- | ----------- |
  1620. | 0 | axis | int | 0 | |
  1621. | 1 | tiles | int | 1 | |
  1622. | 2 | repeats | array | [ ] | |
  1623. # UnaryOp
  1624. ```
  1625. y = unaryop(x)
  1626. ```
  1627. - one_blob_only
  1628. - support_inplace
  1629. | param id | name | type | default | description |
  1630. | -------- | ------- | ---- | ------- | ------------------------- |
  1631. | 0 | op_type | int | 0 | Operation type as follows |
  1632. Operation type:
  1633. - 0 = ABS
  1634. - 1 = NEG
  1635. - 2 = FLOOR
  1636. - 3 = CEIL
  1637. - 4 = SQUARE
  1638. - 5 = SQRT
  1639. - 6 = RSQ
  1640. - 7 = EXP
  1641. - 8 = LOG
  1642. - 9 = SIN
  1643. - 10 = COS
  1644. - 11 = TAN
  1645. - 12 = ASIN
  1646. - 13 = ACOS
  1647. - 14 = ATAN
  1648. - 15 = RECIPROCAL
  1649. - 16 = TANH
  1650. - 17 = LOG10
  1651. - 18 = ROUND
  1652. - 19 = TRUNC
  1653. # Unfold
  1654. ```
  1655. y = unfold(x)
  1656. ```
  1657. - one_blob_only
  1658. | param id | name | type | default | description |
  1659. | -------- | ---------- | ---- | ---------- | ----------- |
  1660. | 0 | num_output | int | 0 | |
  1661. | 1 | kernel_w | int | 0 | |
  1662. | 2 | dilation_w | int | 1 | |
  1663. | 3 | stride_w | int | 1 | |
  1664. | 4 | pad_left | int | 0 | |
  1665. | 11 | kernel_h | int | kernel_w | |
  1666. | 12 | dilation_h | int | dilation_w | |
  1667. | 13 | stride_h | int | stride_w | |
  1668. | 14 | pad_top | int | pad_left | |
  1669. | 15 | pad_right | int | pad_left | |
  1670. | 16 | pad_bottom | int | pad_top | |