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.cc 20 kB

4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  1. /**
  2. * Copyright 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 "common/dump/dump_properties.h"
  17. #include <cstdio>
  18. #include <string>
  19. #include <regex>
  20. #include "common/ge/ge_util.h"
  21. #include "framework/common/util.h"
  22. #include "framework/common/debug/ge_log.h"
  23. #include "framework/common/debug/log.h"
  24. #include "framework/common/ge_types.h"
  25. #include "framework/common/types.h"
  26. #include "graph/debug/ge_attr_define.h"
  27. #include "graph/ge_context.h"
  28. #include "graph/utils/attr_utils.h"
  29. namespace {
  30. const std::string kEnableFlag = "1";
  31. const std::string kDumpStatusOpen = "on";
  32. const uint32_t kAicoreOverflow = (0x1 << 0);
  33. const uint32_t kAtomicOverflow = (0x1 << 1);
  34. const uint32_t kAllOverflow = (kAicoreOverflow | kAtomicOverflow);
  35. } // namespace
  36. namespace ge {
  37. FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpProperties::Split(const std::string &s,
  38. std::vector<std::string> &result,
  39. const char *delchar) {
  40. if (s.empty()) {
  41. return;
  42. }
  43. result.clear();
  44. char *buffer = new (std::nothrow)char[s.size() + 1];
  45. if (buffer == nullptr) {
  46. GELOGE(FAILED, "[Split][string] failed while malloc memory, string value is:%s", s.c_str());
  47. REPORT_CALL_ERROR("E19999", "Memory malloc may fail when split string, get fatal exception, "
  48. "string value is:%s", s.c_str());
  49. return;
  50. }
  51. buffer[s.size()] = '\0';
  52. errno_t e = strcpy_s(buffer, s.size() + 1, s.c_str());
  53. if (e != EOK) {
  54. delete[] buffer;
  55. return;
  56. }
  57. char *context = nullptr;
  58. char *p = strtok_s(buffer, delchar, &context);
  59. while (p != nullptr) {
  60. result.emplace_back(p);
  61. p = strtok_s(nullptr, delchar, &context);
  62. }
  63. delete[] buffer;
  64. }
  65. FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status DumpProperties::CheckDumpStep(const std::string &dump_step) {
  66. std::string modified_dum_step = dump_step + "|";
  67. std::smatch result;
  68. std::vector<string> match_vecs;
  69. std::regex pattern(R"((\d{1,}-\d{1,}\||\d{1,}\|)+)");
  70. if (regex_match(modified_dum_step, result, pattern)) {
  71. Split(result.str(), match_vecs, "|");
  72. if (match_vecs.empty()) {
  73. REPORT_CALL_ERROR("E19999", "Split may get fatal exception, dump_step:%s.", dump_step.c_str());
  74. GELOGE(FAILED, "[Check][Param] failed. Split may get fatal exception, ge.exec.dumpStep:%s.", dump_step.c_str());
  75. return FAILED;
  76. }
  77. // 100 is the max sets of dump steps.
  78. if (match_vecs.size() > 100) {
  79. REPORT_INPUT_ERROR("E10001", std::vector<std::string>({"parameter", "value", "reason"}),
  80. std::vector<std::string>({
  81. "ge.exec.dumpStep",
  82. dump_step.c_str(),
  83. " is not supported, only support dump <= 100 sets of data"}));
  84. GELOGE(PARAM_INVALID, "[Check][Param] get dump_step value:%s, "
  85. "dump_step only support dump <= 100 sets of data.", dump_step.c_str());
  86. return PARAM_INVALID;
  87. }
  88. for (const auto &match_vec : match_vecs) {
  89. std::vector<string> vec_after_split;
  90. Split(match_vec, vec_after_split, "-");
  91. if (match_vecs.empty()) {
  92. REPORT_CALL_ERROR("E19999", "Split may get fatal exception.");
  93. GELOGE(FAILED, "[Check][Param] failed, split may get fatal exception.");
  94. return FAILED;
  95. }
  96. if (vec_after_split.size() > 1) {
  97. if (std::atoi(vec_after_split[0].c_str()) >= std::atoi(vec_after_split[1].c_str())) {
  98. REPORT_INPUT_ERROR("E10001", std::vector<std::string>({"parameter", "value", "reason"}),
  99. std::vector<std::string>({
  100. "ge.exec.dumpStep",
  101. dump_step.c_str(),
  102. " is not supported."
  103. "in range steps, the first step is >= second step, correct example:'0|5|10-20"}));
  104. GELOGE(PARAM_INVALID, "[Check][Param] get dump_step value:%s, "
  105. "in range steps, the first step is >= second step, correct example:'0|5|10-20'", dump_step.c_str());
  106. return PARAM_INVALID;
  107. }
  108. }
  109. }
  110. } else {
  111. REPORT_INPUT_ERROR("E10001", std::vector<std::string>({"parameter", "value", "reason"}),
  112. std::vector<std::string>({
  113. "ge.exec.dumpStep",
  114. dump_step.c_str(),
  115. " is not supported, correct example:'0|5|10|50-100."}));
  116. GELOGE(PARAM_INVALID, "[Check][Param] get dump_step value:%s, "
  117. "dump_step string style is error, correct example:'0|5|10|50-100.'", dump_step.c_str());
  118. return PARAM_INVALID;
  119. }
  120. return SUCCESS;
  121. }
  122. FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status DumpProperties::CheckDumpMode(const std::string &dump_mode) {
  123. const std::set<string> dump_mode_list = {"input", "output", "all"};
  124. std::set<string>::iterator iter;
  125. if ((iter = dump_mode_list.find(dump_mode)) == dump_mode_list.end()) {
  126. REPORT_INPUT_ERROR("E10001", std::vector<std::string>({"parameter", "value", "reason"}),
  127. std::vector<std::string>({
  128. "ge.exec.dumpMode",
  129. dump_mode.c_str(),
  130. " is not supported, should be one of the following:[input, output, all]"}));
  131. GELOGE(PARAM_INVALID, "[Check][Param] the dump_debug_mode:%s, is is not supported,"
  132. "should be one of the following:[input, output, all].", dump_mode.c_str());
  133. return PARAM_INVALID;
  134. }
  135. return SUCCESS;
  136. }
  137. FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status DumpProperties::CheckDumpPath(const std::string &input) {
  138. if (mmIsDir(input.c_str()) != EN_OK) {
  139. REPORT_INPUT_ERROR("E10001", std::vector<std::string>({"parameter", "value", "reason"}),
  140. std::vector<std::string>({
  141. "ge.exec.dumpPath",
  142. input.c_str(),
  143. " is not a directory."}));
  144. GELOGE(PARAM_INVALID, "[Check][Param] the path:%s, is not directory.", input.c_str());
  145. return PARAM_INVALID;
  146. }
  147. char trusted_path[MMPA_MAX_PATH] = { "\0" };
  148. if (mmRealPath(input.c_str(), trusted_path, MMPA_MAX_PATH) != EN_OK) {
  149. REPORT_INPUT_ERROR("E10001", std::vector<std::string>({"parameter", "value", "reason"}),
  150. std::vector<std::string>({
  151. "ge.exec.dumpPath",
  152. input.c_str(),
  153. " dumpPath invalid."}));
  154. GELOGE(PARAM_INVALID, "[Check][Param] the dumpPath:%s, is invalid.", input.c_str());
  155. return PARAM_INVALID;
  156. }
  157. if (mmAccess2(trusted_path, R_OK | W_OK) != EN_OK) {
  158. REPORT_INPUT_ERROR("E10001", std::vector<std::string>({"parameter", "value", "reason"}),
  159. std::vector<std::string>({
  160. "ge.exec.dumpPath",
  161. input.c_str(),
  162. " does't have read, write permissions."}));
  163. GELOGE(PARAM_INVALID, "[Check][Param] the path:%s, does't have read, write permissions.", input.c_str());
  164. return PARAM_INVALID;
  165. }
  166. return SUCCESS;
  167. }
  168. FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status DumpProperties::CheckEnableDump(const std::string &input) {
  169. std::set<string> enable_dump_option_list = {"1", "0"};
  170. auto it = enable_dump_option_list.find(input);
  171. if (it == enable_dump_option_list.end()) {
  172. REPORT_INPUT_ERROR("E10001", std::vector<std::string>({"parameter", "value", "reason"}),
  173. std::vector<std::string>({
  174. "ge.exec.enableDump",
  175. input.c_str(),
  176. " only support 1 or 0."}));
  177. GELOGE(PARAM_INVALID, "[Check][Param] Not support ge.exec.enableDump or ge.exec.enableDumpDebug format:%s, "
  178. "only support 1 or 0.", input.c_str());
  179. return PARAM_INVALID;
  180. }
  181. return SUCCESS;
  182. }
  183. FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY DumpProperties::DumpProperties(const DumpProperties &other) {
  184. CopyFrom(other);
  185. }
  186. FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY DumpProperties &DumpProperties::operator=(
  187. const DumpProperties &other) {
  188. CopyFrom(other);
  189. return *this;
  190. }
  191. FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status DumpProperties::SetDumpOptions() {
  192. if (enable_dump_ == kEnableFlag) {
  193. std::string dump_step;
  194. if (GetContext().GetOption(OPTION_EXEC_DUMP_STEP, dump_step) == GRAPH_SUCCESS) {
  195. GE_CHK_STATUS_RET(CheckDumpStep(dump_step), "[Check][dump_step] failed.");
  196. GELOGI("Get dump step %s successfully", dump_step.c_str());
  197. SetDumpStep(dump_step);
  198. }
  199. string dump_mode = "output";
  200. if (GetContext().GetOption(OPTION_EXEC_DUMP_MODE, dump_mode) == GRAPH_SUCCESS) {
  201. GELOGI("Get dump mode %s successfully", dump_mode.c_str());
  202. GE_CHK_STATUS_RET(CheckDumpMode(dump_mode), "[Check][dump_mode] failed.");
  203. SetDumpMode(dump_mode);
  204. }
  205. AddPropertyValue(DUMP_ALL_MODEL, {});
  206. }
  207. return SUCCESS;
  208. }
  209. FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status DumpProperties::InitByOptions() {
  210. enable_dump_.clear();
  211. enable_dump_debug_.clear();
  212. dump_path_.clear();
  213. dump_step_.clear();
  214. dump_mode_.clear();
  215. is_train_op_debug_ = false;
  216. is_infer_op_debug_ = false;
  217. op_debug_mode_ = 0;
  218. std::string enable_dump = std::to_string(false);
  219. (void)GetContext().GetOption(OPTION_EXEC_ENABLE_DUMP, enable_dump);
  220. enable_dump_ = enable_dump;
  221. if (!enable_dump_.empty()) {
  222. GE_CHK_STATUS_RET(CheckEnableDump(enable_dump_), "[Check][enable_dump] failed.");
  223. }
  224. std::string enable_dump_debug = std::to_string(false);
  225. (void)GetContext().GetOption(OPTION_EXEC_ENABLE_DUMP_DEBUG, enable_dump_debug);
  226. enable_dump_debug_ = enable_dump_debug;
  227. if (!enable_dump_debug_.empty()) {
  228. GE_CHK_STATUS_RET(CheckEnableDump(enable_dump_debug_), "[Check][enable_dump_debug] failed.");
  229. }
  230. if ((enable_dump_ == kEnableFlag) && (enable_dump_debug_ == kEnableFlag)) {
  231. REPORT_INPUT_ERROR("E10001", std::vector<std::string>({"parameter", "value", "reason"}),
  232. std::vector<std::string>({
  233. "ge.exec.enableDump and ge.exec.enableDumpDebug",
  234. enable_dump_ + ", " + enable_dump_debug,
  235. "ge.exec.enableDump and ge.exec.enableDumpDebug cannot be set to 1 at the same time."}));
  236. GELOGE(FAILED, "ge.exec.enableDump and ge.exec.enableDumpDebug cannot be both set to 1 at the same time.");
  237. return FAILED;
  238. }
  239. if ((enable_dump_ == kEnableFlag) || (enable_dump_debug_ == kEnableFlag)) {
  240. std::string dump_path;
  241. if (GetContext().GetOption(OPTION_EXEC_DUMP_PATH, dump_path) == GRAPH_SUCCESS) {
  242. GE_CHK_STATUS_RET(CheckDumpPath(dump_path), "Check dump path failed.");
  243. if (!dump_path.empty() && dump_path[dump_path.size() - 1] != '/') {
  244. dump_path = dump_path + "/";
  245. }
  246. dump_path = dump_path + CurrentTimeInStr() + "/";
  247. GELOGI("Get dump path %s successfully", dump_path.c_str());
  248. SetDumpPath(dump_path);
  249. } else {
  250. REPORT_INPUT_ERROR("E10001", std::vector<std::string>({"parameter", "value", "reason"}),
  251. std::vector<std::string>({
  252. "ge.exec.dumpPath",
  253. dump_path,
  254. "ge.exec.dumpPath is not set."}));
  255. GELOGE(FAILED, "[Check][dump_path] failed. Dump path is not set.");
  256. return FAILED;
  257. }
  258. }
  259. GE_CHK_STATUS_RET(SetDumpOptions(), "SetDumpOptions failed.");
  260. GE_CHK_STATUS_RET(SetDumpDebugOptions(), "SetDumpDebugOptions failed.");
  261. return SUCCESS;
  262. }
  263. // The following is the new dump scenario of the fusion operator
  264. FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpProperties::AddPropertyValue(
  265. const std::string &model, const std::set<std::string> &layers) {
  266. for (const std::string &layer : layers) {
  267. GELOGI("This model %s config to dump layer %s", model.c_str(), layer.c_str());
  268. }
  269. model_dump_properties_map_[model] = layers;
  270. }
  271. FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpProperties::DeletePropertyValue(const std::string &model) {
  272. auto iter = model_dump_properties_map_.find(model);
  273. if (iter != model_dump_properties_map_.end()) {
  274. model_dump_properties_map_.erase(iter);
  275. }
  276. }
  277. FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpProperties::ClearDumpPropertyValue() {
  278. model_dump_properties_map_.clear();
  279. }
  280. FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpProperties::ClearDumpInfo() {
  281. enable_dump_.clear();
  282. enable_dump_debug_.clear();
  283. dump_path_.clear();
  284. dump_step_.clear();
  285. dump_mode_.clear();
  286. dump_op_switch_.clear();
  287. dump_status_.clear();
  288. is_train_op_debug_ = false;
  289. is_infer_op_debug_ = false;
  290. op_debug_mode_ = 0;
  291. }
  292. FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::set<std::string> DumpProperties::GetAllDumpModel() const {
  293. std::set<std::string> model_list;
  294. for (auto &iter : model_dump_properties_map_) {
  295. model_list.insert(iter.first);
  296. }
  297. return model_list;
  298. }
  299. FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::set<std::string> DumpProperties::GetPropertyValue(
  300. const std::string &model) const {
  301. auto iter = model_dump_properties_map_.find(model);
  302. if (iter != model_dump_properties_map_.end()) {
  303. return iter->second;
  304. }
  305. return {};
  306. }
  307. FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool DumpProperties::IsLayerNeedDump(
  308. const std::string &model, const std::string &om_name, const std::string &op_name) const {
  309. // if dump all
  310. GELOGD("model name is %s om name is %s op is %s in layer need dump", model.c_str(), om_name.c_str(), op_name.c_str());
  311. if (model_dump_properties_map_.find(DUMP_ALL_MODEL) != model_dump_properties_map_.end()) {
  312. return true;
  313. }
  314. // if this model need dump
  315. auto om_name_iter = model_dump_properties_map_.find(om_name);
  316. auto model_name_iter = model_dump_properties_map_.find(model);
  317. if (om_name_iter != model_dump_properties_map_.end() || model_name_iter != model_dump_properties_map_.end()) {
  318. // if no dump layer info, dump all layer in this model
  319. auto model_iter = om_name_iter != model_dump_properties_map_.end() ? om_name_iter : model_name_iter;
  320. if (model_iter->second.empty()) {
  321. return true;
  322. }
  323. return model_iter->second.find(op_name) != model_iter->second.end();
  324. }
  325. GELOGD("Model %s is not seated to be dump.", model.c_str());
  326. return false;
  327. }
  328. FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpProperties::SetDumpPath(const std::string &path) {
  329. dump_path_ = path;
  330. }
  331. FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY const std::string &DumpProperties::GetDumpPath() const {
  332. return dump_path_;
  333. }
  334. FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpProperties::SetDumpStep(const std::string &step) {
  335. dump_step_ = step;
  336. }
  337. FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY const std::string &DumpProperties::GetDumpStep() const {
  338. return dump_step_;
  339. }
  340. FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpProperties::SetDumpMode(const std::string &mode) {
  341. dump_mode_ = mode;
  342. }
  343. FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY const std::string &DumpProperties::GetDumpMode() const {
  344. return dump_mode_;
  345. }
  346. FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpProperties::SetDumpStatus(const std::string &status) {
  347. dump_status_ = status;
  348. }
  349. FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY const std::string &DumpProperties::GetDumpStatus() const {
  350. return dump_status_;
  351. }
  352. FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpProperties::InitInferOpDebug() {
  353. is_infer_op_debug_ = true;
  354. }
  355. FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpProperties::SetOpDebugMode(const uint32_t &op_debug_mode) {
  356. op_debug_mode_ = op_debug_mode;
  357. }
  358. FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpProperties::SetDumpOpSwitch(
  359. const std::string &dump_op_switch) {
  360. dump_op_switch_ = dump_op_switch;
  361. }
  362. FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY const std::string &DumpProperties::GetDumpOpSwitch() const {
  363. return dump_op_switch_;
  364. }
  365. FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool DumpProperties::IsSingleOpNeedDump() const {
  366. if (dump_op_switch_ == kDumpStatusOpen) {
  367. return true;
  368. }
  369. return false;
  370. }
  371. FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool DumpProperties::IsDumpOpen() const {
  372. if (enable_dump_ == kEnableFlag || dump_status_ == kDumpStatusOpen) {
  373. return true;
  374. }
  375. return false;
  376. }
  377. void DumpProperties::CopyFrom(const DumpProperties &other) {
  378. if (&other != this) {
  379. enable_dump_ = other.enable_dump_;
  380. enable_dump_debug_ = other.enable_dump_debug_;
  381. dump_path_ = other.dump_path_;
  382. dump_step_ = other.dump_step_;
  383. dump_mode_ = other.dump_mode_;
  384. dump_status_ = other.dump_status_;
  385. dump_op_switch_ = other.dump_op_switch_;
  386. model_dump_properties_map_ = other.model_dump_properties_map_;
  387. is_train_op_debug_ = other.is_train_op_debug_;
  388. is_infer_op_debug_ = other.is_infer_op_debug_;
  389. op_debug_mode_ = other.op_debug_mode_;
  390. }
  391. }
  392. Status DumpProperties::SetDumpDebugOptions() {
  393. if (enable_dump_debug_ == kEnableFlag) {
  394. std::string dump_debug_mode;
  395. if (GetContext().GetOption(OPTION_EXEC_DUMP_DEBUG_MODE, dump_debug_mode) == GRAPH_SUCCESS) {
  396. GELOGD("Get dump debug mode %s successfully", dump_debug_mode.c_str());
  397. } else {
  398. REPORT_INPUT_ERROR("E10001", std::vector<std::string>({"parameter", "value", "reason"}),
  399. std::vector<std::string>({
  400. "ge.exec.dumpDebugMode",
  401. dump_debug_mode,
  402. "ge.exec.dumpDebugMode is not set."}));
  403. GELOGE(PARAM_INVALID, "[Check][dump_debug_mode] failed. Dump debug mode is not set.");
  404. return PARAM_INVALID;
  405. }
  406. if (dump_debug_mode == OP_DEBUG_AICORE) {
  407. GELOGD("ge.exec.dumpDebugMode=aicore_overflow, op debug is open.");
  408. is_train_op_debug_ = true;
  409. op_debug_mode_ = kAicoreOverflow;
  410. } else if (dump_debug_mode == OP_DEBUG_ATOMIC) {
  411. GELOGD("ge.exec.dumpDebugMode=atomic_overflow, op debug is open.");
  412. is_train_op_debug_ = true;
  413. op_debug_mode_ = kAtomicOverflow;
  414. } else if (dump_debug_mode == OP_DEBUG_ALL) {
  415. GELOGD("ge.exec.dumpDebugMode=all, op debug is open.");
  416. is_train_op_debug_ = true;
  417. op_debug_mode_ = kAllOverflow;
  418. } else {
  419. REPORT_INPUT_ERROR("E10001", std::vector<std::string>({"parameter", "value", "reason"}),
  420. std::vector<std::string>({
  421. "ge.exec.dumpDebugMode",
  422. dump_debug_mode,
  423. "ge.exec.dumpDebugMode is invalid."}));
  424. GELOGE(PARAM_INVALID, "[Set][DumpDebugOptions] failed, ge.exec.dumpDebugMode is invalid.");
  425. return PARAM_INVALID;
  426. }
  427. } else {
  428. GELOGI("ge.exec.enableDumpDebug is false or is not set.");
  429. }
  430. return SUCCESS;
  431. }
  432. } // namespace ge

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