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.

acl_op_compiler.h 4.7 kB

4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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 INC_EXTERNAL_ACL_ACL_OP_COMPILER_H_
  17. #define INC_EXTERNAL_ACL_ACL_OP_COMPILER_H_
  18. #include "acl_base.h"
  19. #include "acl_op.h"
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. typedef enum aclCompileType {
  24. ACL_COMPILE_SYS,
  25. ACL_COMPILE_UNREGISTERED
  26. } aclopCompileType;
  27. typedef enum {
  28. ACL_PRECISION_MODE,
  29. ACL_AICORE_NUM,
  30. ACL_AUTO_TUNE_MODE,
  31. ACL_OP_SELECT_IMPL_MODE,
  32. ACL_OPTYPELIST_FOR_IMPLMODE,
  33. ACL_OP_DEBUG_LEVEL,
  34. ACL_DEBUG_DIR,
  35. ACL_OP_COMPILER_CACHE_MODE,
  36. ACL_OP_COMPILER_CACHE_DIR,
  37. ACL_OP_PERFORMANCE_MODE
  38. } aclCompileOpt;
  39. typedef enum aclCompileFlag {
  40. ACL_OP_COMPILE_DEFAULT,
  41. ACL_OP_COMPILE_FUZZ
  42. } aclOpCompileFlag;
  43. /**
  44. * @ingroup AscendCL
  45. * @brief compile op
  46. *
  47. * @param opType [IN] op type
  48. * @param numInputs [IN] number of inputs
  49. * @param inputDesc [IN] pointer to array of input tensor descriptions
  50. * @param numOutputs [IN] number of outputs
  51. * @param outputDesc [IN] pointer to array of output tensor descriptions
  52. * @param attr [IN] pointer to instance of aclopAttr.
  53. * may pass nullptr if the op has no attribute
  54. * @param engineType [IN] engine type
  55. * @param compileFlag [IN] compile flag
  56. * @param opPath [IN] path of op
  57. *
  58. * @retval ACL_SUCCESS The function is successfully executed.
  59. * @retval OtherValues Failure
  60. */
  61. ACL_FUNC_VISIBILITY aclError aclopCompile(const char *opType,
  62. int numInputs,
  63. const aclTensorDesc *const inputDesc[],
  64. int numOutputs,
  65. const aclTensorDesc *const outputDesc[],
  66. const aclopAttr *attr,
  67. aclopEngineType engineType,
  68. aclopCompileType compileFlag,
  69. const char *opPath);
  70. /**
  71. * @ingroup AscendCL
  72. * @brief compile and execute op
  73. *
  74. * @param opType [IN] op type
  75. * @param numInputs [IN] number of inputs
  76. * @param inputDesc [IN] pointer to array of input tensor descriptions
  77. * @param inputs [IN] pointer to array of input buffers
  78. * @param numOutputs [IN] number of outputs
  79. * @param outputDesc [IN] pointer to array of output tensor descriptions
  80. * @param outputs [IN] pointer to array of outputs buffers
  81. * @param attr [IN] pointer to instance of aclopAttr.
  82. * may pass nullptr if the op has no attribute
  83. * @param engineType [IN] engine type
  84. * @param compileFlag [IN] compile flag
  85. * @param opPath [IN] path of op
  86. * @param stream [IN] stream handle
  87. *
  88. * @retval ACL_SUCCESS The function is successfully executed.
  89. * @retval OtherValues Failure
  90. */
  91. ACL_FUNC_VISIBILITY aclError aclopCompileAndExecute(const char *opType,
  92. int numInputs, const aclTensorDesc *const inputDesc[], const aclDataBuffer *const inputs[],
  93. int numOutputs, const aclTensorDesc *const outputDesc[], aclDataBuffer *const outputs[],
  94. const aclopAttr *attr, aclopEngineType engineType, aclopCompileType compileFlag,
  95. const char *opPath, aclrtStream stream);
  96. /**
  97. * @ingroup AscendCL
  98. * @brief set compile option
  99. *
  100. * @param aclCompileOpt [IN] compile option
  101. * @param value [IN] pointer for the option value
  102. *
  103. * @retval ACL_SUCCESS The function is successfully executed.
  104. * @retval OtherValues Failure
  105. */
  106. ACL_FUNC_VISIBILITY aclError aclSetCompileopt(aclCompileOpt opt, const char *value);
  107. /**
  108. * @ingroup AscendCL
  109. * @brief set compile flag
  110. *
  111. * @param flag [IN] compile flag, ACL_OP_COMPILE_DEFAULT means compile with default mode
  112. * ACL_OP_COMPILE_FUZZ means compile with fuzz mode
  113. *
  114. * @retval ACL_SUCCESS The function is successfully executed.
  115. * @retval OtherValues Failure
  116. */
  117. ACL_FUNC_VISIBILITY aclError aclopSetCompileFlag(aclOpCompileFlag flag);
  118. #ifdef __cplusplus
  119. }
  120. #endif
  121. #endif // INC_EXTERNAL_ACL_ACL_OP_COMPILER_H_

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