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.

state_ops.h 5.7 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
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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 state_ops.h
  18. * \brief
  19. */
  20. #ifndef OPS_BUILT_IN_OP_PROTO_INC_STATE_OPS_H_
  21. #define OPS_BUILT_IN_OP_PROTO_INC_STATE_OPS_H_
  22. #include "graph/operator_reg.h"
  23. namespace ge {
  24. /**
  25. *@brief Creates a variable tensor . \n
  26. *@par Inputs:
  27. *x: A tensor, used to assign a value to the variable tensor internally.
  28. The caller does not need to pass the value of the variable tensor . \n
  29. *@par Attributes:
  30. *@li index: An integer. Index of the input tensor.
  31. *@li value: A tensor, used to pass and record the value of the variable tensor.
  32. *@li container: A string. The container of the variable tensor.
  33. *@li shared_name: A string. The shared name of the variable tensor . \n
  34. *@par Outputs:
  35. *y: The created variable tensor . \n
  36. *@par Third-party framework compatibility
  37. *Compatible with the TensorFlow operator Variable.
  38. */
  39. REG_OP(Variable)
  40. .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, DT_UINT16, \
  41. DT_UINT8, DT_INT32, DT_INT64, DT_UINT32, DT_UINT64, DT_BOOL, DT_DOUBLE}))
  42. .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, DT_UINT16, \
  43. DT_UINT8, DT_INT32, DT_INT64, DT_UINT32, DT_UINT64, DT_BOOL, DT_DOUBLE}))
  44. .ATTR(index, Int, 0)
  45. .ATTR(value, Tensor, Tensor())
  46. .ATTR(container, String, "")
  47. .ATTR(shared_name, String, "")
  48. .OP_END_FACTORY_REG(Variable)
  49. /**
  50. *@brief Returns a temporary variable tensor. After the use of TemporaryVariable,
  51. pass the reference to the variable tensor to the matching DestroyTemporaryVariable op for destruction . \n
  52. *@par Attributes:
  53. *@li shape: A required list of int32 or int64. The shape of the variable tensor.
  54. *@li dtype: Required. The type of elements in the variable tensor.
  55. *@li var_name: An optional string. The name of the variable to be created . \n
  56. *@par Outputs:
  57. *y: The created variable tensor . \n
  58. *@par Third-party framework compatibility
  59. *Compatible with the TensorFlow operator TemporaryVariable.
  60. */
  61. REG_OP(TemporaryVariable)
  62. .OUTPUT(y, TensorType::ALL())
  63. .REQUIRED_ATTR(shape, ListInt)
  64. .REQUIRED_ATTR(dtype, Int)
  65. .ATTR(var_name, String, "")
  66. .OP_END_FACTORY_REG(TemporaryVariable)
  67. /**
  68. *@brief Destroys the temporary variable and returns its final value.
  69. All other uses of the temporary variable must have been executed before this op . \n
  70. *@par Inputs:
  71. *x: A reference to the temporary variable tensor . \n
  72. *@par Attributes:
  73. *var_name: A required string. Name of the temporary variable.
  74. Must be the same as the "var_name" attribute of the reference to the temporary variable tensor . \n
  75. *@par Outputs:
  76. *y: Final value of the reference to the temporary variable tensor . \n
  77. *@par Third-party framework compatibility
  78. *Compatible with the TensorFlow operator DestroyTemporaryVariable.
  79. */
  80. REG_OP(DestroyTemporaryVariable)
  81. .INPUT(x, TensorType::ALL())
  82. .OUTPUT(y, TensorType::ALL())
  83. .ATTR(var_name, String, "")
  84. .OP_END_FACTORY_REG(DestroyTemporaryVariable)
  85. /**
  86. *@brief Checks whether a tensor has been initialized. Outputs boolean scalar indicating whether the tensor has been initialized . \n
  87. *@par Inputs:
  88. *x: A tensor . \n
  89. *@par Outputs:
  90. *y: A tensor, indicating whether "x" has been initialized . \n
  91. *@par Third-party framework compatibility
  92. *Compatible with the TensorFlow operator IsVariableInitialized.
  93. */
  94. REG_OP(IsVariableInitialized)
  95. .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, DT_UINT16, DT_UINT8,
  96. DT_INT32, DT_INT64, DT_UINT32, DT_UINT64, DT_BOOL, DT_DOUBLE}))
  97. .OUTPUT(y, TensorType({DT_BOOL}))
  98. .OP_END_FACTORY_REG(IsVariableInitialized)
  99. /**
  100. *@brief Checks whether a tensor has been initialized. Outputs boolean scalar indicating whether the tensor has been initialized . \n
  101. *@par Inputs:
  102. *x: A tensor . \n
  103. *@par Outputs:
  104. *y: A tensor, indicating whether "x" has been initialized, and the data type is boolean . \n
  105. *@par Third-party framework compatibility
  106. *Compatible with the TensorFlow operator VarIsInitializedOp.
  107. */
  108. REG_OP(VarIsInitializedOp)
  109. .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, DT_UINT16, DT_UINT8,
  110. DT_INT32, DT_INT64, DT_UINT32, DT_UINT64, DT_BOOL, DT_DOUBLE}))
  111. .OUTPUT(y, TensorType({DT_BOOL}))
  112. .OP_END_FACTORY_REG(VarIsInitializedOp)
  113. /**
  114. *@brief Increments 'ref' until it reaches 'limit' . \n
  115. *@par Inputs:
  116. *Inputs include:
  117. *ref: A mutable Tensor. Must be one of the following types: int32, int64 . \n
  118. *@par Attributes:
  119. *limit: An int. If incrementing ref would bring it above limit, instead
  120. generates an 'OutOfRange' error . \n
  121. *@par Outputs:
  122. *y: A Tensor. Has the same type as ref . \n
  123. *@attention Constraints:
  124. *The implementation for CountUpTo on Ascend uses AICPU, with bad performance.
  125. *@par Third-party framework compatibility
  126. *@li compatible with tensorflow CountUpTo operator.
  127. */
  128. REG_OP(CountUpTo)
  129. .INPUT(ref, TensorType({DT_INT32, DT_INT64}))
  130. .OUTPUT(y, TensorType({DT_INT32, DT_INT64}))
  131. .ATTR(limit, Int, 0)
  132. .OP_END_FACTORY_REG(CountUpTo)
  133. } // namespace ge
  134. #endif // OPS_BUILT_IN_OP_PROTO_INC_STATE_OPS_H_

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