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.

randomdsa_ops.h 5.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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 randomdsa_ops.h
  18. * \brief
  19. */
  20. #ifndef OPS_BUILT_IN_OP_PROTO_INC_RANDOMDSA_OPS_H_
  21. #define OPS_BUILT_IN_OP_PROTO_INC_RANDOMDSA_OPS_H_
  22. #include <vector>
  23. #include "graph/operator_reg.h"
  24. #include "graph/operator.h"
  25. namespace ge {
  26. /**
  27. * @brief Generate DSA random bit mask for dropout. \n
  28. * @par Inputs:
  29. include:
  30. * @li count:The shape of the input tensor.
  31. * @li seed:If seed is set to be non-zero, the random number
  32. * generator is seeded by the given seed. Otherwise, it is seeded by a random seed
  33. * @li dropout:0-D. Number of bit 1 . \n
  34. * @par Attributes:
  35. * @li random_algorithm:The default value is "Philox". \n
  36. * @par Outputs:
  37. * y:Output (1-D) random number using uint data format . \n
  38. * @see DSAGenBitMask()
  39. */
  40. REG_OP(DSAGenBitMask)
  41. .INPUT(count, TensorType({DT_INT64}))
  42. .INPUT(seed, TensorType({DT_UINT64}))
  43. .INPUT(dropout, TensorType({DT_FLOAT16, DT_FLOAT, DT_BF16}))
  44. .OUTPUT(out, TensorType({DT_UINT8}))
  45. .ATTR(random_algorithm, String, "Philox")
  46. .OP_END_FACTORY_REG(DSAGenBitMask)
  47. /**
  48. * @brief Generate DSA truncatenormal data in random. \n
  49. * @par Inputs:
  50. include:
  51. * @li count: The shape of the input tensor.
  52. * @li seed: If seed is set to be non-zero, the random number
  53. * generator is seeded by the given seed. Otherwise, it is seeded by a random seed
  54. * @li mean: A Tensor. Must be one of the following types: float16, float32, double
  55. * @li stdev: A Tensor. Must be one of the following types: float16, float32, double. \n
  56. * @par Attributes:
  57. * @li random_algorithm:The default value is "Philox". \n
  58. * @par Outputs:
  59. * y:Output (1-D) random number using float and bf data format . \n
  60. * @see DSARandomTruncatedNormal()
  61. */
  62. REG_OP(DSARandomTruncatedNormal)
  63. .INPUT(count, TensorType({DT_INT64}))
  64. .INPUT(seed, TensorType({DT_UINT64}))
  65. .INPUT(mean, TensorType({DT_FLOAT16, DT_FLOAT, DT_BF16}))
  66. .INPUT(stdev, TensorType({DT_FLOAT16, DT_FLOAT, DT_BF16}))
  67. .OUTPUT(out, TensorType({DT_FLOAT16, DT_FLOAT32, DT_BF16}))
  68. .ATTR(random_algorithm, String, "Philox")
  69. .OP_END_FACTORY_REG(DSARandomTruncatedNormal)
  70. /**
  71. * @brief Generate DSA normal data in random. \n
  72. * @par Inputs:
  73. include:
  74. * @li count: The shape of the input tensor.
  75. * @li seed: If seed is set to be non-zero, the random number
  76. * generator is seeded by the given seed. Otherwise, it is seeded by a random seed
  77. * @li mean: A Tensor. Must be one of the following types: float16, float32, double
  78. * @li stdev: A Tensor. Must be one of the following types: float16, float32, double. \n
  79. * @par Attributes:
  80. * @li random_algorithm:The default value is "Philox". \n
  81. * @par Outputs:
  82. * y:Output (1-D) random number using float and bf data format . \n
  83. * @see DSARandomNormal()
  84. */
  85. REG_OP(DSARandomNormal)
  86. .INPUT(count, TensorType({DT_INT64}))
  87. .INPUT(seed, TensorType({DT_UINT64}))
  88. .INPUT(mean, TensorType({DT_FLOAT16, DT_FLOAT, DT_BF16}))
  89. .INPUT(stdev, TensorType({DT_FLOAT16, DT_FLOAT, DT_BF16}))
  90. .OUTPUT(out, TensorType({DT_FLOAT16, DT_FLOAT32, DT_BF16}))
  91. .ATTR(random_algorithm, String, "Philox")
  92. .OP_END_FACTORY_REG(DSARandomNormal)
  93. /**
  94. * @brief Generate DSA uniform data in random. \n
  95. * @par Inputs:
  96. include:
  97. * @li count: The shape of the input tensor.
  98. * @li seed: If seed is set to be non-zero, the random number
  99. * generator is seeded by the given seed. Otherwise, it is seeded by a random seed
  100. * @li low: A Tensor. Must be one of the following types: int, float, bf
  101. * @li high: A Tensor. Must be one of the following types: int, float, bf. \n
  102. * @par Attributes:
  103. * @li random_algorithm:The default value is "Philox". \n
  104. * @par Outputs:
  105. * y:Output (1-D) random number using float int and bf data format . \n
  106. * @see DSARandomUniform()
  107. */
  108. REG_OP(DSARandomUniform)
  109. .INPUT(count, TensorType({DT_INT64}))
  110. .INPUT(seed, TensorType({DT_UINT64}))
  111. .INPUT(low, TensorType({DT_BF16, DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT64, DT_UINT32, DT_UINT64}))
  112. .INPUT(high, TensorType({DT_BF16, DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT64, DT_UINT32, DT_UINT64}))
  113. .OUTPUT(out, TensorType({DT_BF16, DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT64, DT_UINT32, DT_UINT64}))
  114. .ATTR(random_algorithm, String, "Philox")
  115. .OP_END_FACTORY_REG(DSARandomUniform)
  116. }
  117. #endif // OPS_BUILT_IN_OP_PROTO_INC_RANDOMDSA_OPS_H

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