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

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