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.

task_info.h 3.2 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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. #ifndef GE_GRAPH_LOAD_NEW_MODEL_MANAGER_TASK_INFO_TASK_INFO_H_
  17. #define GE_GRAPH_LOAD_NEW_MODEL_MANAGER_TASK_INFO_TASK_INFO_H_
  18. #include <vector>
  19. #include "cce/customize.h"
  20. #include "framework/common/taskdown_common.h"
  21. #include "framework/common/ge_inner_error_codes.h"
  22. #include "graph/load/model_manager/ts_mem_mall.h"
  23. #include "graph/load/model_manager/task_info/task_info_factory.h"
  24. #include "proto/task.pb.h"
  25. namespace ge {
  26. struct MemInfo {
  27. uint64_t memory_size = 0;
  28. uint64_t logic_memory_base = 0;
  29. uint8_t *memory_base = nullptr;
  30. };
  31. struct RuntimeParam {
  32. RuntimeParam() {
  33. ts_mem_mall = std::unique_ptr<TsMemMall>(new (std::nothrow) TsMemMall());
  34. aicpu_mem_mall = std::unique_ptr<TsMemMall>(new (std::nothrow) TsMemMall(RT_MEMORY_HBM));
  35. }
  36. ~RuntimeParam() = default;
  37. uint64_t mem_size = 0;
  38. uint64_t logic_mem_base = 0;
  39. uint8_t *mem_base = nullptr;
  40. uint64_t weight_size = 0;
  41. uint64_t logic_weight_base = 0;
  42. uint8_t *weight_base = nullptr;
  43. uint64_t var_size = 0;
  44. uint64_t logic_var_base = 0;
  45. uint8_t *var_base = nullptr;
  46. std::map<uint32_t, MemInfo> memory_infos;
  47. uint32_t batch_num = 0;
  48. uint32_t stream_num = 0;
  49. uint32_t event_num = 0;
  50. uint32_t label_num = 0;
  51. uint64_t session_id = 0;
  52. uint32_t graph_id = 0;
  53. bool is_single_op = false;
  54. std::unique_ptr<TsMemMall> ts_mem_mall;
  55. std::unique_ptr<TsMemMall> aicpu_mem_mall;
  56. };
  57. typedef struct FusionOpInfo {
  58. std::vector<std::string> original_op_names;
  59. std::string op_name;
  60. uint32_t op_index;
  61. uint32_t stream_id;
  62. } FusionOpInfo;
  63. class DavinciModel;
  64. class TaskInfo {
  65. public:
  66. TaskInfo() : stream_(nullptr) {}
  67. virtual ~TaskInfo() { stream_ = nullptr; }
  68. virtual Status Init(const domi::TaskDef &task_def, DavinciModel *davinci_model) = 0;
  69. virtual Status Distribute() = 0;
  70. virtual Status UpdateArgs() { return SUCCESS; }
  71. virtual Status CalculateArgs(const domi::TaskDef &task_def, DavinciModel *davinci_model) { return SUCCESS; }
  72. virtual Status Release() { return SUCCESS; }
  73. virtual ccOpContext *GetCtx() { return nullptr; }
  74. virtual uint32_t GetTaskID() { return 0xFFFFFFFF; }
  75. virtual bool CallSaveDumpInfo() { return false; }
  76. virtual uint32_t GetStreamId() { return 0xFFFFFFFF; }
  77. virtual uintptr_t GetDumpArgs() { return 0; }
  78. virtual uint32_t GetSktTaskID() { return 0xFFFFFFFF; }
  79. virtual FusionOpInfo *GetFusionOpInfo() { return nullptr; }
  80. protected:
  81. Status SetStream(uint32_t stream_id, const std::vector<rtStream_t> &stream_list);
  82. void *stream_;
  83. };
  84. } // namespace ge
  85. #endif // GE_GRAPH_LOAD_NEW_MODEL_MANAGER_TASK_INFO_TASK_INFO_H_

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