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.

set_ops.h 7.1 kB

5 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /**
  2. * Copyright 2019 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. /*!
  17. * \file set_ops.h
  18. * \brief
  19. */
  20. #ifndef OPS_BUILT_IN_OP_PROTO_INC_SET_OPS_H_
  21. #define OPS_BUILT_IN_OP_PROTO_INC_SET_OPS_H_
  22. #include "graph/operator.h"
  23. #include "graph/operator_reg.h"
  24. namespace ge {
  25. /**
  26. *@brief Applies set operation along last dimension of 2 Tensor inputs . \n
  27. *@par Inputs:
  28. *Inputs include:
  29. * @li x1: A Tensor. Must be one of the following types: int8, int16, int32, int64, uint8, uint16, string.
  30. * @li x2: A Tensor. Must have the same type as x1 . \n
  31. *@par Attributes:
  32. *@li set_operation: A string.
  33. *@li validate_indices: An optional bool. Defaults to True . \n
  34. *@par Outputs:
  35. *@li y_indices: A Tensor of type int64.
  36. *@li y_values: A Tensor. Has the same type as x1.
  37. *@li y_shape: A Tensor of type int64 . \n
  38. *@attention Constraints:
  39. *The implementation for DenseToDenseSetOperation on Ascend uses AICPU, with bad performance.
  40. *@par Third-party framework compatibility
  41. *@li compatible with tensorflow DenseToDenseSetOperation operator.
  42. */
  43. REG_OP(DenseToDenseSetOperation)
  44. .INPUT(x1, TensorType({DT_INT8, DT_INT16, DT_UINT16, DT_UINT8, \
  45. DT_INT32, DT_INT64, DT_STRING}))
  46. .INPUT(x2, TensorType({DT_INT8, DT_INT16, DT_UINT16, DT_UINT8, \
  47. DT_INT32, DT_INT64, DT_STRING}))
  48. .OUTPUT(y_indices, TensorType({DT_INT64}))
  49. .OUTPUT(y_values, TensorType({DT_INT8, DT_INT16, DT_UINT16, DT_UINT8, \
  50. DT_INT32, DT_INT64, DT_STRING}))
  51. .OUTPUT(y_shape, TensorType({DT_INT64}))
  52. .ATTR(set_operation, String, "")
  53. .ATTR(validate_indices, Bool, true)
  54. .OP_END_FACTORY_REG(DenseToDenseSetOperation)
  55. /**
  56. *@brief Applies set operation along last dimension of Tensor and SparseTensor . \n
  57. *@par Inputs:
  58. *Inputs include:
  59. * @li x1: A Tensor. Must be one of the following types: int8, int16, int32, int64, uint8, uint16, string.
  60. * @li x2_indices: A Tensor of type int64. 2D Tensor, indices of a SparseTensor.
  61. * @li x2_values: A Tensor. Must have the same type as set1. 1D Tensor, values of a SparseTensor.
  62. * @li x2_shape: A Tensor of type int64. 1D Tensor, shape of a SparseTensor . \n
  63. *@par Attributes:
  64. *@li set_operation: A string.
  65. *@li validate_indices: An optional bool. Defaults to True . \n
  66. *@par Outputs:
  67. *@li y_indices: A Tensor of type int64.
  68. *@li y_values: A Tensor. Has the same type as x1.
  69. *@li y_shape: A Tensor of type int64 . \n
  70. *@attention Constraints:
  71. *The implementation for DenseToSparseSetOperation on Ascend uses AICPU, with bad performance.
  72. *@par Third-party framework compatibility
  73. *@li compatible with tensorflow DenseToSparseSetOperation operator.
  74. */
  75. REG_OP(DenseToSparseSetOperation)
  76. .INPUT(x1, TensorType({DT_INT8, DT_INT16, DT_UINT16, DT_UINT8, \
  77. DT_INT32, DT_INT64, DT_STRING}))
  78. .INPUT(x2_indices, TensorType({DT_INT64}))
  79. .INPUT(x2_values, TensorType({DT_INT8, DT_INT16, DT_UINT16, DT_UINT8, \
  80. DT_INT32, DT_INT64, DT_STRING}))
  81. .INPUT(x2_shape, TensorType({DT_INT64}))
  82. .OUTPUT(y_indices, TensorType({DT_INT64}))
  83. .OUTPUT(y_values, TensorType({DT_INT8, DT_INT16, DT_UINT16, DT_UINT8, \
  84. DT_INT32, DT_INT64, DT_STRING}))
  85. .OUTPUT(y_shape, TensorType({DT_INT64}))
  86. .ATTR(set_operation, String, "")
  87. .ATTR(validate_indices, Bool, true)
  88. .OP_END_FACTORY_REG(DenseToSparseSetOperation)
  89. /**
  90. *@brief Applies set operation along last dimension of 2 SparseTensor inputs . \n
  91. *@par Inputs:
  92. *Inputs include:
  93. * @li x1_indices: A Tensor of type int64. 2D Tensor, indices of a SparseTensor.
  94. * @li x1_values: A Tensor. Must be one of the following types: int8, int16,
  95. int32, int64, uint8, uint16, string. 1D Tensor, values of a SparseTensor.
  96. * @li x1_shape: A Tensor of type int64. 1D Tensor, shape of a SparseTensor.
  97. * @li x2_indices: A Tensor of type int64. 2D Tensor, indices of a SparseTensor.
  98. * @li x2_values: A Tensor. Must have the same type as set1_values. 1D Tensor, values of a SparseTensor.
  99. * @li x2_shape: A Tensor of type int64. 1D Tensor, shape of a SparseTensor . \n
  100. *@par Attributes:
  101. *@li set_operation: A string.
  102. *@li validate_indices: An optional bool. Defaults to True . \n
  103. *@par Outputs:
  104. *@li y_indices: A Tensor of type int64.
  105. *@li y_values: A Tensor. Has the same type as x1_values.
  106. *@li y_shape: A Tensor of type int64 . \n
  107. *@attention Constraints:
  108. *The implementation for SparseToSparseSetOperation on Ascend uses AICPU, with bad performance.
  109. *@par Third-party framework compatibility
  110. *@li compatible with tensorflow SparseToSparseSetOperation operator.
  111. */
  112. REG_OP(SparseToSparseSetOperation)
  113. .INPUT(x1_indices, TensorType({DT_INT64}))
  114. .INPUT(x1_values, TensorType({DT_INT8, DT_INT16, DT_UINT16, DT_UINT8, \
  115. DT_INT32, DT_INT64, DT_STRING}))
  116. .INPUT(x1_shape, TensorType({DT_INT64}))
  117. .INPUT(x2_indices, TensorType({DT_INT64}))
  118. .INPUT(x2_values, TensorType({DT_INT8, DT_INT16, DT_UINT16, DT_UINT8, \
  119. DT_INT32, DT_INT64, DT_STRING}))
  120. .INPUT(x2_shape, TensorType({DT_INT64}))
  121. .OUTPUT(y_indices, TensorType({DT_INT64}))
  122. .OUTPUT(y_values, TensorType({DT_INT8, DT_INT16, DT_UINT16, DT_UINT8, \
  123. DT_INT32, DT_INT64, DT_STRING}))
  124. .OUTPUT(y_shape, TensorType({DT_INT64}))
  125. .ATTR(set_operation, String, "")
  126. .ATTR(validate_indices, Bool, true)
  127. .OP_END_FACTORY_REG(SparseToSparseSetOperation)
  128. /**
  129. *@brief Number of unique elements along last dimension of input set . \n
  130. *@par Inputs:
  131. *Inputs include:
  132. * @li set_indices: A Tensor of type int64. 2D Tensor, indices of a SparseTensor.
  133. * @li set_values: A Tensor. Must be one of the following types: int8, int16, int32, int64, uint8, uint16.
  134. * @li set_shape: A Tensor of type int64. 1D Tensor, shape of a SparseTensor . \n
  135. *@par Attributes:
  136. *validate_indices: An optional bool. Defaults to True . \n
  137. *@par Outputs:
  138. *size: A Tensor of type int32 . \n
  139. *@attention Constraints:
  140. *The implementation for SetSize on Ascend uses AICPU, with bad performance.
  141. *@par Third-party framework compatibility
  142. *@li compatible with tensorflow SetSize operator.
  143. */
  144. REG_OP(SetSize)
  145. .INPUT(set_indices, TensorType({DT_INT64}))
  146. .INPUT(set_values, TensorType({DT_INT8, DT_INT16, \
  147. DT_UINT8, DT_UINT16, DT_INT32, DT_INT64, DT_STRING}))
  148. .INPUT(set_shape, TensorType({DT_INT64}))
  149. .OUTPUT(size, TensorType({DT_INT32}))
  150. .ATTR(validate_indices, Bool, true)
  151. .OP_END_FACTORY_REG(SetSize)
  152. } // namespace ge
  153. #endif // OPS_BUILT_IN_OP_PROTO_INC_SET_OPS_H_

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