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.

prof_callback.h 4.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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 MSPROFILER_PROF_CALLBACK_H_
  17. #define MSPROFILER_PROF_CALLBACK_H_
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif // __cplusplus
  21. #include "stddef.h"
  22. #include "stdint.h"
  23. /**
  24. * @name MsprofErrorCode
  25. * @brief error code
  26. */
  27. enum MsprofErrorCode {
  28. MSPROF_ERROR_NONE = 0,
  29. MSPROF_ERROR_MEM_NOT_ENOUGH,
  30. MSPROF_ERROR_GET_ENV,
  31. MSPROF_ERROR_CONFIG_INVALID,
  32. MSPROF_ERROR_ACL_JSON_OFF,
  33. MSPROF_ERROR,
  34. };
  35. #define MSPROF_ENGINE_MAX_TAG_LEN (31)
  36. /**
  37. * @name ReporterData
  38. * @brief struct of data to report
  39. */
  40. struct ReporterData {
  41. char tag[MSPROF_ENGINE_MAX_TAG_LEN + 1]; // the sub-type of the module, data with different tag will be writen
  42. int deviceId; // the index of device
  43. size_t dataLen; // the length of send data
  44. unsigned char *data; // the data content
  45. };
  46. /**
  47. * @name MsprofReporterModuleId
  48. * @brief module id of data to report
  49. */
  50. enum MsprofReporterModuleId {
  51. MSPROF_MODULE_DATA_PREPROCESS = 0, // DATA_PREPROCESS
  52. MSPROF_MODULE_HCCL, // HCCL
  53. MSPROF_MODULE_ACL, // AclModule
  54. MSPROF_MODULE_FRAMEWORK, // Framework
  55. MSPROF_MODULE_RUNTIME // runtime
  56. };
  57. /**
  58. * @name MsprofReporterCallbackType
  59. * @brief reporter callback request type
  60. */
  61. enum MsprofReporterCallbackType {
  62. MSPROF_REPORTER_REPORT = 0, // report data
  63. MSPROF_REPORTER_INIT, // init reporter
  64. MSPROF_REPORTER_UNINIT, // uninit reporter
  65. };
  66. /**
  67. * @name MsprofReporterCallback
  68. * @brief callback to start reporter/stop reporter/report date
  69. * @param moduleId [IN] enum MsprofReporterModuleId
  70. * @param type [IN] enum MsprofReporterCallbackType
  71. * @param data [IN] callback data (nullptr on INTI/UNINIT)
  72. * @param len [IN] callback data size (0 on INIT/UNINIT)
  73. * @return enum MsprofErrorCode
  74. */
  75. typedef int32_t (*MsprofReporterCallback)(uint32_t moduleId, uint32_t type, void *data, uint32_t len);
  76. #define MSPROF_OPTIONS_DEF_LEN_MAX (2048)
  77. /**
  78. * @name MsprofGeOptions
  79. * @brief struct of MSPROF_CTRL_INIT_GE_OPTIONS
  80. */
  81. struct MsprofGeOptions {
  82. char jobId[MSPROF_OPTIONS_DEF_LEN_MAX];
  83. char options[MSPROF_OPTIONS_DEF_LEN_MAX];
  84. };
  85. /**
  86. * @name MsprofCtrlCallbackType
  87. * @brief ctrl callback request type
  88. */
  89. enum MsprofCtrlCallbackType {
  90. MSPROF_CTRL_INIT_ACL_ENV = 0, // start profiling with acl env
  91. MSPROF_CTRL_INIT_ACL_JSON, // start profiling with acl.json
  92. MSPROF_CTRL_INIT_GE_OPTIONS, // start profiling with ge env and options
  93. MSPROF_CTRL_FINALIZE // stop profiling
  94. };
  95. /**
  96. * @name MsprofCtrlCallback
  97. * @brief callback to start/stop profiling
  98. * @param type [IN] enum MsprofCtrlCallbackType
  99. * @param data [IN] callback data
  100. * @param len [IN] callback data size
  101. * @return enum MsprofErrorCode
  102. */
  103. typedef int32_t (*MsprofCtrlCallback)(uint32_t type, void *data, uint32_t len);
  104. /**
  105. * @name MsprofSetDeviceCallback
  106. * @brief callback to notify set/reset device
  107. * @param devId [IN] device id
  108. * @param isOpenDevice [IN] true: set device, false: reset device
  109. */
  110. typedef void (*MsprofSetDeviceCallback)(uint32_t devId, bool isOpenDevice);
  111. #ifdef __cplusplus
  112. }
  113. #endif
  114. #endif // MSPROFILER_PROF_CALLBACK_H_

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