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.

map_ops.h 4.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /**
  2. * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved.
  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 map_ops.h
  18. * \brief
  19. */
  20. #ifndef OPS_BUILT_IN_OP_PROTO_INC_MAP_OPS_H_
  21. #define OPS_BUILT_IN_OP_PROTO_INC_MAP_OPS_H_
  22. #include "graph/operator_reg.h"
  23. namespace ge {
  24. /**
  25. * @brief Returns whether the given key exists in the map. \n
  26. * @par Inputs:
  27. * @li input_handle: A scalar Tensor of type variant. The original map.
  28. * @li key: The key to check. Supports int32, int64, string. \n
  29. * @par Outputs:
  30. * has_key: A scalar Tensor of type bool. Whether the key is already in the map or not. \n
  31. * @par Third-party framework compatibility.
  32. * Compatible with tensorflow TensorMapHasKey operator.
  33. */
  34. REG_OP(TensorMapHasKey)
  35. .INPUT(input_handle, TensorType({DT_VARIANT}))
  36. .INPUT(key, TensorType({DT_INT32, DT_INT64, DT_STRING}))
  37. .OUTPUT(has_key, TensorType({DT_BOOL}))
  38. .OP_END_FACTORY_REG(TensorMapHasKey)
  39. /**
  40. * @brief Returns a tensor map with item from given key erased. \n
  41. * @par Inputs:
  42. * @li input_handle: A scalar Tensor of type variant. The original map.
  43. * @li key: The key of the value to be erased. Supports int32, int64, string. \n
  44. * @par Outputs:
  45. * output_handle: A scalar Tensor of type variant. The map with value from given key removed. \n
  46. * @par Third-party framework compatibility.
  47. * Compatible with tensorflow TensorMapErase operator.
  48. */
  49. REG_OP(TensorMapErase)
  50. .INPUT(input_handle, TensorType({DT_VARIANT}))
  51. .INPUT(key, TensorType({DT_INT32, DT_INT64, DT_STRING}))
  52. .OUTPUT(output_handle, TensorType({DT_VARIANT}))
  53. .OP_END_FACTORY_REG(TensorMapErase)
  54. /**
  55. * @brief Returns a map that is the 'input_handle'
  56. with the given key-value pair inserted. \n
  57. * @par Inputs:
  58. * @li input_handle: The original map, Must be type: DT_VARIANT.
  59. * @li key: A Tensor,the key to be inserted.Must be one of
  60. the following types: int32, int64, string.
  61. * @li value: A Tensor,the value to be inserted.Must be
  62. one of BasicType types. \n
  63. * @par Outputs:
  64. * output_handle: The map with key and value inserted.
  65. Must be type: DT_VARIANT. \n
  66. */
  67. REG_OP(TensorMapInsert)
  68. .INPUT(input_handle, TensorType({DT_VARIANT}))
  69. .INPUT(key, TensorType({DT_INT32, DT_INT64, DT_STRING}))
  70. .INPUT(value, BasicType)
  71. .OUTPUT(output_handle, TensorType({DT_VARIANT}))
  72. .OP_END_FACTORY_REG(TensorMapInsert)
  73. /**
  74. * @brief Returns the value from a given key in a tensor map . \n
  75. * @par Inputs:
  76. * @li input_handle: The input map. Must be type: DT_VARIANT.
  77. * @li key: A Tensor, the key to be looked up. Must be one of
  78. the following types: int32,int64,string . \n
  79. * @par Attributes:
  80. * value_dtype: A int. Representing the type of value . \n
  81. * @par Outputs:
  82. * value: A Tensor,the value found from the given key.
  83. */
  84. REG_OP(TensorMapLookup)
  85. .INPUT(input_handle, TensorType({DT_VARIANT}))
  86. .INPUT(key, TensorType({DT_INT32, DT_INT64, DT_STRING}))
  87. .OUTPUT(value, BasicType)
  88. .REQUIRED_ATTR(value_dtype, Type)
  89. .OP_END_FACTORY_REG(TensorMapLookup)
  90. /**
  91. * @brief return TensorMap Size. \n
  92. *
  93. * @par Inputs:
  94. * input_handle: A Tensor. Must be one of the following types: variant. \n
  95. *
  96. * @par Outputs:
  97. * size: A Tensor. Must be one of the following types: int32. \n
  98. */
  99. REG_OP(TensorMapSize)
  100. .INPUT(input_handle, TensorType({DT_VARIANT}))
  101. .OUTPUT(size, TensorType({DT_INT32}))
  102. .OP_END_FACTORY_REG(TensorMapSize)
  103. /**
  104. * @brief Return TensorMapStackKeys \n
  105. *
  106. * @par Inputs:
  107. * input_handle: A Tensor. Must be one of the following types: variant. \n
  108. *
  109. * @par Outputs:
  110. * keys: A Tensor. Must be one of the following types: int32, int64, string. \n
  111. *
  112. * @par Attributes:
  113. * key_dtype: An required param. It is the dtype of the key.
  114. */
  115. REG_OP(TensorMapStackKeys)
  116. .INPUT(input_handle, TensorType({DT_VARIANT}))
  117. .OUTPUT(keys, TensorType({DT_INT32, DT_INT64, DT_STRING}))
  118. .REQUIRED_ATTR(key_dtype, Type)
  119. .OP_END_FACTORY_REG(TensorMapStackKeys)
  120. /**
  121. * @brief Creates and returns an empty tensor map. \n
  122. * @par Outputs:
  123. * handle: An empty tensor map . \n
  124. * @par Third-party framework compatibility.
  125. * Compatible with tensorflow EmptyTensorMap operator.
  126. */
  127. REG_OP(EmptyTensorMap)
  128. .OUTPUT(handle, TensorType({DT_VARIANT}))
  129. .OP_END_FACTORY_REG(EmptyTensorMap)
  130. } // namespace ge
  131. #endif // OPS_BUILT_IN_OP_PROTO_INC_MAP_OPS_H_

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