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

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