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 #include "pipeline/jit/ps/event_message_print.h" 18 #include <iostream> 19 #include "utils/log_adapter.h" 20 #include "pipeline/jit/ps/pipeline.h" 21 22 namespace mindspore { 23 namespace pipeline { PrintCompileStartMsg(const std::string & phase,const std::string & obj_desc)24void EventMessage::PrintCompileStartMsg(const std::string &phase, const std::string &obj_desc) { 25 if (IsPhaseLoadFromMindIR(phase)) { 26 return; 27 } 28 PrintEventMessage("Start compiling " + obj_desc + " and it will take a while. Please wait..."); 29 PrintCompileStatusMessage("Start compiling " + obj_desc + "."); 30 } 31 PrintCompileEndMsg(const std::string & phase,const std::string & obj_desc)32void EventMessage::PrintCompileEndMsg(const std::string &phase, const std::string &obj_desc) { 33 if (IsPhaseLoadFromMindIR(phase)) { 34 return; 35 } 36 PrintEventMessage("End compiling " + obj_desc + "."); 37 PrintCompileStatusMessage("End compiling " + obj_desc + "."); 38 } 39 PrintEventMessage(const std::string & message)40void EventMessage::PrintEventMessage(const std::string &message) { MS_LOG(INFO) << message; } 41 PrintCompileStatusMessage(const std::string & message)42void EventMessage::PrintCompileStatusMessage(const std::string &message) { 43 static const auto need_display_progress = (common::GetEnv("MS_JIT_DISPLAY_PROGRESS") == "1"); 44 if (need_display_progress) { 45 auto sys_time = GetTimeString(); 46 std::cout << sys_time << ": " << message << std::endl; 47 } 48 } 49 } // namespace pipeline 50 } // namespace mindspore 51