1 /** 2 * Copyright 2022-2023 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_CORE_UTILS_PHASE_H_ 18 #define MINDSPORE_CORE_UTILS_PHASE_H_ 19 20 #include <string> 21 #include <memory> 22 #include <map> 23 #include "mindapi/base/macros.h" 24 25 namespace mindspore { 26 class MS_CORE_API PhaseManager { 27 public: 28 /// \brief Get instance of PhaseManager. 29 /// 30 /// \return Instance of PhaseManager. 31 static PhaseManager &GetInstance() noexcept; 32 33 /// \brief Disable the default constructor. 34 PhaseManager(const PhaseManager &) = delete; 35 /// \brief Disable the default copy constructor. 36 PhaseManager &operator=(const PhaseManager &) = delete; 37 /// \brief Destructor. 38 ~PhaseManager() = default; 39 40 /// \brief Set the phase. 41 /// 42 /// \param[in] The phase of an obj to be compiled. set_phase(const std::string & phase)43 void set_phase(const std::string &phase) { phase_ = phase; } 44 45 /// \brief Get the current phase. 46 /// 47 /// \return The current phase. phase()48 const std::string &phase() const { return phase_; } 49 50 /// \brief Clear the phase by set an empty string. ClearPhase()51 void ClearPhase() { phase_ = ""; } 52 53 /// \brief Set jit config. 54 /// 55 /// \param[in] The current jit config. set_jit_config(const std::map<std::string,std::string> & jit_config)56 void set_jit_config(const std::map<std::string, std::string> &jit_config) { jit_config_ = jit_config; } 57 58 /// \brief Get the current jit config. 59 /// 60 /// \return The current jit config. jit_config()61 const std::map<std::string, std::string> &jit_config() const { return jit_config_; } 62 63 private: 64 PhaseManager() = default; 65 std::string phase_ = ""; 66 std::map<std::string, std::string> jit_config_; 67 }; 68 } // namespace mindspore 69 #endif // MINDSPORE_CORE_UTILS_PHASE_H_ 70