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

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