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.

math_ops.h 6.5 kB

5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. /**
  2. * Copyright 2019-2020 Huawei Technologies Co., Ltd
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef GE_OP_MATH_OPS_H_
  17. #define GE_OP_MATH_OPS_H_
  18. #include "graph/operator_reg.h"
  19. #include "graph/operator.h"
  20. namespace ge {
  21. REG_OP(Igamma)
  22. .INPUT(a, TensorType({DT_FLOAT, DT_DOUBLE}))
  23. .INPUT(x, TensorType({DT_FLOAT, DT_DOUBLE}))
  24. .OUTPUT(z, TensorType({DT_FLOAT, DT_DOUBLE}))
  25. .OP_END_FACTORY_REG(Igamma)
  26. REG_OP(Igammac)
  27. .INPUT(a, TensorType({DT_FLOAT, DT_DOUBLE}))
  28. .INPUT(x, TensorType({DT_FLOAT, DT_DOUBLE}))
  29. .OUTPUT(z, TensorType({DT_FLOAT, DT_DOUBLE}))
  30. .OP_END_FACTORY_REG(Igammac)
  31. REG_OP(CompareAndBitpack)
  32. .INPUT(x, TensorType({ DT_FLOAT, DT_FLOAT16, DT_DOUBLE, DT_INT8, \
  33. DT_INT16, DT_INT32, DT_INT64, DT_BOOL }))
  34. .INPUT(threshold, TensorType({ DT_FLOAT, DT_FLOAT16, DT_DOUBLE, \
  35. DT_INT8, DT_INT16, DT_INT32, DT_INT64, DT_BOOL }))
  36. .OUTPUT(y, TensorType(DT_UINT8))
  37. .OP_END_FACTORY_REG(CompareAndBitpack)
  38. REG_OP(Bincount)
  39. .INPUT(array, TensorType(DT_INT32))
  40. .INPUT(size, TensorType(DT_INT32))
  41. .INPUT(weights, TensorType({ DT_FLOAT, DT_INT32, DT_INT64, DT_DOUBLE }))
  42. .OUTPUT(bins, TensorType({ DT_FLOAT, DT_INT32, DT_INT64, DT_DOUBLE }))
  43. .OP_END_FACTORY_REG(Bincount)
  44. REG_OP(Betainc)
  45. .INPUT(a, TensorType({DT_DOUBLE, DT_FLOAT}))
  46. .INPUT(b, TensorType({DT_DOUBLE, DT_FLOAT}))
  47. .INPUT(x, TensorType({DT_DOUBLE, DT_FLOAT}))
  48. .OUTPUT(z, TensorType({DT_DOUBLE, DT_FLOAT}))
  49. .OP_END_FACTORY_REG(Betainc)
  50. REG_OP(Zeta)
  51. .INPUT(x, TensorType({DT_DOUBLE, DT_FLOAT}))
  52. .INPUT(q, TensorType({DT_DOUBLE, DT_FLOAT}))
  53. .OUTPUT(z, TensorType({DT_DOUBLE, DT_FLOAT}))
  54. .OP_END_FACTORY_REG(Zeta)
  55. REG_OP(Bucketize)
  56. .INPUT(x, TensorType({DT_INT32, DT_INT64, DT_DOUBLE, DT_FLOAT}))
  57. .OUTPUT(y, TensorType({DT_INT32}))
  58. .REQUIRED_ATTR(boundaries, ListFloat)
  59. .OP_END_FACTORY_REG(Bucketize)
  60. REG_OP(SparseSegmentSum)
  61. .INPUT(x, TensorType({DT_INT8, DT_UINT8, DT_INT16, DT_UINT16,
  62. DT_INT32, DT_INT64, DT_DOUBLE, DT_FLOAT, DT_FLOAT16}))
  63. .INPUT(indices, TensorType({DT_INT32}))
  64. .INPUT(segment_ids, TensorType({DT_INT32}))
  65. .OUTPUT(y, TensorType({DT_INT8, DT_UINT8, DT_INT16, DT_UINT16,
  66. DT_INT32, DT_INT64, DT_DOUBLE, DT_FLOAT, DT_FLOAT16}))
  67. .OP_END_FACTORY_REG(SparseSegmentSum)
  68. REG_OP(SparseSegmentMean)
  69. .INPUT(x, TensorType({DT_FLOAT, DT_DOUBLE}))
  70. .INPUT(indices, TensorType({DT_INT32}))
  71. .INPUT(segment_ids, TensorType({DT_INT32}))
  72. .OUTPUT(y, TensorType({DT_FLOAT, DT_DOUBLE}))
  73. .OP_END_FACTORY_REG(SparseSegmentMean)
  74. REG_OP(SparseSegmentMeanGrad)
  75. .INPUT(x, TensorType({DT_FLOAT, DT_DOUBLE}))
  76. .INPUT(indices, TensorType({DT_INT32}))
  77. .INPUT(segment_ids, TensorType({DT_INT32}))
  78. .INPUT(output_dim0, TensorType({DT_INT32}))
  79. .OUTPUT(y, TensorType({DT_FLOAT, DT_DOUBLE}))
  80. .OP_END_FACTORY_REG(SparseSegmentMeanGrad)
  81. REG_OP(IgammaGradA)
  82. .INPUT(a, TensorType({DT_FLOAT, DT_DOUBLE}))
  83. .INPUT(x, TensorType({DT_FLOAT, DT_DOUBLE}))
  84. .OUTPUT(z, TensorType({DT_FLOAT, DT_DOUBLE}))
  85. .OP_END_FACTORY_REG(IgammaGradA)
  86. REG_OP(InitData)
  87. .ATTR(channel_name, String, "")
  88. .OP_END_FACTORY_REG(InitData)
  89. REG_OP(GetNext)
  90. .DYNAMIC_OUTPUT(y, TensorType({DT_INT8, DT_UINT8, DT_INT16, DT_UINT16, DT_INT32, DT_INT64, DT_UINT32, DT_UINT64,
  91. DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_BOOL}))
  92. .ATTR(output_types, ListInt, {})
  93. .ATTR(output_shapes, ListListInt, {})
  94. .ATTR(output_num, Int, 1)
  95. .ATTR(channel_name, String, "")
  96. .OP_END_FACTORY_REG(GetNext)
  97. /**
  98. *@brief: Computes the Gauss error function of `x` element-wise.
  99. *@par Inputs:\n
  100. *x: A Tensor of type float16 or float32.
  101. *@par Outputs:
  102. *y: A Tensor. Has the same type as "x".
  103. */
  104. REG_OP(Erf)
  105. .INPUT(x, TensorType::FloatingDataType())
  106. .OUTPUT(y, TensorType::FloatingDataType())
  107. .OP_END_FACTORY_REG(Erf)
  108. /**
  109. *@brief: Computes the Gauss complementary error function of "x" element-wise.
  110. *@par Inputs:\n
  111. *x: A Tensor of type float16 or float32.
  112. *@par Outputs:
  113. *y: A Tensor. Has the same type as "x".
  114. */
  115. REG_OP(Erfc)
  116. .INPUT(x, TensorType::FloatingDataType())
  117. .OUTPUT(y, TensorType::FloatingDataType())
  118. .OP_END_FACTORY_REG(Erfc)
  119. /**
  120. *@brief This operation returns a rank 1 histogram counting the number of entries in `values` \n
  121. * that fell into every bin.The bins are equal width and determined by the arguments \n
  122. * 'value_range' and 'nbins'. \n
  123. *@par Inputs:
  124. *Three inputs, including: \n
  125. *@li x: A Tensor of type float32,float16,int32.
  126. *@li range: A Tensor of type float32,float16,int32.
  127. *@li nbins: A Tensor of type int32.
  128. *@par Attributes:
  129. * dtype: An optional attribute. Defaults to "int32".
  130. *@par Outputs:
  131. *y: A Tensor. A Tensor of type int32.
  132. */
  133. REG_OP(HistogramFixedWidth)
  134. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32}))
  135. .INPUT(range, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32}))
  136. .INPUT(nbins, TensorType({DT_INT32}))
  137. .OUTPUT(y, TensorType({DT_INT32}))
  138. .ATTR(dtype, String, "int32")
  139. .OP_END_FACTORY_REG(HistogramFixedWidth)
  140. /**
  141. *@brief This operation returns a rank 1 histogram counting the number of entries in `values` \n
  142. * that fell into every bin.The bins are equal width and determined by the arguments \n
  143. * 'value_range' and 'nbins'. \n
  144. *@par Inputs:
  145. *Two inputs, including: \n
  146. *@li x: A Tensor of type float32,float16,int32.
  147. *@li range: A Tensor of type float32,float16,int32.
  148. *@par Attributes:
  149. *@li dtype: An optional attribute. Defaults to "int32".
  150. *@li nbins: A required attribute,the type is int32.
  151. *@par Outputs:
  152. *y: A Tensor. A Tensor of type int32.
  153. */
  154. REG_OP(HistogramFixedWidthD)
  155. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32}))
  156. .INPUT(range, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32}))
  157. .OUTPUT(y, TensorType({DT_INT32}))
  158. .REQUIRED_ATTR(nbins, Int)
  159. .ATTR(dtype, String, "int32")
  160. .OP_END_FACTORY_REG(HistogramFixedWidthD)
  161. } // namespace ge
  162. #endif // GE_OP_MATH_OPS_H_

图引擎模块(GE)是MindSpore的一个子模块,其代码由C++实现,位于前端模块ME和底层硬件之间,起到承接作用。图引擎模块以ME下发的图作为输入,然后进行一系列的深度图优化操作,最后输出一张可以在底层硬件上高效运行的图。GE针对昇腾AI处理器的硬件结构特点,做了特定的优化工作,以此来充分发挥出昇腾AI处理器的强大算力。在进行模型训练/推理时,GE会被自动调用而用户并不感知。GE主要由GE API和GE Core两部分组成,详细的架构图如下所示