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_CCSRC_RUNTIME_DEVICE_ASCEND_PASS_SWITCH_MANAGER_H_ 17 #define MINDSPORE_CCSRC_RUNTIME_DEVICE_ASCEND_PASS_SWITCH_MANAGER_H_ 18 19 #include <memory> 20 #include <string> 21 #include <map> 22 #include <vector> 23 24 namespace mindspore { 25 enum class OptPassEnum { 26 MatmulBiasaddFusion, 27 MulAddFusion, 28 ReshapeTransposeFusion, 29 SoftmaxGradExtFusion, 30 SquareSumFusion, 31 TransposeReshapeFusion, 32 ClipByNormNoDivSquareSumFusion, 33 MomentumLossscaleFusion, 34 DereluFusion, 35 FusedBatchNormFusion, 36 MatmulEltwiseFusionPass, 37 BatchMatmulFusedMulAddFusionPass, 38 EltwiseFusionPass, 39 MultiOutputFusionPass, 40 BnupdateEltwiseEltwiseFusionPass, 41 BnupdateEltwiseFusionPass, 42 Conv2DBackpropEltwiseFusionPass, 43 ConvBnReduceFusionPass, 44 MulAddNPass, 45 Resnet50DbnDwFusionPass, 46 MatmulConfusiontransposeUbFusion, 47 TbeBatchMatmulElementWiseFusionPass, 48 }; 49 50 class LicManager { 51 public: 52 static LicManager &GetInstance(); 53 bool GetPassSwitch(OptPassEnum pass) const; GetOpTuneSwitch()54 const std::string &GetOpTuneSwitch() const { return op_tune_switch_; } GetOpTuneList()55 const std::string &GetOpTuneList() const { return op_tune_list_; } GetRlTuneSwitch()56 const std::string &GetRlTuneSwitch() const { return rl_tune_switch_; } GetRlTuneList()57 const std::string &GetRlTuneList() const { return rl_tune_list_; } GetPassSwitch()58 const std::string &GetPassSwitch() const { return pass_list_; } 59 60 private: 61 LicManager(); 62 ~LicManager() = default; 63 64 void ParseSwitch(); 65 void ParseFeSwitch(const std::map<std::string, std::string> &options_map); 66 void ParseOpTuneSwitch(const std::map<std::string, std::string> &options_map); 67 void ParsePassSwitch(const std::map<std::string, std::string> &options_map); 68 void ParseRlSwitch(const std::map<std::string, std::string> &options_map); 69 70 std::map<OptPassEnum, bool> pass_switch_ = {}; 71 std::string op_tune_switch_ = "null"; 72 std::string op_tune_list_ = {}; 73 std::string pass_list_ = "invalid"; 74 std::string rl_tune_switch_ = "null"; 75 std::string rl_tune_list_ = {}; 76 }; 77 } // namespace mindspore 78 #endif // MINDSPORE_CCSRC_RUNTIME_DEVICE_ASCEND_PASS_SWITCH_MANAGER_H_ 79