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.2 kB

4 years ago
4 years ago
4 years ago
4 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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"};
  32. static const char *const kCaffeFormatSupport = "only support NCHW, ND in Caffe model";
  33. static const char *const kTFFormatSupport = "only support NCHW, NHWC, ND, NCDHW, NDHWC in TF model";
  34. static const char *const kONNXFormatSupport = "only support NCHW, ND in ONNX model";
  35. static std::map<std::string, domiTensorFormat_t> input_format_str_to_geformat = {
  36. {"ND", domi::DOMI_TENSOR_ND},
  37. {"NCHW", domi::DOMI_TENSOR_NCHW},
  38. {"NHWC", domi::DOMI_TENSOR_NHWC},
  39. {"CHWN", domi::DOMI_TENSOR_CHWN},
  40. {"NC1HWC0", domi::DOMI_TENSOR_NC1HWC0},
  41. {"NHWC1C0", domi::DOMI_TENSOR_NHWC1C0},
  42. {"NCDHW", domi::DOMI_TENSOR_NCDHW},
  43. {"NDHWC", domi::DOMI_TENSOR_NDHWC}
  44. };
  45. static const std::string kEnableCompressWeightTrue = "1";
  46. static const std::string kEnableCompressWeightFalse = "0";
  47. bool CheckDynamicBatchSizeInputShapeValid(unordered_map<string, vector<int64_t>> shape_map,
  48. std::string &dynamic_batch_size);
  49. bool CheckDynamicImagesizeInputShapeValid(unordered_map<string, vector<int64_t>> shape_map,
  50. const std::string input_format, std::string &dynamic_image_size);
  51. bool CheckDynamicDimsInputShapeValid(const std::unordered_map<std::string, std::vector<int64_t>> &shape_map,
  52. std::string input_format, std::string &dynamic_dims);
  53. bool CheckAndParseDynamicDims(int32_t dynamic_dim_num, std::string &dynamic_dims);
  54. Status CheckDynamicInputParamValid(std::string &dynamic_batch_size, std::string &dynamic_image_size,
  55. std::string &dynamic_dims, const std::string input_shape,
  56. const std::string input_format, bool &is_dynamic_input);
  57. bool ParseInputShape(const std::string &input_shape, std::unordered_map<string, std::vector<int64_t>> &shape_map,
  58. std::vector<std::pair<string, vector<int64_t>>> &user_shape_map, bool is_dynamic_input = false);
  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 std::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. }
  72. #endif // FRAMEWORK_DOMI_ATC_IR_COMMON_H_

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