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

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

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