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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  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. * [convolutiondepthwise](#convolutiondepthwise)
  12. * [crop](#crop)
  13. * [dequantize](#dequantize)
  14. * [lstm](#lstm)
  15. * [sigmoid](#sigmoid)
  16. * [softmax](#softmax)
  17. * [tanh](#tanh)
  18. # absval
  19. ```
  20. y = abs(x)
  21. ```
  22. * one_blob_only
  23. * support_inplace
  24. # argmax
  25. ```
  26. y = argmax(x, out_max_val, topk)
  27. ```
  28. * one_blob_only
  29. |param id|name|type|default|
  30. |--|--|--|--|
  31. |0|out_max_val|int|0|
  32. |1|topk|int|1|
  33. # batchnorm
  34. ```
  35. y = (x - mean) / sqrt(var + eps) * slope + bias
  36. ```
  37. * one_blob_only
  38. * support_inplace
  39. |param id|name|type|default|
  40. |--|--|--|--|
  41. |0|channels|int|0|
  42. |1|eps|float|0.f|
  43. |weight|type|
  44. |--|--|
  45. |slope_data|float|
  46. |mean_data|float|
  47. |var_data|float|
  48. |bias_data|float|
  49. # bias
  50. ```
  51. y = x + bias
  52. ```
  53. * one_blob_only
  54. * support_inplace
  55. |param id|name|type|default|
  56. |--|--|--|--|
  57. |0|bias_data_size|int|0|
  58. |weight|type|
  59. |--|--|
  60. |bias_data|float|
  61. # binaryop
  62. This operation is used for binary computation, and the calculation rule depends on the [broadcasting rule](https://github.com/Tencent/ncnn/wiki/binaryop-broadcasting).
  63. ```
  64. C = binaryop(A, B)
  65. ```
  66. if with_scalar = 1:
  67. - one_blob_only
  68. - support_inplace
  69. |param id|name|type|default|description|
  70. |--|--|--|--|--|
  71. |0|op_type|int|0|Operation type as follows|
  72. |1|with_scalar|int|0|with_scalar=0 B is a matrix, with_scalar=1 B is a scalar|
  73. |2|b|float|0.f|When B is a scalar, B = b|
  74. Operation type:
  75. - 0 = ADD
  76. - 1 = SUB
  77. - 2 = MUL
  78. - 3 = DIV
  79. - 4 = MAX
  80. - 5 = MIN
  81. - 6 = POW
  82. - 7 = RSUB
  83. - 8 = RDIV
  84. # bnll
  85. ```
  86. y = log(1 + e^(-x)) , x > 0
  87. y = log(1 + e^x), x < 0
  88. ```
  89. * one_blob_only
  90. * support_inplace
  91. # cast
  92. ```
  93. y = cast(x)
  94. ```
  95. * one_blob_only
  96. * support_packing
  97. |param id|name|type|default|
  98. |--|--|--|--|
  99. |0|type_from|int|0|
  100. |1|type_to|int|0|
  101. Element type:
  102. - 0 = auto
  103. - 1 = float32
  104. - 2 = float16
  105. - 3 = int8
  106. - 4 = bfloat16
  107. # clip
  108. ```
  109. y = clamp(x, min, max)
  110. ```
  111. * one_blob_only
  112. * support_inplace
  113. |param id|name|type|default|
  114. |--|--|--|--|
  115. |0|min|float|-FLT_MAX|
  116. |1|max|float|FLT_MAX|
  117. # concat
  118. ```
  119. y = concat(x0, x1, x2, ...) by axis
  120. ```
  121. |param id|name|type|default|
  122. |--|--|--|--|
  123. |0|axis|int|0|
  124. # convolution
  125. ```
  126. x2 = pad(x, pads, pad_value)
  127. x3 = conv(x2, weight, kernel, stride, dilation) + bias
  128. y = activation(x3, act_type, act_params)
  129. ```
  130. * one_blob_only
  131. |param id|name|type|default|
  132. |--|--|--|--|
  133. |0|num_output|int|0|
  134. |1|kernel_w|int|0|
  135. |2|dilation_w|int|1|
  136. |3|stride_w|int|1|
  137. |4|pad_left|int|0|
  138. |5|bias_term|int|0|
  139. |6|weight_data_size|int|0|
  140. |8|int8_scale_term|int|0|
  141. |9|activation_type|int|0|
  142. |10|activation_params|array|[ ]|
  143. |11|kernel_h|int|kernel_w|
  144. |12|dilation_h|int|dilation_w|
  145. |13|stride_h|int|stride_w|
  146. |15|pad_right|int|pad_left|
  147. |14|pad_top|int|pad_left|
  148. |16|pad_bottom|int|pad_top|
  149. |18|pad_value|float|0.f|
  150. |weight|type|
  151. |--|--|
  152. |weight_data|float/fp16/int8|
  153. |bias_data|float|
  154. # convolutiondepthwise
  155. ```
  156. x2 = pad(x, pads, pad_value)
  157. x3 = conv(x2, weight, kernel, stride, dilation, group) + bias
  158. y = activation(x3, act_type, act_params)
  159. ```
  160. * one_blob_only
  161. |param id|name|type|default|
  162. |--|--|--|--|
  163. |0|num_output|int|0|
  164. |1|kernel_w|int|0|
  165. |2|dilation_w|int|1|
  166. |3|stride_w|int|1|
  167. |4|pad_left|int|0|
  168. |5|bias_term|int|0|
  169. |6|weight_data_size|int|0|
  170. |7|group|int|1|
  171. |8|int8_scale_term|int|0|
  172. |9|activation_type|int|0|
  173. |10|activation_params|array|[ ]|
  174. |11|kernel_h|int|kernel_w|
  175. |12|dilation_h|int|dilation_w|
  176. |13|stride_h|int|stride_w|
  177. |15|pad_right|int|pad_left|
  178. |14|pad_top|int|pad_left|
  179. |16|pad_bottom|int|pad_top|
  180. |18|pad_value|float|0.f|
  181. |weight|type|
  182. |--|--|
  183. |weight_data|float/fp16/int8|
  184. |bias_data|float|
  185. # crop
  186. ```
  187. y = crop(x)
  188. ```
  189. * one_blob_only
  190. |param id|name|type|default|
  191. |--|--|--|--|
  192. |0|woffset|int|0|
  193. |1|hoffset|int|0|
  194. |2|coffset|int|1|
  195. |3|outw|int|1|
  196. |4|outh|int|0|
  197. |5|outc|int|0|
  198. |6|woffset2|int|0|
  199. |7|hoffset2|int|1|
  200. |8|coffset2|int|0|
  201. |9|starts|array|[ ]|
  202. |10|ends|array|[ ]|
  203. |11|axes|array|[ ]|
  204. # dequantize
  205. ```
  206. y = x * scale + bias
  207. ```
  208. * one_blob_only
  209. * support_inplace
  210. |param id|name|type|default|
  211. |--|--|--|--|
  212. |0|scale|float|1.f|
  213. |1|bias_term|int|0|
  214. |2|bias_data_size|int|0|
  215. # lstm
  216. 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]`.
  217. * one_blob_only
  218. |param id|name|type|default|description|
  219. |--|--|--|--|--|
  220. |0|num_output|int|0|hidden size of output|
  221. |1|weight_data_size|int|0|total size of IFOG weight matrix|
  222. |2|direction|int|0|0=forward, 1=reverse, 2=bidirectional|
  223. |weight|type|shape|description|
  224. |--|--|--|--|
  225. |weight_xc_data|float|`[w=input_size, h=num_output * 4, c=num_directions]`||
  226. |bias_c_data|float|`[w=num_output, h=4, c=num_directions]`||
  227. |weight_hc_data|float|`[w=num_output, h=num_output * 4, c=num_directions]`||
  228. # sigmoid
  229. ```
  230. y = 1 / (1 + exp(-x))
  231. ```
  232. * one_blob_only
  233. * support_inplace
  234. # softmax
  235. ```
  236. softmax(x, axis)
  237. ```
  238. * one_blob_only
  239. * support_inplace
  240. |param id|name|type|default|description|
  241. |--|--|--|--|--|
  242. |0|axis|int|0||
  243. |1|fixbug0|int|0|hack for bug fix, should be 1|
  244. # tanh
  245. ```
  246. y = tanh(x)
  247. ```
  248. * one_blob_only
  249. * support_inplace