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_PASS_H_ 18 #define MINDSPORE_LITE_TOOLS_OPTIMIZER_FISSON_MULTI_CONV_SPLIT_PASS_H_ 19 20 #include <utility> 21 #include <vector> 22 #include <string> 23 #include <unordered_map> 24 #include "schema/model_generated.h" 25 #include "tools/optimizer/common/pattern_process_pass_extends.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 LitePatternProcessPass { 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 : LitePatternProcessPass("multi_conv_split", multigraph), 39 strategys_(std::move(strategys)), 40 fmk_type_(fmk_type), 41 num_(num) {} 42 ~MultiConvSplitPass() override = default; 43 const BaseRef DefinePattern() const override; 44 const AnfNodePtr Process(const FuncGraphPtr &, const AnfNodePtr &, const EquivPtr &) const override; 45 46 private: 47 std::string IsMultiParallelConvNode(const AnfNodePtr &node) const; 48 49 std::unordered_map<std::string, SplitStrategy> strategys_{}; 50 PrimitiveType primitive_type_{schema::PrimitiveType_NONE}; 51 int32_t fmk_type_{-1}; 52 int32_t num_{0}; 53 }; 54 } // namespace opt 55 } // namespace mindspore 56 #endif // MINDSPORE_LITE_TOOLS_OPTIMIZER_FISSON_MULTI_CONV_SPLIT_PASS_H_ 57