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.

log.h 4.6 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /**
  2. * Copyright 2021 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 MINDSPORE_LITE_MICRO_CODER_LOG_H_
  17. #define MINDSPORE_LITE_MICRO_CODER_LOG_H_
  18. #include "src/common/log_adapter.h"
  19. #include "include/errorcode.h"
  20. #include "nnacl/op_base.h"
  21. #define MS_CHECK_PTR(ptr) \
  22. do { \
  23. if ((ptr) == nullptr) { \
  24. MS_LOG(ERROR) << ": The pointer[" << #ptr << "] is null."; \
  25. return mindspore::lite::RET_ERROR; \
  26. } \
  27. } while (0)
  28. #define MS_CHECK_PTR_WITH_EXE(ptr, FUNC) \
  29. do { \
  30. if ((ptr) == nullptr) { \
  31. MS_LOG(ERROR) << ": The pointer[" << #ptr << "] is null."; \
  32. FUNC; \
  33. return mindspore::lite::RET_ERROR; \
  34. } \
  35. } while (0)
  36. #define MS_CHECK_PTR_RET_NULL(ptr) \
  37. do { \
  38. if ((ptr) == nullptr) { \
  39. MS_LOG(ERROR) << ": The pointer[" << #ptr << "] is null."; \
  40. return nullptr; \
  41. } \
  42. } while (0)
  43. #define MS_CHECK_RET_CODE(code, msg) \
  44. do { \
  45. if ((code) != RET_OK) { \
  46. MS_LOG(ERROR) << msg; \
  47. return mindspore::lite::RET_ERROR; \
  48. } \
  49. } while (0)
  50. #define MS_CHECK_RET_CODE_WITH_EXE(code, msg, FUNC) \
  51. do { \
  52. if ((code) != RET_OK) { \
  53. MS_LOG(ERROR) << msg; \
  54. FUNC; \
  55. return mindspore::lite::RET_ERROR; \
  56. } \
  57. } while (0)
  58. #define MS_CHECK_RET_CODE_RET_NULL(code, msg) \
  59. do { \
  60. if ((code) != RET_OK) { \
  61. MS_LOG(ERROR) << msg; \
  62. return nullptr; \
  63. } \
  64. } while (0)
  65. #define MS_CHECK_TRUE(code, msg) \
  66. do { \
  67. if (!(code)) { \
  68. MS_LOG(ERROR) << msg; \
  69. return mindspore::lite::RET_ERROR; \
  70. } \
  71. } while (0)
  72. #define MS_CHECK_TRUE_WITH_EXE(code, msg, FUNC) \
  73. do { \
  74. if (!(code)) { \
  75. MS_LOG(ERROR) << msg; \
  76. FUNC; \
  77. return mindspore::lite::RET_ERROR; \
  78. } \
  79. } while (0)
  80. #define MS_CHECK_TRUE_WITHOUT_RET(code, msg) \
  81. do { \
  82. if (!(code)) { \
  83. MS_LOG(ERROR) << msg; \
  84. return; \
  85. } \
  86. } while (0)
  87. #define MS_CHECK_TRUE_RET_NULL(code, msg) \
  88. do { \
  89. if (!(code)) { \
  90. MS_LOG(ERROR) << msg; \
  91. return nullptr; \
  92. } \
  93. } while (0)
  94. #define MS_CHECK_TRUE_RET_BOOL(code, msg) \
  95. do { \
  96. if (!(code)) { \
  97. MS_LOG(ERROR) << msg; \
  98. return false; \
  99. } \
  100. } while (0)
  101. #endif // MINDSPORE_LITE_MICRO_CODER_LOG_H_