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.

multi_batch_options.h 3.6 kB

4 years ago
4 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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_PREPROCESS_MULTI_BATCH_OPTIONS_H_
  17. #define GE_GRAPH_PREPROCESS_MULTI_BATCH_OPTIONS_H_
  18. #include <vector>
  19. #include "external/ge/ge_api_error_codes.h"
  20. #include "graph/ge_tensor.h"
  21. #include "graph/op_desc.h"
  22. #include "graph/node.h"
  23. namespace ge {
  24. namespace multibatch {
  25. ///
  26. /// @ingroup ge
  27. /// @brief Init Dynamic Param from Options.
  28. /// @param [out] std::vector<std::vector<int64_t>> &shapes: Result for Params.
  29. /// @return true: Configed for Multi batch / false: Not configed for Multi batch.
  30. ///
  31. bool InitDynamicParams(std::vector<std::vector<int64_t>> &shapes);
  32. ///
  33. /// @ingroup ge
  34. /// @brief Check Dynamic Param is invalid.
  35. /// @param [in] const vector<vector<int64_t>> &shapes: Params for check.
  36. /// @return SUCCESS: valid / PARAM_INVALID: invalid.
  37. ///
  38. Status CheckDynamicParams(const std::vector<std::vector<int64_t>> &shapes);
  39. ///
  40. /// @ingroup ge
  41. /// @brief Get GeShape from configed shape.
  42. /// @param [in] const std::vector<int64_t> &batch_shape: Configed shape.
  43. /// @param [out] GeShape &data_shape: GeShape for configed shape.
  44. /// @return SUCCESS / PARAM_INVALID
  45. ///
  46. Status CalcShape(const std::vector<int64_t> &batch_shape, GeShape &data_shape);
  47. ///
  48. /// @ingroup ge
  49. /// @brief parse each data's own dynamic dims.
  50. /// @param [in] vector<vector<int64_t>> &shapes: dynamic batch gears info.
  51. /// @param [in] vector<pair<string, vector<int64_t>>> data_name_and_shape: eg:{{data:{1,1,-1,2}}}.
  52. /// @param [out] map<string, vector<vector<int64_t>>> &data_to_dynamic_info: key:data_name. value:dynamic dims.
  53. /// @return SUCCESS / PARAM_INVALID
  54. ///
  55. Status ParserDataToDynmaicInfo(const vector<vector<int64_t>> &shapes,
  56. vector<pair<string, vector<int64_t>>> &data_name_and_shape,
  57. map<string, vector<vector<int64_t>>> &data_to_dynamic_info);
  58. ///
  59. /// @ingroup ge
  60. /// @brief Set mbatch_dynamic_type on node.
  61. /// @param [in] const OpDescPtr &op_desc: Node for set attribute.
  62. /// @return 0: SUCCESS / others: INTERNAL_ERROR
  63. ///
  64. Status StampDynamicType(const OpDescPtr &op_desc);
  65. ///
  66. /// @ingroup ge
  67. /// @brief Check dynamic batch Shape.
  68. /// @param [in] const vector<int64_t> &shape: data_shape to be checked.
  69. /// @param [in] const string &data_name: cur data name.
  70. /// @return 0: true/false
  71. ///
  72. bool CheckDynamicBatchShape(const vector<int64_t> &shape, const string &data_name);
  73. ///
  74. /// @ingroup ge
  75. /// @brief Check Dynamic image size shape.
  76. /// @param [in] unordered_map<string, vector<int64_t>> &shape_map: map of data_name and data_shape.
  77. /// @param [in] const string &data_name: cur data name.
  78. /// @param [in] const std::string &input_format: cur data format.
  79. /// @param [in] const std::string &input_format: format of input.
  80. /// @return 0: true/false
  81. ///
  82. bool CheckDynamicImageSizeShape(const vector<int64_t> &shape, const string &data_name,
  83. const std::string &input_format);
  84. } // namespace multibatch
  85. } // namespace ge
  86. #endif // GE_GRAPH_PREPROCESS_MULTI_BATCH_OPTIONS_H_

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