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_SRC_RUNTIME_RUNTIME_PASS_H_ 18 #define MINDSPORE_LITE_SRC_RUNTIME_RUNTIME_PASS_H_ 19 20 #include <vector> 21 #include "src/executor/kernel_exec.h" 22 #include "src/executor/sub_graph_kernel.h" 23 #include "schema/ops_generated.h" 24 #include "schema/model_generated.h" 25 26 namespace mindspore::lite { 27 STATUS RuntimePass(std::vector<kernel::KernelExec *> *subgraphs, std::vector<Tensor *> *tensors); 28 STATUS GraphOptimizePass(std::vector<kernel::KernelExec *> *sub_graphs); 29 #ifndef RUNTIME_PASS_CLIP 30 /* Nc4hw4 PASS 31 * before : --(nhwc)-- CONV --(nhwc)-- TRANSPOSE --(nchw)-- IN --(nchw)-- TRANSPOSE --(nhwc)-- 32 * after : --(nhwc)-- CONV --(nc4hw4)-- IN --(nhwc)-- 33 * */ 34 static const schema::PrimitiveType Nc4hw4FormatTransposeOp = schema::PrimitiveType_Transpose; 35 static const std::vector<schema::PrimitiveType> Nc4hw4FormatOutOpList = {schema::PrimitiveType_Conv2DFusion}; 36 static const std::vector<schema::PrimitiveType> Nc4hw4FormatInOpList = {schema::PrimitiveType_InstanceNorm}; 37 38 /* 39 * ConvNormC4 PASS 40 * before : --(nhwc)-- CONV --(nhwc)-- INSTANCENORM --(nhwc)-- 41 * after : --(nhwc)-- CONV --(nc4hw4)-- INSTANCENORM --(nhwc)-- 42 * 43 * before : --(nhwc)-- CONV --(nhwc)-- ACT --(nhwc)-- INSTANCENORM --(nhwc)-- 44 * after : --(nhwc)-- CONV --(nc4hw4)-- ACT --(nc4hw4)-- INSTANCENORM --(nhwc)-- 45 * */ 46 static const schema::PrimitiveType ConvNormC4OpConv2DFusion = schema::PrimitiveType_Conv2DFusion; 47 static const schema::PrimitiveType ConvNormC4OpActivation = schema::PrimitiveType_Activation; 48 static const schema::PrimitiveType ConvNormC4OpInstanceNorm = schema::PrimitiveType_InstanceNorm; 49 #endif 50 } // namespace mindspore::lite 51 #endif // MINDSPORE_LITE_SRC_RUNTIME_RUNTIME_PASS_H_ 52