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.

array_ops.h 23 kB

modified: CMakeLists.txt modified: build.sh modified: ge/ge_runtime/runtime_model.cc modified: ge/ge_runtime/task/aicpu_task.cc modified: ge/ge_runtime/task/hccl_task.cc modified: ge/ge_runtime/task/label_goto_task.cc modified: ge/ge_runtime/task/label_switch_task.cc new file: tests/st/CMakeLists.txt new file: tests/st/cmake/graphengine.cmake new file: tests/st/framework/CMakeLists.txt new file: tests/st/framework/framework.cc new file: tests/st/framework/framework.h new file: tests/st/framework/stub_engine/CMakeLists.txt new file: tests/st/framework/stub_engine/common/constant/constant.h new file: tests/st/framework/stub_engine/engine/stub_engine.cc new file: tests/st/framework/stub_engine/engine/stub_engine.h new file: tests/st/framework/stub_engine/ops_kernel_store/host_cpu_ops_kernel_builder.cc new file: tests/st/framework/stub_engine/ops_kernel_store/host_cpu_ops_kernel_builder.h new file: tests/st/framework/stub_engine/ops_kernel_store/host_cpu_ops_kernel_info.cc new file: tests/st/framework/stub_engine/ops_kernel_store/host_cpu_ops_kernel_info.h new file: tests/st/framework/stub_engine/ops_kernel_store/op/host_op.cc new file: tests/st/framework/stub_engine/ops_kernel_store/op/host_op.h new file: tests/st/framework/stub_engine/ops_kernel_store/op/op.h new file: tests/st/framework/stub_engine/ops_kernel_store/op/op_factory.cc new file: tests/st/framework/stub_engine/ops_kernel_store/op/op_factory.h new file: tests/st/framework/stub_engine/proto/task.proto new file: tests/st/framework/stub_op_proto/array_ops.cc new file: tests/st/framework/stub_op_proto/array_ops.h new file: tests/st/framework/stub_op_proto/control_flow_ops.cc new file: tests/st/framework/stub_op_proto/control_flow_ops.h new file: tests/st/framework/stub_op_proto/elewise_calculation_ops.cc new file: tests/st/framework/stub_op_proto/elewise_calculation_ops.h new file: tests/st/framework/stub_op_proto/util/array_ops_shape_fns.cc new file: tests/st/framework/stub_op_proto/util/array_ops_shape_fns.h new file: tests/st/framework/stub_op_proto/util/axis_util.cc new file: tests/st/framework/stub_op_proto/util/axis_util.h new file: tests/st/framework/stub_op_proto/util/common_shape_fns.cc new file: tests/st/framework/stub_op_proto/util/common_shape_fns.h new file: tests/st/framework/stub_op_proto/util/error_code.h new file: tests/st/framework/stub_op_proto/util/error_util.cc new file: tests/st/framework/stub_op_proto/util/error_util.h new file: tests/st/framework/stub_op_proto/util/op_common_util.h new file: tests/st/framework/stub_op_proto/util/op_log.h new file: tests/st/framework/stub_op_proto/util/transfer_shape_according_to_format.cc new file: tests/st/framework/stub_op_proto/util/transfer_shape_according_to_format.h new file: tests/st/framework/stub_op_proto/util/util.cc new file: tests/st/framework/stub_op_proto/util/util.h new file: tests/st/framework/utils/assertion/graph_assertion.cc new file: tests/st/framework/utils/assertion/graph_assertion.h new file: tests/st/framework/utils/builder/graph_builder_utils.cc new file: tests/st/framework/utils/builder/graph_builder_utils.h new file: tests/st/framework/utils/builder/tensor_builder_utils.cc new file: tests/st/framework/utils/builder/tensor_builder_utils.h new file: tests/st/test.cc new file: tests/st/testcase/CMakeLists.txt new file: tests/st/testcase/test_framework_dummy.cc modified: CMakeLists.txt modified: build.sh modified: ge/ge_runtime/runtime_model.cc modified: ge/ge_runtime/task/aicpu_task.cc modified: ge/ge_runtime/task/hccl_task.cc modified: ge/ge_runtime/task/label_goto_task.cc modified: ge/ge_runtime/task/label_switch_task.cc new file: tests/st/CMakeLists.txt new file: tests/st/cmake/graphengine.cmake new file: tests/st/framework/CMakeLists.txt new file: tests/st/framework/framework.cc new file: tests/st/framework/framework.h new file: tests/st/framework/stub_engine/CMakeLists.txt new file: tests/st/framework/stub_engine/common/constant/constant.h new file: tests/st/framework/stub_engine/engine/stub_engine.cc new file: tests/st/framework/stub_engine/engine/stub_engine.h new file: tests/st/framework/stub_engine/ops_kernel_store/host_cpu_ops_kernel_builder.cc new file: tests/st/framework/stub_engine/ops_kernel_store/host_cpu_ops_kernel_builder.h new file: tests/st/framework/stub_engine/ops_kernel_store/host_cpu_ops_kernel_info.cc new file: tests/st/framework/stub_engine/ops_kernel_store/host_cpu_ops_kernel_info.h new file: tests/st/framework/stub_engine/ops_kernel_store/op/host_op.cc new file: tests/st/framework/stub_engine/ops_kernel_store/op/host_op.h new file: tests/st/framework/stub_engine/ops_kernel_store/op/op.h new file: tests/st/framework/stub_engine/ops_kernel_store/op/op_factory.cc new file: tests/st/framework/stub_engine/ops_kernel_store/op/op_factory.h new file: tests/st/framework/stub_engine/proto/task.proto new file: tests/st/framework/stub_op_proto/array_ops.cc new file: tests/st/framework/stub_op_proto/array_ops.h new file: tests/st/framework/stub_op_proto/control_flow_ops.cc new file: tests/st/framework/stub_op_proto/control_flow_ops.h new file: tests/st/framework/stub_op_proto/elewise_calculation_ops.cc new file: tests/st/framework/stub_op_proto/elewise_calculation_ops.h new file: tests/st/framework/stub_op_proto/util/array_ops_shape_fns.cc new file: tests/st/framework/stub_op_proto/util/array_ops_shape_fns.h new file: tests/st/framework/stub_op_proto/util/axis_util.cc new file: tests/st/framework/stub_op_proto/util/axis_util.h new file: tests/st/framework/stub_op_proto/util/common_shape_fns.cc new file: tests/st/framework/stub_op_proto/util/common_shape_fns.h new file: tests/st/framework/stub_op_proto/util/error_code.h new file: tests/st/framework/stub_op_proto/util/error_util.cc new file: tests/st/framework/stub_op_proto/util/error_util.h new file: tests/st/framework/stub_op_proto/util/op_common_util.h new file: tests/st/framework/stub_op_proto/util/op_log.h new file: tests/st/framework/stub_op_proto/util/transfer_shape_according_to_format.cc new file: tests/st/framework/stub_op_proto/util/transfer_shape_according_to_format.h new file: tests/st/framework/stub_op_proto/util/util.cc new file: tests/st/framework/stub_op_proto/util/util.h new file: tests/st/framework/utils/assertion/graph_assertion.cc new file: tests/st/framework/utils/assertion/graph_assertion.h new file: tests/st/framework/utils/builder/graph_builder_utils.cc new file: tests/st/framework/utils/builder/graph_builder_utils.h new file: tests/st/framework/utils/builder/tensor_builder_utils.cc new file: tests/st/framework/utils/builder/tensor_builder_utils.h new file: tests/st/test.cc new file: tests/st/testcase/CMakeLists.txt new file: tests/st/testcase/test_framework_dummy.cc modified: CMakeLists.txt modified: build.sh modified: ge/ge_runtime/runtime_model.cc modified: ge/ge_runtime/task/aicpu_task.cc modified: ge/ge_runtime/task/hccl_task.cc modified: ge/ge_runtime/task/label_goto_task.cc modified: ge/ge_runtime/task/label_switch_task.cc new file: tests/st/CMakeLists.txt new file: tests/st/cmake/graphengine.cmake new file: tests/st/framework/CMakeLists.txt new file: tests/st/framework/framework.cc new file: tests/st/framework/framework.h new file: tests/st/framework/stub_engine/CMakeLists.txt new file: tests/st/framework/stub_engine/common/constant/constant.h new file: tests/st/framework/stub_engine/engine/stub_engine.cc new file: tests/st/framework/stub_engine/engine/stub_engine.h new file: tests/st/framework/stub_engine/ops_kernel_store/host_cpu_ops_kernel_builder.cc new file: tests/st/framework/stub_engine/ops_kernel_store/host_cpu_ops_kernel_builder.h new file: tests/st/framework/stub_engine/ops_kernel_store/host_cpu_ops_kernel_info.cc new file: tests/st/framework/stub_engine/ops_kernel_store/host_cpu_ops_kernel_info.h new file: tests/st/framework/stub_engine/ops_kernel_store/op/host_op.cc new file: tests/st/framework/stub_engine/ops_kernel_store/op/host_op.h new file: tests/st/framework/stub_engine/ops_kernel_store/op/op.h new file: tests/st/framework/stub_engine/ops_kernel_store/op/op_factory.cc new file: tests/st/framework/stub_engine/ops_kernel_store/op/op_factory.h new file: tests/st/framework/stub_engine/proto/task.proto new file: tests/st/framework/stub_op_proto/array_ops.cc new file: tests/st/framework/stub_op_proto/array_ops.h new file: tests/st/framework/stub_op_proto/control_flow_ops.cc new file: tests/st/framework/stub_op_proto/control_flow_ops.h new file: tests/st/framework/stub_op_proto/elewise_calculation_ops.cc new file: tests/st/framework/stub_op_proto/elewise_calculation_ops.h new file: tests/st/framework/stub_op_proto/util/array_ops_shape_fns.cc new file: tests/st/framework/stub_op_proto/util/array_ops_shape_fns.h new file: tests/st/framework/stub_op_proto/util/axis_util.cc new file: tests/st/framework/stub_op_proto/util/axis_util.h new file: tests/st/framework/stub_op_proto/util/common_shape_fns.cc new file: tests/st/framework/stub_op_proto/util/common_shape_fns.h new file: tests/st/framework/stub_op_proto/util/error_code.h new file: tests/st/framework/stub_op_proto/util/error_util.cc new file: tests/st/framework/stub_op_proto/util/error_util.h new file: tests/st/framework/stub_op_proto/util/op_common_util.h new file: tests/st/framework/stub_op_proto/util/op_log.h new file: tests/st/framework/stub_op_proto/util/transfer_shape_according_to_format.cc new file: tests/st/framework/stub_op_proto/util/transfer_shape_according_to_format.h new file: tests/st/framework/stub_op_proto/util/util.cc new file: tests/st/framework/stub_op_proto/util/util.h new file: tests/st/framework/utils/assertion/graph_assertion.cc new file: tests/st/framework/utils/assertion/graph_assertion.h new file: tests/st/framework/utils/builder/graph_builder_utils.cc new file: tests/st/framework/utils/builder/graph_builder_utils.h new file: tests/st/framework/utils/builder/tensor_builder_utils.cc new file: tests/st/framework/utils/builder/tensor_builder_utils.h new file: tests/st/test.cc new file: tests/st/testcase/CMakeLists.txt new file: tests/st/testcase/test_framework_dummy.cc modified: CMakeLists.txt modified: build.sh modified: ge/ge_runtime/runtime_model.cc modified: ge/ge_runtime/task/aicpu_task.cc modified: ge/ge_runtime/task/hccl_task.cc modified: ge/ge_runtime/task/label_goto_task.cc modified: ge/ge_runtime/task/label_switch_task.cc new file: tests/st/CMakeLists.txt new file: tests/st/cmake/graphengine.cmake new file: tests/st/framework/CMakeLists.txt new file: tests/st/framework/framework.cc new file: tests/st/framework/framework.h new file: tests/st/framework/stub_engine/CMakeLists.txt new file: tests/st/framework/stub_engine/common/constant/constant.h new file: tests/st/framework/stub_engine/engine/stub_engine.cc new file: tests/st/framework/stub_engine/engine/stub_engine.h new file: tests/st/framework/stub_engine/ops_kernel_store/host_cpu_ops_kernel_builder.cc new file: tests/st/framework/stub_engine/ops_kernel_store/host_cpu_ops_kernel_builder.h new file: tests/st/framework/stub_engine/ops_kernel_store/host_cpu_ops_kernel_info.cc new file: tests/st/framework/stub_engine/ops_kernel_store/host_cpu_ops_kernel_info.h new file: tests/st/framework/stub_engine/ops_kernel_store/op/host_op.cc new file: tests/st/framework/stub_engine/ops_kernel_store/op/host_op.h new file: tests/st/framework/stub_engine/ops_kernel_store/op/op.h new file: tests/st/framework/stub_engine/ops_kernel_store/op/op_factory.cc new file: tests/st/framework/stub_engine/ops_kernel_store/op/op_factory.h new file: tests/st/framework/stub_engine/proto/task.proto new file: tests/st/framework/stub_op_proto/array_ops.cc new file: tests/st/framework/stub_op_proto/array_ops.h new file: tests/st/framework/stub_op_proto/control_flow_ops.cc new file: tests/st/framework/stub_op_proto/control_flow_ops.h new file: tests/st/framework/stub_op_proto/elewise_calculation_ops.cc new file: tests/st/framework/stub_op_proto/elewise_calculation_ops.h new file: tests/st/framework/stub_op_proto/util/array_ops_shape_fns.cc new file: tests/st/framework/stub_op_proto/util/array_ops_shape_fns.h new file: tests/st/framework/stub_op_proto/util/axis_util.cc new file: tests/st/framework/stub_op_proto/util/axis_util.h new file: tests/st/framework/stub_op_proto/util/common_shape_fns.cc new file: tests/st/framework/stub_op_proto/util/common_shape_fns.h new file: tests/st/framework/stub_op_proto/util/error_code.h new file: tests/st/framework/stub_op_proto/util/error_util.cc new file: tests/st/framework/stub_op_proto/util/error_util.h new file: tests/st/framework/stub_op_proto/util/op_common_util.h new file: tests/st/framework/stub_op_proto/util/op_log.h new file: tests/st/framework/stub_op_proto/util/transfer_shape_according_to_format.cc new file: tests/st/framework/stub_op_proto/util/transfer_shape_according_to_format.h new file: tests/st/framework/stub_op_proto/util/util.cc new file: tests/st/framework/stub_op_proto/util/util.h new file: tests/st/framework/utils/assertion/graph_assertion.cc new file: tests/st/framework/utils/assertion/graph_assertion.h new file: tests/st/framework/utils/builder/graph_builder_utils.cc new file: tests/st/framework/utils/builder/graph_builder_utils.h new file: tests/st/framework/utils/builder/tensor_builder_utils.cc new file: tests/st/framework/utils/builder/tensor_builder_utils.h new file: tests/st/testcase/CMakeLists.txt new file: tests/st/testcase/test_framework_dummy.cc
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711
  1. /**
  2. * Copyright 2021 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 array_ops.h
  18. * \brief
  19. */
  20. #ifndef OPS_BUILT_IN_OP_PROTO_INC_ARRAY_OPS_H_
  21. #define OPS_BUILT_IN_OP_PROTO_INC_ARRAY_OPS_H_
  22. #include "graph/operator_reg.h"
  23. #include "graph/operator.h"
  24. namespace ge {
  25. /**
  26. *@brief Finds unique elements in a 1D tensor. \n
  27. *@par Inputs:
  28. *x: 1D tensor.
  29. *Input "x" is a k-dimensional tensor. Inputs "num_lower" and "num_upper"
  30. are 0D scalars. \n
  31. *@par Attributes:
  32. *out_idx: An optional DType from: "int32, int64". Defaults to "int32". \n
  33. *@par Outputs:
  34. *@li y: "x" in the unique output "y".
  35. *@li idx: A tensor the same size as "x". The index of each value of "x". \n
  36. *@attention Constraints:
  37. *Unique runs on the Ascend AI CPU, which delivers poor performance. \n
  38. *@par Third-party framework compatibility
  39. *Compatible with the TensorFlow operator Unique.
  40. */
  41. REG_OP(Unique)
  42. .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, \
  43. DT_UINT16, DT_UINT8, DT_INT32, DT_INT64, DT_DOUBLE}))
  44. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, \
  45. DT_UINT16, DT_UINT8, DT_INT32, DT_INT64, DT_DOUBLE}))
  46. .OUTPUT(idx, TensorType({DT_INT32, DT_INT64}))
  47. .ATTR(out_idx, Type, DT_INT32)
  48. .OP_END_FACTORY_REG(Unique)
  49. /**
  50. *@brief Creates a constant tensor from a tensor-like object. This operator is used for inference.
  51. Operator Const has the same definition as operator Constant. \n
  52. *@par Attributes:
  53. *value: Required. The value and type of the resulting tensor, and no restrictions on type. \n
  54. *@par Outputs:
  55. *y: A constant tensor. \n
  56. *@par Third-party framework compatibility
  57. *Compatible with the TensorFlow operator Const.
  58. */
  59. REG_OP(Const)
  60. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, DT_UINT16, \
  61. DT_UINT8, DT_INT32, DT_INT64, DT_UINT32, DT_UINT64, DT_BOOL, DT_DOUBLE}))
  62. .ATTR(value, Tensor, Tensor())
  63. .OP_END_FACTORY_REG(Const)
  64. /**
  65. *@brief Creates a constant tensor for training. \n
  66. *@par Attributes:
  67. *value: Required. The value and type of the resulting tensor, and no restrictions on type. \n
  68. *@par Outputs:
  69. *y: The constant tensor. \n
  70. *@par Third-party framework compatibility
  71. *Compatible with the TensorFlow operator Const.
  72. */
  73. REG_OP(Constant)
  74. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, DT_UINT16, \
  75. DT_UINT8, DT_INT32, DT_INT64, DT_UINT32, DT_UINT64, DT_BOOL, DT_DOUBLE}))
  76. .ATTR(value, Tensor, Tensor())
  77. .OP_END_FACTORY_REG(Constant)
  78. /**
  79. *@brief Returns a copy of the input tensor. \n
  80. *@par Inputs:
  81. *x: A tensor. \n
  82. *@par Outputs:
  83. *y: A tensor. \n
  84. *@par Third-party framework compatibility
  85. *Compatible with the TensorFlow operator Snapshot.
  86. */
  87. REG_OP(Snapshot)
  88. .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, DT_UINT16, \
  89. DT_UINT8, DT_INT32, DT_INT64, DT_UINT32, DT_UINT64, DT_BOOL, DT_DOUBLE}))
  90. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, DT_UINT16, \
  91. DT_UINT8, DT_INT32, DT_INT64, DT_UINT32, DT_UINT64, DT_BOOL, DT_DOUBLE}))
  92. .OP_END_FACTORY_REG(Snapshot)
  93. /**
  94. *@brief Gives a guarantee to the runtime that the input tensor is a constant. \n
  95. *@par Inputs:
  96. *x: A tensor. \n
  97. *@par Outputs:
  98. *y: The input tensor. \n
  99. *@par Third-party framework compatibility
  100. *Compatible with the TensorFlow operator GuaranteeConst.
  101. */
  102. REG_OP(GuaranteeConst)
  103. .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, DT_UINT16, DT_UINT8,
  104. DT_INT32, DT_INT64, DT_UINT32, DT_UINT64, DT_BOOL, DT_DOUBLE}))
  105. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, DT_UINT16, DT_UINT8,
  106. DT_INT32, DT_INT64, DT_UINT32, DT_UINT64, DT_BOOL, DT_DOUBLE}))
  107. .OP_END_FACTORY_REG(GuaranteeConst)
  108. /**
  109. *@brief Returns the target shape for broadcasting shapes "x1" and "x2". \n
  110. *@par Inputs:
  111. *@li x1: A tensor of type int32 or int64. A shape.
  112. *@li x2: A tensor of the same type as "x1". The other shape. \n
  113. *@par Outputs:
  114. *y: A tensor. The broadcasted shape. \n
  115. *@par Third-party framework compatibility
  116. *Compatible with the TensorFlow operator BroadcastArgs.
  117. */
  118. REG_OP(BroadcastArgs)
  119. .INPUT(x1, TensorType({DT_INT32, DT_INT64}))
  120. .INPUT(x2, TensorType({DT_INT32, DT_INT64}))
  121. .OUTPUT(y, TensorType({DT_INT32, DT_INT64}))
  122. .OP_END_FACTORY_REG(BroadcastArgs)
  123. /**
  124. *@brief Outputs its input tensor as is and triggers an error if a gradient is requested. \n
  125. *@par Inputs:
  126. *x: A tensor. \n
  127. *@par Attributes:
  128. *message: Will be printed in the error at the attempt to request a gradient. \n
  129. *@par Outputs:
  130. *y: The input tensor. \n
  131. *@par Third-party framework compatibility
  132. *Compatible with the TensorFlow operator PreventGradient.
  133. */
  134. REG_OP(PreventGradient)
  135. .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, DT_UINT16, DT_UINT8,
  136. DT_INT32, DT_INT64, DT_UINT32, DT_UINT64, DT_BOOL, DT_DOUBLE}))
  137. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, DT_UINT16, DT_UINT8,
  138. DT_INT32, DT_INT64, DT_UINT32, DT_UINT64, DT_BOOL, DT_DOUBLE}))
  139. .ATTR(message, String, "")
  140. .OP_END_FACTORY_REG(PreventGradient)
  141. /**
  142. *@brief Returns the reduction indices for computing gradients of "x1" and "x2" with broadcast. \n
  143. *@par Inputs:
  144. *@li x1: A tensor of type int32 or int64.
  145. *@li x2: A tensor of type int32 or int64.
  146. "x2" has the same type as "x1". \n
  147. *@par Outputs:
  148. *@li y1: A tensor. Reduction indices of "x1".
  149. *@li y2: A tensor. Reduction indices of "x2". \n
  150. *@par Third-party framework compatibility
  151. *Compatible with the TensorFlow operator BroadcastGradientArgs.
  152. */
  153. REG_OP(BroadcastGradientArgs)
  154. .INPUT(x1, TensorType({DT_INT32, DT_INT64}))
  155. .INPUT(x2, TensorType({DT_INT32, DT_INT64}))
  156. .OUTPUT(y1, TensorType({DT_INT32, DT_INT64}))
  157. .OUTPUT(y2, TensorType({DT_INT32, DT_INT64}))
  158. .OP_END_FACTORY_REG(BroadcastGradientArgs)
  159. /**
  160. *@brief Stops gradient computation. None is returned for the node where the gradient computation is stopped.
  161. *@par Inputs:
  162. *x: A tensor. \n
  163. *@par Outputs:
  164. *y: The input tensor. \n
  165. *@par Third-party framework compatibility
  166. *Compatible with the TensorFlow operator StopGradient.
  167. */
  168. REG_OP(StopGradient)
  169. .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, DT_UINT16, DT_UINT8,
  170. DT_INT32, DT_INT64, DT_UINT32, DT_UINT64, DT_BOOL, DT_DOUBLE}))
  171. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, DT_UINT16, DT_UINT8,
  172. DT_INT32, DT_INT64, DT_UINT32, DT_UINT64, DT_BOOL, DT_DOUBLE}))
  173. .OP_END_FACTORY_REG(StopGradient)
  174. /**
  175. *@brief Return a tensor with the same shape and contents as input. \n
  176. *@par Inputs:
  177. *x: A tensor. \n
  178. *@par Outputs:
  179. *y: A tensor. \n
  180. *@par Third-party framework compatibility
  181. *Compatible with the TensorFlow operator Identity.
  182. */
  183. REG_OP(Identity)
  184. .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, DT_UINT16, DT_UINT8,
  185. DT_INT32, DT_INT64, DT_UINT32, DT_UINT64, DT_BOOL, DT_DOUBLE}))
  186. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, DT_UINT16, DT_UINT8,
  187. DT_INT32, DT_INT64, DT_UINT32, DT_UINT64, DT_BOOL, DT_DOUBLE}))
  188. .OP_END_FACTORY_REG(Identity)
  189. /**
  190. *@brief Returns a list of tensors with the same shapes and contents as the input tensors. \n
  191. *@par Inputs:
  192. *x: A list of input tensors. It's a dynamic input \n
  193. *@par Outputs:
  194. *y: A list of Tensor objects, with the same length as the input tensor list.
  195. It's a dynamic output. \n
  196. *@par Third-party framework compatibility
  197. *Compatible with the TensorFlow operator IdentityN.
  198. */
  199. REG_OP(IdentityN)
  200. .DYNAMIC_INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, DT_UINT16, DT_UINT8,
  201. DT_INT32, DT_INT64, DT_UINT32, DT_UINT64, DT_BOOL, DT_DOUBLE}))
  202. .DYNAMIC_OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, DT_UINT16, DT_UINT8,
  203. DT_INT32, DT_INT64, DT_UINT32, DT_UINT64, DT_BOOL, DT_DOUBLE}))
  204. .OP_END_FACTORY_REG(IdentityN)
  205. /**
  206. *@brief Inserts a dimension of 1 into a tensor's shape. Only the tensor shape is changed, without changing the data. \n
  207. *@par Inputs:
  208. *@li x: A tensor.
  209. *@li axis: The dimension index at which to expand. \n
  210. *@par Outputs:
  211. *y: A tensor. \n
  212. *@par Third-party framework compatibility
  213. *Compatible with the TensorFlow operator ExpandDims.
  214. */
  215. REG_OP(ExpandDims)
  216. .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, DT_UINT16, DT_UINT8, DT_INT32,
  217. DT_INT64, DT_UINT32, DT_UINT64, DT_BOOL, DT_DOUBLE}))
  218. .INPUT(axis, TensorType({DT_INT32, DT_INT64}))
  219. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, DT_UINT16, DT_UINT8, DT_INT32,
  220. DT_INT64, DT_UINT32, DT_UINT64, DT_BOOL, DT_DOUBLE}))
  221. .OP_END_FACTORY_REG(ExpandDims)
  222. /**
  223. *@brief Inserts a dimension of 1 into a tensor's shape. Only the tensor shape is changed, without changing the data. \n
  224. *@par Inputs:
  225. *@li x: Original tensor.
  226. *@li axis: List of ints. \n
  227. *@par Outputs:
  228. *y: Reshape tensor with same data as input. \n
  229. *@par Third-party framework compatibility
  230. *Compatible with the Onnx operator Unsqueeze.
  231. */
  232. REG_OP(Unsqueeze)
  233. .INPUT(x, TensorType({DT_FLOAT32, DT_INT32, DT_UINT8, DT_BOOL}))
  234. .OUTPUT(y, TensorType({DT_FLOAT32, DT_INT32, DT_UINT8, DT_BOOL}))
  235. .ATTR(axes, ListInt, {})
  236. .OP_END_FACTORY_REG(Unsqueeze)
  237. /**
  238. *@brief Reshapes a tensor. Only the tensor shape is changed, without changing the data. \n
  239. *@par Inputs:
  240. *@li x: A tensor.
  241. *@li shape: A tensor. Defines the shape of the output tensor. \n
  242. *@par Attributes:
  243. *@li axis: An optional int32 or int64. The first dimension to reshape. Defaults to "0".
  244. *@li num_axes: An optional int32 or int64. The extent of the reshape. Defaults to "-1". \n
  245. *@par Outputs:
  246. *y: A tensor. \n
  247. *@par Attention:
  248. *This operator cannot be directly called by the acllopExecute API. \n
  249. *@par Third-party framework compatibility
  250. *@li Compatible with the TensorFlow operator Reshape.
  251. *@li Compatible with the Caffe operator Reshape.
  252. */
  253. REG_OP(Reshape)
  254. .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, DT_UINT16, DT_UINT8, DT_INT32,
  255. DT_INT64, DT_UINT32, DT_UINT64, DT_BOOL, DT_DOUBLE}))
  256. .INPUT(shape, TensorType({DT_INT32, DT_INT64}))
  257. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, DT_UINT16, DT_UINT8, DT_INT32,
  258. DT_INT64, DT_UINT32, DT_UINT64, DT_BOOL, DT_DOUBLE}))
  259. .ATTR(axis, Int, 0)
  260. .ATTR(num_axes, Int, -1)
  261. .OP_END_FACTORY_REG(Reshape)
  262. /**
  263. *@brief Removes dimensions of size 1 from the shape of a tensor. \n
  264. *@par Inputs:
  265. *x: A tensor. \n
  266. *@par Attributes:
  267. *axis: An optional list of int32 or int64. If not specified, squeezes all dimensions of size 1. If specified, only squeezes the dimensions listed. It is an error to squeeze a dimension that is not 1. \n
  268. *@par Outputs:
  269. *y: A tensor. \n
  270. *@par Third-party framework compatibility
  271. *Compatible with the TensorFlow operator Squeeze.
  272. */
  273. REG_OP(Squeeze)
  274. .INPUT(x, TensorType::ALL())
  275. .OUTPUT(y, TensorType::ALL())
  276. .ATTR(axis, ListInt, {})
  277. .OP_END_FACTORY_REG(Squeeze)
  278. /**
  279. *@brief Returns an integer representing the rank of input tensor. The rank of a tensor is the number of indices required to uniquely select each element of the tensor, that is, the dimension size of the tensor. \n
  280. *@par Inputs:
  281. *x: A tensor. \n
  282. *@par Outputs:
  283. *y: A tensor. The rank of input tensor. \n
  284. *@par Third-party framework compatibility
  285. *Compatible with the TensorFlow operator Rank.
  286. */
  287. REG_OP(Rank)
  288. .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, DT_UINT16, DT_UINT8,
  289. DT_INT32, DT_INT64, DT_UINT32, DT_UINT64, DT_BOOL, DT_DOUBLE}))
  290. .OUTPUT(y, TensorType({DT_INT32}))
  291. .OP_END_FACTORY_REG(Rank)
  292. /**
  293. *@brief Returns the size of a tensor, that is, an integer of the number of elements of the tensor. \n
  294. *@par Inputs:
  295. *x: A tensor. \n
  296. *@par Attributes:
  297. *out_type: An optional int32 or int64. The output data type. Defaults to "int32". \n
  298. *@par Outputs:
  299. *y: A tensor. The size of the input tensor. \n
  300. *@par Third-party framework compatibility
  301. *Compatible with the TensorFlow operator Size.
  302. */
  303. REG_OP(Size)
  304. .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, DT_UINT16, DT_UINT8,
  305. DT_INT32, DT_INT64, DT_UINT32, DT_UINT64, DT_BOOL, DT_DOUBLE}))
  306. .OUTPUT(y, TensorType({DT_INT32,DT_INT64}))
  307. .ATTR(dtype, Int, DT_INT32)
  308. .OP_END_FACTORY_REG(Size)
  309. /**
  310. *@brief Input data for other operators. \n
  311. *@par Inputs:
  312. *x: A tensor. \n
  313. *@par Attributes:
  314. *index: Index of the input tensor.The data type must be int32 or int64.
  315. Assume that net has three data nodes, one should be set 0, another should
  316. be set 1, and the left should be set 2. \n
  317. *@par Outputs:
  318. *y: A tensor. \n
  319. *@par Third-party framework compatibility
  320. *Compatible with the Caffe operator Data.
  321. */
  322. REG_OP(Data)
  323. .INPUT(x, TensorType::ALL())
  324. .OUTPUT(y, TensorType::ALL())
  325. .ATTR(index, Int, 0)
  326. .OP_END_FACTORY_REG(Data)
  327. /**
  328. *@brief Inserts a placeholder for a tensor that will be always fed. \n
  329. *@par Inputs:
  330. *x: A tensor. \n
  331. *@par Attributes:
  332. *@li peerIndex: An integer type. The index of the corresponding "end" node connected to.
  333. *@li parentId: A string, used to check if the nodes are from the saved parent node.
  334. *@li parentOpType: A string. Op type of the original node.
  335. *@li anchorIndex: An integer, used to check if the node is from the saved anchor. \n
  336. *@par Outputs:
  337. *y: The created placeholder tensor. \n
  338. *@par Third-party framework compatibility
  339. *Compatible with the TensorFlow operator PlaceHolder.
  340. */
  341. REG_OP(PlaceHolder)
  342. .INPUT(x, TensorType::ALL())
  343. .OUTPUT(y, TensorType::ALL())
  344. .ATTR(peerIndex, Int, 0) // the index of the corresponding 'end' node it's connected to
  345. .ATTR(parentId, String, "") // check if these node are from save parent node
  346. .ATTR(parentOpType, String, "") // op type of original node
  347. .ATTR(anchorIndex, Int, 0) // check if these node are from save anchor
  348. .OP_END_FACTORY_REG(PlaceHolder)
  349. /**
  350. *@brief Inserts a placeholder with default value for a tensor. \n
  351. *@par Inputs:
  352. *x: A tensor. \n
  353. *@par Attributes:
  354. *@li dtype: data type of tensor.
  355. *@li shape: tensor shape. \n
  356. *@par Outputs:
  357. *y: The created placeholder tensor. \n
  358. *@par Third-party framework compatibility
  359. *Compatible with the TensorFlow operator PlaceholderWithDefault.
  360. */
  361. REG_OP(PlaceholderWithDefault)
  362. .INPUT(x, TensorType::ALL())
  363. .OUTPUT(y, TensorType::ALL())
  364. .REQUIRED_ATTR(shape, ListInt)
  365. .OP_END_FACTORY_REG(PlaceholderWithDefault)
  366. /**
  367. *@brief Reads and returns the value of the input variable tensor. \n
  368. *@par Inputs:
  369. *x: A tensor. \n
  370. *@par Attributes:
  371. *dtype: An optional int32 or int64. The output data type. Defaults to int32. \n
  372. *@par Outputs:
  373. *y: A tensor. \n
  374. *@par Third-party framework compatibility
  375. *Compatible with the TensorFlow operator ReadVariableOp.
  376. */
  377. REG_OP(ReadVariableOp)
  378. .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, DT_UINT16, DT_UINT8,
  379. DT_INT32, DT_INT64, DT_UINT32, DT_UINT64, DT_BOOL, DT_DOUBLE}))
  380. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, DT_UINT16, DT_UINT8,
  381. DT_INT32, DT_INT64, DT_UINT32, DT_UINT64, DT_BOOL, DT_DOUBLE}))
  382. .ATTR(dtype, Int, DT_INT32)
  383. .OP_END_FACTORY_REG(ReadVariableOp)
  384. /**
  385. *@brief Mark outputs of one sub graph which partitioned by engine type.
  386. *@par Inputs:
  387. *x: A tensor. \n
  388. *@par Outputs:
  389. *y: A tensor. \n
  390. *@par Attributes:
  391. *@li peerIndex: The index of the corresponding 'placeholder' node it's connected to.
  392. *@li parentOpType: Op type of original node.
  393. *@par Restrictions:
  394. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  395. */
  396. REG_OP(End)
  397. .INPUT(x, TensorType::ALL())
  398. .OUTPUT(y, TensorType::ALL())
  399. .ATTR(peerIndex, Int, 0)
  400. .ATTR(parentOpType, String, "")
  401. .OP_END_FACTORY_REG(End)
  402. /**
  403. *@brief Operations for writing summary data, for use in analysis and visualization.
  404. *@par Inputs:
  405. * One input:
  406. *x: Collections of summary data.
  407. *@par Restrictions:
  408. *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use.
  409. */
  410. REG_OP(Summary)
  411. .INPUT(x, TensorType::ALL())
  412. .OP_END_FACTORY_REG(Summary)
  413. /**
  414. *@brief Returns the shape of a tensor. \n
  415. *@par Inputs:
  416. *x: A tensor. \n
  417. *@par Attributes:
  418. *dtype: An optional int32 or int64. The output data type. Defaults to int32. \n
  419. *@par Outputs:
  420. *y: A tensor. The shape of the input tensor. \n
  421. *@par Third-party framework compatibility
  422. *Compatible with the TensorFlow operator Size.
  423. */
  424. REG_OP(Shape)
  425. .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, DT_UINT16, DT_UINT8,
  426. DT_INT32, DT_INT64, DT_UINT32, DT_UINT64, DT_BOOL, DT_DOUBLE}))
  427. .OUTPUT(y, TensorType({DT_INT32, DT_INT64}))
  428. .ATTR(dtype, Int, DT_INT32)
  429. .OP_END_FACTORY_REG(Shape)
  430. /**
  431. *@brief Returns shape of tensors. \n
  432. *@par Inputs:
  433. *x: A list of input tensors. It's a dynamic input. \n
  434. *@par Attributes:
  435. *dtype: An optional int32 or int64. The output data type. Defaults to "int32". \n
  436. *@par Outputs:
  437. *y: A list of tensors with the same length as the input list of tensors.
  438. It's a dynamic output. \n
  439. *@par Third-party framework compatibility
  440. *Compatible with the TensorFlow operator ShapeN.
  441. */
  442. REG_OP(ShapeN)
  443. .DYNAMIC_INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, DT_UINT16, DT_UINT8,
  444. DT_INT32, DT_INT64, DT_UINT32, DT_UINT64, DT_BOOL, DT_DOUBLE}))
  445. .DYNAMIC_OUTPUT(y, TensorType({DT_INT32, DT_INT64}))
  446. .ATTR(dtype, Int, DT_INT32)
  447. .OP_END_FACTORY_REG(ShapeN)
  448. /**
  449. *@brief Creates a tensor with the given "shape" and "dtype". \n
  450. *@par Inputs:
  451. *shape: The shape of the output tensor. \n
  452. *@par Attributes:
  453. *@li dtype: Optional. The data type of the output tensor. Defaults to "int32".
  454. *@li init: An optional bool. If true, initializes the returned tensor with the default value of "dtype". Defaults to "false". \n
  455. *@par Outputs:
  456. *y: A tensor. \n
  457. *@par Third-party framework compatibility
  458. *Compatible with the TensorFlow operator Empty.
  459. */
  460. REG_OP(Empty)
  461. .INPUT(shape, TensorType({DT_INT32}))
  462. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, DT_UINT16, DT_UINT8,
  463. DT_INT32, DT_INT64, DT_UINT32, DT_UINT64, DT_BOOL, DT_DOUBLE}))
  464. .ATTR(dtype, Int, DT_INT32)
  465. .ATTR(init, Bool, 0)
  466. .OP_END_FACTORY_REG(Empty)
  467. /**
  468. *@brief Returns locations of nonzero / true values in a tensor. \n
  469. *@par Inputs:
  470. *Including:
  471. *x: A Tensor. Must be one of the following types:
  472. DT_DOUBLE, DT_FLOAT, DT_FLOAT16, DT_INT8, DT_UINT8, DT_INT16,
  473. DT_UINT16, DT_INT32, DT_UINT32, DT_INT64, DT_UINT64, DT_BOOL. \n
  474. *@par Outputs:
  475. *y: A Tensor of type DT_INT64. \n
  476. *@attention Constraints:
  477. *Where runs on the Ascend AI CPU, which delivers poor performance.\n
  478. *@par Third-party framework compatibility
  479. *Compatible with the TensorFlow operator Where.
  480. */
  481. REG_OP(Where)
  482. .INPUT(x, TensorType({DT_DOUBLE, DT_FLOAT, DT_FLOAT16, DT_INT8, DT_UINT8, DT_INT16, \
  483. DT_UINT16, DT_INT32, DT_UINT32, DT_INT64, DT_UINT64, DT_BOOL}))
  484. .OUTPUT(y, TensorType({DT_INT64}))
  485. .OP_END_FACTORY_REG(Where)
  486. /**
  487. *@brief Change the shape of output according to the attr outShape
  488. *
  489. *@par Inputs:
  490. *x: A Tensor. \n
  491. *@par Outputs:
  492. *y: A Tensor. Has the same type as "x".It's required and the value should equal to output_num. \n
  493. *@par Attributes:
  494. *outShape: The shape of output will be inferred according to the attribute
  495. */
  496. REG_OP(TransShape)
  497. .INPUT(x, TensorType::ALL())
  498. .OUTPUT(y, TensorType::ALL())
  499. .ATTR(outShape,ListInt ,{})
  500. .OP_END_FACTORY_REG(TransShape);
  501. /**
  502. * @brief sort_v2.
  503. * @par Inputs:
  504. * @li x: An ND tensor of type float16.
  505. * @par Attributes:
  506. * @li axis: An optional int. The dimension to sort along. This value defaults to -1.
  507. * @li descending: An optional bool. Controls the sorting order (ascending or descending). This value defaults to False.
  508. * @par Outputs:
  509. * @li y: An ND tensor of type float16.
  510. * @attention Constraints:
  511. * @li Axis should select the last dim.
  512. * @li When the sorting data is less than 150K, it is recommended to use this tbe ops,
  513. and the descending performance is better than the ascending.
  514. * @li The upper limit of data on Ascend910 is 2000K.
  515. */
  516. REG_OP(SortV2)
  517. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  518. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE}))
  519. .ATTR(axis, Int, -1)
  520. .ATTR(descending, Bool, false)
  521. .OP_END_FACTORY_REG(SortV2)
  522. /**
  523. * @brief Expand the input tensor to a compatible shape. \n
  524. * @par Inputs:
  525. * One inputs, including:
  526. * @li x: A Tensor. Must be one of the following types:
  527. * float16, float32, int32, int8 ,uint8. \n
  528. * @li shape: A Tensor to specify the shape that the input tensor expanded to. \n
  529. * @par Outputs:
  530. * @li y: A Tensor. Has the same type as "x", and the shape specified by input and attr shape \n
  531. * @par Third-party framework compatibility
  532. * Compatible with the ONNX operator Expand.
  533. */
  534. REG_OP(Expand)
  535. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT8, DT_UINT8}))
  536. .INPUT(shape, TensorType({DT_INT16, DT_INT32, DT_INT64}))
  537. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT8, DT_UINT8}))
  538. .OP_END_FACTORY_REG(Expand)
  539. /**
  540. * @brief Expand the input tensor to a compatible shape. \n
  541. * @par Inputs:
  542. * One inputs, including:
  543. * @li x: A Tensor. Must be one of the following types:
  544. * float16, float32, int32, int8 ,uint8. \n
  545. * @par Attributes:
  546. * @li shape: A required listInt to specify the shape that the input tensor expanded to. \n
  547. * @par Outputs:
  548. * @li y: A Tensor. Has the same type as "x", and the shape specified by input and attr shape \n
  549. * @par Third-party framework compatibility
  550. * Compatible with the ONNX operator Expand.
  551. */
  552. REG_OP(ExpandD)
  553. .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT8, DT_UINT8}))
  554. .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT8, DT_UINT8}))
  555. .REQUIRED_ATTR(shape, ListInt)
  556. .OP_END_FACTORY_REG(ExpandD)
  557. } // namespace ge
  558. #endif // OPS_BUILT_IN_OP_PROTO_INC_ARRAY_OPS_H_

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