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.

spliter.h 2.5 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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_PARALLEL_SPLITER_H
  17. #define MINDSPORE_LITE_TOOLS_OPTIMIZER_PARALLEL_SPLITER_H
  18. #include <vector>
  19. #include <string>
  20. #include <unordered_map>
  21. #include "schema/inner/model_generated.h"
  22. #include "utils/utils.h"
  23. #include "tools/optimizer/common/gllo_utils.h"
  24. #include "tools/converter/converter_flags.h"
  25. #include "include/context.h"
  26. #include "include/lite_types.h"
  27. namespace mindspore {
  28. namespace opt {
  29. class Spliter {
  30. public:
  31. static Spliter *GetInstance();
  32. Spliter(const Spliter &) = delete;
  33. Spliter &operator=(const Spliter &) = delete;
  34. // update current input node's output. if candidate node has been recorded, we will be ignore it, otherwise record it.
  35. void UpdateNodeOutputs(const std::string &input_node_name, const AnfNodePtr &candidate_output);
  36. // update current node's input shapes.
  37. void UpdateNodeInputShapes(const std::string &node_name, const std::vector<ShapeVector> &input_shapes);
  38. // update current node's output shapes.
  39. void UpdateNodeOutputShapes(const std::string &node_name, const std::vector<ShapeVector> &output_shapes);
  40. std::unordered_map<std::string, std::vector<AnfNodePtr>> graph_node_outputs() const { return graph_node_outputs_; }
  41. std::unordered_map<std::string, std::vector<ShapeVector>> graph_node_output_shapes() const {
  42. return graph_node_output_shapes_;
  43. }
  44. std::unordered_map<std::string, std::vector<ShapeVector>> graph_node_input_shapes() const {
  45. return graph_node_input_shapes_;
  46. }
  47. private:
  48. Spliter() = default;
  49. virtual ~Spliter() = default;
  50. private:
  51. std::unordered_map<std::string, std::vector<AnfNodePtr>> graph_node_outputs_;
  52. std::unordered_map<std::string, std::vector<ShapeVector>> graph_node_output_shapes_;
  53. std::unordered_map<std::string, std::vector<ShapeVector>> graph_node_input_shapes_;
  54. };
  55. } // namespace opt
  56. } // namespace mindspore
  57. #endif // MINDSPORE_LITE_TOOLS_OPTIMIZER_PARALLEL_SPLITER_H