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 2.9 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 "schema/inner/model_generated.h"
  22. #include "mindspore/ccsrc/utils/utils.h"
  23. #include "tools/optimizer/common/gllo_utils.h"
  24. #include "tools/converter/converter_flags.h"
  25. #include "mindspore/lite/include/context.h"
  26. #include "mindspore/lite/include/lite_types.h"
  27. namespace mindspore {
  28. using mindspore::schema::PrimitiveType;
  29. namespace opt {
  30. extern std::unordered_map<std::string, std::vector<AnfNodePtr>> g_graph_nodes_output;
  31. extern std::unordered_map<std::string, std::vector<std::vector<ShapeVector>>> g_graph_nodes_out_shapes;
  32. struct SplitInfo {
  33. int32_t axis;
  34. int32_t out_num;
  35. std::vector<int32_t> size_splits;
  36. std::vector<int32_t> extend_top;
  37. std::vector<int32_t> extend_bottom;
  38. std::vector<mindspore::lite::DeviceType> dev_types;
  39. int32_t in_num_conv;
  40. int32_t fmk_type;
  41. std::vector<int32_t> weight_channel;
  42. PrimitiveType primitive_type;
  43. };
  44. typedef enum { CUT_N, CUT_H, CUT_W, CUT_C_IN, CUT_C_OUT, CUT_NONE } CuttingStragedy;
  45. void GetMultipleOutputsOfAnfNode(const FuncGraphPtr &func_graph, const AnfNodePtr &node, size_t output_num,
  46. std::vector<AnfNodePtr> *outputs);
  47. AnfNodePtr CreateOutputsOfConcat(const FuncGraphPtr &func_graph, const CNodePtr &conv_cnode,
  48. const std::vector<AnfNodePtr> &conv_outputs, const SplitInfo &split_info,
  49. const std::string &node_name);
  50. void CreateOutputsOfSplitWithOverlap(const FuncGraphPtr &func_graph, const CNodePtr &conv_cnode,
  51. std::vector<AnfNodePtr> *split_outputs, const SplitInfo &split_info,
  52. const std::string &node_name);
  53. void GetCNodeShapeInfo(const FuncGraphPtr &func_graph, int32_t fmk_type);
  54. AnfNodePtr CreateOutputsOfAddN(const FuncGraphPtr &func_graph, const CNodePtr &conv_cnode,
  55. const std::vector<AnfNodePtr> &conv_outputs, const SplitInfo &split_info,
  56. const std::string &node_name);
  57. } // namespace opt
  58. } // namespace mindspore
  59. #endif // MINDSPORE_LITE_TOOLS_OPTIMIZER_FISSON_FISSON_UTIL_H_