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.

atc_ir_common.h 4.5 kB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 FRAMEWORK_DOMI_ATC_IR_COMMON_H_
  17. #define FRAMEWORK_DOMI_ATC_IR_COMMON_H_
  18. #include <unistd.h>
  19. #include <string>
  20. #include <unordered_map>
  21. #include <utility>
  22. #include <vector>
  23. #include <set>
  24. #include "framework/common/debug/ge_log.h"
  25. #include "framework/common/ge_inner_error_codes.h"
  26. #include "framework/omg/omg_inner_types.h"
  27. #include "graph/preprocess/multi_batch_options.h"
  28. namespace ge {
  29. static std::set<std::string> caffe_support_input_format = {"NCHW", "ND"};
  30. static std::set<std::string> tf_support_input_format = {"NCHW", "NHWC", "ND", "NCDHW", "NDHWC"};
  31. static std::set<std::string> onnx_support_input_format = {"NCHW", "ND", "NCDHW"};
  32. static std::map<std::string, domiTensorFormat_t> input_format_str_to_geformat = {
  33. {"ND", domi::DOMI_TENSOR_ND},
  34. {"NCHW", domi::DOMI_TENSOR_NCHW},
  35. {"NHWC", domi::DOMI_TENSOR_NHWC},
  36. {"CHWN", domi::DOMI_TENSOR_CHWN},
  37. {"NC1HWC0", domi::DOMI_TENSOR_NC1HWC0},
  38. {"NHWC1C0", domi::DOMI_TENSOR_NHWC1C0},
  39. {"NCDHW", domi::DOMI_TENSOR_NCDHW},
  40. {"NDHWC", domi::DOMI_TENSOR_NDHWC}
  41. };
  42. static const std::string kEnableCompressWeightTrue = "1";
  43. static const std::string kEnableCompressWeightFalse = "0";
  44. bool CheckDynamicBatchSizeInputShapeValid(map<string, vector<int64_t>> shape_map,
  45. std::string &dynamic_batch_size);
  46. bool CheckDynamicImagesizeInputShapeValid(map<string, vector<int64_t>> shape_map,
  47. const std::string input_format, std::string &dynamic_image_size);
  48. bool CheckDynamicDimsInputShapeValid(const std::map<std::string, std::vector<int64_t>> &shape_map,
  49. std::string input_format, std::string &dynamic_dims);
  50. bool CheckAndParseDynamicDims(int32_t dynamic_dim_num, std::string &dynamic_dims);
  51. Status CheckDynamicInputParamValid(std::string &dynamic_batch_size, std::string &dynamic_image_size,
  52. std::string &dynamic_dims, const std::string input_shape,
  53. const std::string input_shape_range, const std::string input_format,
  54. bool &is_dynamic_input);
  55. bool ParseInputShape(const std::string &input_shape, std::map<string, std::vector<int64_t>> &shape_map,
  56. std::vector<std::pair<string, vector<int64_t>>> &user_shape_map, bool is_dynamic_input = false);
  57. bool ParseInputShapeRange(const std::string &shape_range,
  58. std::map<string, std::vector<std::pair<int64_t, int64_t>>> &shape_range_map);
  59. Status CheckOutputTypeParamValid(const std::string output_type);
  60. Status CheckBufferOptimizeParamValid(const std::string buffer_optimize);
  61. Status CheckCompressWeightParamValid(const std::string enable_compress_weight, const std::string compress_weight_conf);
  62. int CheckLogParamValidAndSetLogLevel(const std::string log);
  63. Status CheckInsertOpConfParamValid(const std::string insert_op_conf);
  64. Status CheckDisableReuseMemoryParamValid(const std::string disable_reuse_memory);
  65. Status CheckEnableSingleStreamParamValid(const std::string enable_single_stream);
  66. Status CheckImplmodeParamValid(const std::string &optypelist_for_implmode, std::string &op_select_implmode);
  67. Status CheckInputFormat(const string &input_format);
  68. Status CheckKeepTypeParamValid(const std::string &keep_dtype);
  69. void PrintOptionMap(std::map<std::string, std::string> &options, std::string tips);
  70. void EraseEndSemicolon(std::string &param);
  71. Status UpdateDataOpShape(const OpDescPtr &op, std::map<std::string, std::vector<int64_t>> &shape_map);
  72. Status UpdateDataOpShapeRange(const OpDescPtr &op,
  73. std::map<std::string, std::vector<std::pair<int64_t, int64_t>>> &shape_range_map);
  74. Status UpdateDynamicInputShapeRange(const ge::ComputeGraphPtr &compute_graph, const string &input_shape_range);
  75. }
  76. #endif // FRAMEWORK_DOMI_ATC_IR_COMMON_H_

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