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

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