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

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