1 /** 2 * Copyright 2022 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_SRC_TRAIN_OPTIMIZER_COMMON_FUSION_UTILS_H_ 18 #define MINDSPORE_LITE_SRC_TRAIN_OPTIMIZER_COMMON_FUSION_UTILS_H_ 19 20 #include <vector> 21 #include <unordered_map> 22 #include <string> 23 #include <memory> 24 #include "src/common/utils.h" 25 #include "schema/inner/model_generated.h" 26 #include "tools/converter/legacy_optimizer/fusion/fusion_pattern.h" 27 28 using mindspore::lite::RET_ERROR; 29 using mindspore::lite::RET_NULL_PTR; 30 using mindspore::lite::RET_OK; 31 using mindspore::lite::STATUS; 32 namespace mindspore { 33 namespace opt { 34 inline constexpr int kInputIndexZero = 0; 35 inline constexpr int kInputIndexOne = 1; 36 inline constexpr int kInputIndexTwo = 2; 37 inline constexpr int kOutputIndexZero = 0; 38 inline constexpr int kOutputIndexOne = 1; 39 inline constexpr size_t kInputSizeTwo = 2; 40 inline constexpr size_t kInputSizeThree = 3; 41 inline constexpr size_t kOutputSizeOne = 1; 42 inline constexpr size_t kMatchPathLenTwo = 2; 43 inline constexpr size_t kMatchPathLenThree = 3; 44 45 STATUS GetMatchNodeIndex(schema::MetaGraphT *graph, 46 const std::unordered_map<std::string, std::shared_ptr<lite::Path>> &matched_path, 47 const std::string &node_name, size_t *node_index); 48 49 bool IsMultiOutputNode(schema::MetaGraphT *graph, size_t out_node_index); 50 } // namespace opt 51 } // namespace mindspore 52 #endif // MINDSPORE_LITE_SRC_TRAIN_OPTIMIZER_COMMON_FUSION_UTILS_H_ 53