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.

data_dumper.h 3.7 kB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
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. #ifndef GE_GRAPH_LOAD_NEW_MODEL_MANAGER_DATA_DUMPER_H_
  17. #define GE_GRAPH_LOAD_NEW_MODEL_MANAGER_DATA_DUMPER_H_
  18. #include <map>
  19. #include <memory>
  20. #include <string>
  21. #include <vector>
  22. #include "framework/common/ge_inner_error_codes.h"
  23. #include "graph/node.h"
  24. #include "proto/ge_ir.pb.h"
  25. #include "proto/op_mapping_info.pb.h"
  26. #include "runtime/mem.h"
  27. #include "task_info/task_info.h"
  28. namespace ge {
  29. class DataDumper {
  30. public:
  31. DataDumper()
  32. : model_name_(),
  33. model_id_(0),
  34. runtime_param_(),
  35. dev_mem_load_(nullptr),
  36. dev_mem_unload_(nullptr),
  37. op_list_(),
  38. input_map_(),
  39. load_flag_(false),
  40. device_id_(0),
  41. global_step_(0),
  42. loop_per_iter_(0),
  43. loop_cond_(0) {}
  44. ~DataDumper();
  45. void SetModelName(const std::string &model_name) { model_name_ = model_name; }
  46. void SetModelId(uint32_t model_id) { model_id_ = model_id; }
  47. void SetMemory(const RuntimeParam &runtime_param) { runtime_param_ = runtime_param; }
  48. void SetDeviceId(uint32_t device_id) { device_id_ = device_id; }
  49. void SetLoopAddr(void *global_step, void *loop_per_iter, void *loop_cond);
  50. void SaveDumpInput(const std::shared_ptr<Node> &node);
  51. // args is device memory stored first output addr
  52. void SaveDumpTask(uint32_t task_id, uint32_t stream_id, const std::shared_ptr<OpDesc> &op_desc, uintptr_t args);
  53. void SaveEndGraphId(uint32_t task_id, uint32_t stream_id);
  54. void SetOmName(const std::string &om_name) { om_name_ = om_name; }
  55. Status LoadDumpInfo();
  56. Status UnloadDumpInfo();
  57. private:
  58. void ReleaseDevMem(void **ptr) noexcept;
  59. void PrintCheckLog(string &dump_list_key);
  60. std::string model_name_;
  61. // for inference data dump
  62. std::string om_name_;
  63. uint32_t model_id_;
  64. RuntimeParam runtime_param_;
  65. void *dev_mem_load_;
  66. void *dev_mem_unload_;
  67. struct InnerDumpInfo;
  68. struct InnerInputMapping;
  69. std::vector<InnerDumpInfo> op_list_;
  70. uint32_t end_graph_task_id_ = 0;
  71. uint32_t end_graph_stream_id_ = 0;
  72. std::multimap<std::string, InnerInputMapping> input_map_;
  73. bool load_flag_;
  74. uint32_t device_id_;
  75. uintptr_t global_step_;
  76. uintptr_t loop_per_iter_;
  77. uintptr_t loop_cond_;
  78. Status DumpOutput(const InnerDumpInfo &inner_dump_info, aicpu::dump::Task &task);
  79. Status DumpInput(const InnerDumpInfo &inner_dump_info, aicpu::dump::Task &task);
  80. Status ExecuteLoadDumpInfo(aicpu::dump::OpMappingInfo &op_mapping_info);
  81. void SetEndGraphIdToAicpu(uint32_t task_id, uint32_t stream_id, aicpu::dump::OpMappingInfo &op_mapping_info);
  82. Status ExecuteUnLoadDumpInfo(aicpu::dump::OpMappingInfo &op_mapping_info);
  83. };
  84. struct DataDumper::InnerDumpInfo {
  85. uint32_t task_id;
  86. uint32_t stream_id;
  87. std::shared_ptr<OpDesc> op;
  88. uintptr_t args;
  89. bool is_task;
  90. int input_anchor_index;
  91. int output_anchor_index;
  92. std::vector<int64_t> dims;
  93. int64_t data_size;
  94. };
  95. struct DataDumper::InnerInputMapping {
  96. std::shared_ptr<OpDesc> data_op;
  97. int input_anchor_index;
  98. int output_anchor_index;
  99. };
  100. } // namespace ge
  101. #endif // GE_GRAPH_LOAD_NEW_MODEL_MANAGER_DATA_DUMPER_H_

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