• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
17 #ifndef MINDSPORE_LITE_TOOLS_OPTIMIZER_FISSON_MULTI_CONV_SPLIT_H_
18 #define MINDSPORE_LITE_TOOLS_OPTIMIZER_FISSON_MULTI_CONV_SPLIT_H_
19 
20 #include <utility>
21 #include <vector>
22 #include <string>
23 #include <unordered_map>
24 #include "schema/model_generated.h"
25 #include "backend/optimizer/common/optimizer.h"
26 #include "tools/optimizer/fisson/fisson_util.h"
27 #include "tools/optimizer/parallel/split_strategy.h"
28 #include "tools/optimizer/parallel/multi_node_split.h"
29 
30 using mindspore::schema::PrimitiveType;
31 namespace mindspore {
32 namespace opt {
33 
34 class MultiConvSplitPass : public PatternProcessPass {
35  public:
36   explicit MultiConvSplitPass(std::unordered_map<std::string, SplitStrategy> strategys, int32_t fmk_type = -1,
37                               int32_t num = 3, bool multigraph = true)
38       : PatternProcessPass("multi_conv_split", multigraph),
39         strategys_(std::move(strategys)),
40         fmk_type_(fmk_type),
41         num_(num) {}
42   ~MultiConvSplitPass() override = default;
43 
44  private:
45   const BaseRef DefinePattern() const override;
46   const AnfNodePtr Process(const FuncGraphPtr &, const AnfNodePtr &, const EquivPtr &) const override;
47   std::string IsMultiParallelConvNode(const AnfNodePtr &node) const;
48 
49  private:
50   std::unordered_map<std::string, SplitStrategy> strategys_{};
51   PrimitiveType primitive_type_{schema::PrimitiveType_NONE};
52   int32_t fmk_type_{-1};
53   int32_t num_{0};
54 };
55 }  // namespace opt
56 }  // namespace mindspore
57 #endif  // MINDSPORE_LITE_TOOLS_OPTIMIZER_FISSON_MULTI_CONV_SPLIT_H_
58