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.

catch.hpp 3.4 kB

3 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 CATCH_HPP_
  17. #define CATCH_HPP_
  18. #include <stdint.h>
  19. #include <iostream>
  20. #define ERROR_CODE() __catch_error_code
  21. #define ERROR_LINE_NO() __catch_error_line_no
  22. #define ERROR_PROC() __catch_error_line_no = __LINE__;
  23. #define PROC \
  24. uint32_t __catch_error_code = 0x7FFFFFCC; \
  25. uint32_t __catch_error_line_no = 0xFFFFFFFF; \
  26. {
  27. #define END_PROC \
  28. } \
  29. __tabErrorCode:
  30. #define THROW(errcode) \
  31. { \
  32. __catch_error_code = (errcode); \
  33. ERROR_PROC(); \
  34. goto __tabErrorCode; \
  35. }
  36. #define EXEC(func) \
  37. { \
  38. if (0 != (__catch_error_code = (func))) THROW(__catch_error_code) \
  39. }
  40. #define EXEC_EX1(func, error_code) \
  41. { \
  42. if (0 != (func)) THROW(error_code) \
  43. }
  44. #define EXEC_EX(func, succRet, error_code) \
  45. { \
  46. if (succRet != (__catch_error_code = (func))) THROW(error_code) \
  47. }
  48. #define ASSERT_EXEC(func, succRet) \
  49. { \
  50. if (succRet != (__catch_error_code = (func))) /*GO_ASSERT_FALSE();*/ \
  51. THROW(__catch_error_code) \
  52. } \
  53. }
  54. #define NEW_ERROR_EXEC(errcode, func, succRet) \
  55. { \
  56. if (succRet != (func)) { \
  57. THROW(errcode) \
  58. } \
  59. }
  60. #define JUDGE(errcode, expr) \
  61. { \
  62. if (!(expr)) { \
  63. THROW(errcode) \
  64. } \
  65. }
  66. #define ASSERT_JUDGE(errcode, expr) \
  67. { \
  68. if (!(expr)) { /*GO_ASSERT_FALSE();*/ \
  69. THROW(errcode) \
  70. } \
  71. }
  72. #define JUDGE_FALSE(errcode, expr) \
  73. { \
  74. if (expr) { \
  75. THROW(errcode) \
  76. } \
  77. }
  78. #define JUDGE_CONTINUE(expr) \
  79. { \
  80. if (expr) { \
  81. continue; \
  82. } \
  83. }
  84. #define CATCH_ERROR(errcode) if (__catch_error_code == (errcode)) { // ERROR_LOG();
  85. #define CATCH_ALL_ERROR {
  86. #define END_CATCH_ERROR }
  87. #define FINAL \
  88. __tabFinal:
  89. #define END_FINAL /*GO_ASSERT_FALSE()*/ ;
  90. #define GOTO_FINAL() goto __tabFinal;
  91. #endif // CATCH_HPP_

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