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.

dump_properties_unittest.cc 4.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. #include <gtest/gtest.h>
  17. #define protected public
  18. #define private public
  19. #include "common/dump/dump_properties.h"
  20. #include "ge_local_context.h"
  21. #include "ge/ge_api_types.h"
  22. #include "common/debug/log.h"
  23. #include "common/ge_inner_error_codes.h"
  24. namespace ge {
  25. class UTEST_dump_properties : public testing::Test {
  26. protected:
  27. void SetUp() {}
  28. void TearDown() {}
  29. };
  30. TEST_F(UTEST_dump_properties, check_dump_step) {
  31. DumpProperties dp;
  32. std::string dump_step{"0|3-5|10"};
  33. std::string unsupport_input1{"0|5-3|10"};
  34. std::string unsupport_input2{"one"};
  35. std::string unsupport_input3;
  36. for (int i = 0; i < 200; ++i) {
  37. unsupport_input3 += std::to_string(i) + "|";
  38. }
  39. unsupport_input3.pop_back();
  40. Status st = dp.CheckDumpStep(dump_step);
  41. EXPECT_EQ(st, SUCCESS);
  42. st = dp.CheckDumpStep(unsupport_input1);
  43. EXPECT_NE(st, SUCCESS);
  44. st = dp.CheckDumpStep(unsupport_input2);
  45. EXPECT_NE(st, SUCCESS);
  46. st = dp.CheckDumpStep(unsupport_input3);
  47. EXPECT_NE(st, SUCCESS);
  48. }
  49. TEST_F(UTEST_dump_properties, check_dump_mode) {
  50. DumpProperties dp;
  51. std::string dump_mode_1{"input"};
  52. std::string dump_mode_2{"output"};
  53. std::string dump_mode_3{"all"};
  54. std::string unsupport_input1{"mode1"};
  55. Status st = dp.CheckDumpMode(dump_mode_1);
  56. EXPECT_EQ(st, SUCCESS);
  57. st = dp.CheckDumpMode(dump_mode_2);
  58. EXPECT_EQ(st, SUCCESS);
  59. st = dp.CheckDumpMode(dump_mode_3);
  60. EXPECT_EQ(st, SUCCESS);
  61. st = dp.CheckDumpMode(unsupport_input1);
  62. EXPECT_NE(st, SUCCESS);
  63. }
  64. TEST_F(UTEST_dump_properties, check_dump_path) {
  65. DumpProperties dp;
  66. std::string dump_path{"/tmp/"};
  67. std::string unsupport_input1{" \\unsupported"};
  68. Status st = dp.CheckDumpPath(dump_path);
  69. EXPECT_EQ(st, SUCCESS);
  70. st = dp.CheckDumpPath(unsupport_input1);
  71. EXPECT_NE(st, SUCCESS);
  72. }
  73. TEST_F(UTEST_dump_properties, check_enable_dump) {
  74. DumpProperties dp;
  75. std::string enable_dump_t{"1"};
  76. std::string enable_dump_f{"0"};
  77. std::string unsupport_input1{"true"};
  78. std::string unsupport_input2{"false"};
  79. Status st = dp.CheckEnableDump(enable_dump_t);
  80. EXPECT_EQ(st, SUCCESS);
  81. st = dp.CheckEnableDump(enable_dump_f);
  82. EXPECT_EQ(st, SUCCESS);
  83. st = dp.CheckEnableDump(unsupport_input1);
  84. EXPECT_NE(st, SUCCESS);
  85. st = dp.CheckEnableDump(unsupport_input2);
  86. EXPECT_NE(st, SUCCESS);
  87. }
  88. TEST_F(UTEST_dump_properties, init_by_options_success_1) {
  89. DumpProperties dp;
  90. std::map<std::string, std::string> options {{OPTION_EXEC_ENABLE_DUMP, "1"},
  91. {OPTION_EXEC_DUMP_PATH, "/tmp/"},
  92. {OPTION_EXEC_DUMP_STEP, "0|1-3|10"},
  93. {OPTION_EXEC_DUMP_MODE, "all"}};
  94. GetThreadLocalContext().SetGlobalOption(options);
  95. Status st = dp.InitByOptions();
  96. EXPECT_EQ(st, SUCCESS);
  97. }
  98. TEST_F(UTEST_dump_properties, init_by_options_success_2) {
  99. DumpProperties dp;
  100. std::map<std::string, std::string> options {{OPTION_EXEC_ENABLE_DUMP_DEBUG, "1"},
  101. {OPTION_EXEC_DUMP_PATH, "/tmp/"},
  102. {OPTION_EXEC_DUMP_DEBUG_MODE, "aicore_overflow"}};
  103. GetThreadLocalContext().SetGlobalOption(options);
  104. Status st = dp.InitByOptions();
  105. EXPECT_EQ(st, SUCCESS);
  106. }
  107. TEST_F(UTEST_dump_properties, init_by_options_success_3) {
  108. DumpProperties dp;
  109. std::map<std::string, std::string> options {{OPTION_EXEC_ENABLE_DUMP_DEBUG, "1"},
  110. {OPTION_EXEC_DUMP_PATH, "/tmp/"}};
  111. GetThreadLocalContext().SetGlobalOption(options);
  112. Status st = dp.InitByOptions();
  113. EXPECT_EQ(st, SUCCESS);
  114. }
  115. } // namespace ge

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