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.

fisson_util.h 3.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /**
  2. * Copyright 2021 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 MINDSPORE_LITE_TOOLS_OPTIMIZER_FISSON_FISSON_UTIL_H_
  17. #define MINDSPORE_LITE_TOOLS_OPTIMIZER_FISSON_FISSON_UTIL_H_
  18. #include <vector>
  19. #include <string>
  20. #include <unordered_map>
  21. #include <memory>
  22. #include "schema/inner/model_generated.h"
  23. #include "mindspore/ccsrc/utils/utils.h"
  24. #include "tools/optimizer/common/gllo_utils.h"
  25. #include "tools/converter/converter_flags.h"
  26. #include "mindspore/lite/include/context.h"
  27. #include "mindspore/lite/include/lite_types.h"
  28. #include "ops/fusion/conv2d_fusion.h"
  29. namespace mindspore {
  30. using mindspore::schema::PrimitiveType;
  31. namespace opt {
  32. struct SplitInfo {
  33. int64_t axis{0};
  34. int64_t out_num{0};
  35. std::vector<int64_t> size_splits{};
  36. std::vector<int64_t> extend_top{};
  37. std::vector<int64_t> extend_bottom{};
  38. std::vector<mindspore::lite::DeviceType> dev_types{};
  39. int64_t ori_split_axis_value{0};
  40. int64_t in_num_conv{0};
  41. int64_t fmk_type{0};
  42. PrimitiveType primitive_type{schema::PrimitiveType_NONE};
  43. };
  44. typedef enum { CUT_N, CUT_H, CUT_W, CUT_C_IN, CUT_C_OUT, CUT_NONE } CuttingStragedy;
  45. std::vector<int64_t> GetSplitPadList(const std::shared_ptr<ops::Conv2DFusion> &ori_conv_prim, int64_t input_h,
  46. int64_t input_w);
  47. bool IsConv2D(const AnfNodePtr &node);
  48. std::shared_ptr<ops::Conv2DFusion> CopyConvPrim(const std::shared_ptr<ops::Conv2DFusion> &ori_attr);
  49. bool UpdateSplitInfo(const FuncGraphPtr &func_graph, const std::vector<AnfNodePtr> &conv_nodes, SplitInfo *split_info);
  50. bool GetMultipleOutputsOfAnfNode(const FuncGraphPtr &func_graph, const AnfNodePtr &node, size_t output_num,
  51. std::vector<AnfNodePtr> *outputs);
  52. AnfNodePtr CreateOutputsOfConcat(const FuncGraphPtr &func_graph, const AnfNodePtr &conv_cnode,
  53. const std::vector<AnfNodePtr> &conv_outputs, SplitInfo *split_info,
  54. const std::string &node_name);
  55. bool CreateOutputsOfSplitWithOverlap(const FuncGraphPtr &func_graph, const AnfNodePtr &conv_cnode,
  56. std::vector<AnfNodePtr> *split_outputs, SplitInfo *split_info,
  57. const std::string &node_name);
  58. bool UpdateRatioWithPadStride(int64_t *ratio, size_t ratio_len, size_t split_size, int split_dim_size);
  59. } // namespace opt
  60. } // namespace mindspore
  61. #endif // MINDSPORE_LITE_TOOLS_OPTIMIZER_FISSON_FISSON_UTIL_H_