| @@ -156,5 +156,5 @@ if __name__ == "__main__": | |||||
| in_args = sys.stdin.readline() | in_args = sys.stdin.readline() | ||||
| result = compile_with_json(in_args) | result = compile_with_json(in_args) | ||||
| if isinstance(result, dict): | if isinstance(result, dict): | ||||
| sys.stdout.write(json.dumps(result)) | |||||
| sys.stdout.flush() | |||||
| sys.stderr.write(json.dumps(result)) | |||||
| sys.stderr.flush() | |||||
| @@ -89,14 +89,12 @@ def run_compiler(op_json): | |||||
| tbe_compiler = os.path.join(os.path.split(os.path.realpath(__file__))[0], "compiler.py") | tbe_compiler = os.path.join(os.path.split(os.path.realpath(__file__))[0], "compiler.py") | ||||
| completed_object = subprocess.run([sys.executable, tbe_compiler], input=op_json, timeout=300, | completed_object = subprocess.run([sys.executable, tbe_compiler], input=op_json, timeout=300, | ||||
| text=True, capture_output=True, check=True) | text=True, capture_output=True, check=True) | ||||
| if completed_object: | |||||
| out = completed_object.stdout | |||||
| return "Success", out | |||||
| return "Success", completed_object.stderr | |||||
| except subprocess.TimeoutExpired: | except subprocess.TimeoutExpired: | ||||
| tb = traceback.format_exc() | tb = traceback.format_exc() | ||||
| return "TBEException", "PreCompileTimeOut: " + tb + "\ninput_args: " + op_json | |||||
| return "TBEException", "ERROR: " + tb + "\ninput_args: " + op_json | |||||
| except subprocess.CalledProcessError as e: | except subprocess.CalledProcessError as e: | ||||
| return "TBEException", "PreCompileProcessFailed:\n" + e.stdout + "\n" + e.stderr + "\ninput_args: " + op_json | |||||
| return "TBEException", "ERROR:\n" + e.stdout + "\n" + e.stderr + "\ninput_args: " + op_json | |||||
| class TbeProcess: | class TbeProcess: | ||||
| """tbe process""" | """tbe process""" | ||||
| @@ -148,9 +148,6 @@ bool TbeKernelJsonCreator::GenTbeSingleKernelJson(const std::shared_ptr<mindspor | |||||
| op_info_json[kJKernelName] = json_name_; | op_info_json[kJKernelName] = json_name_; | ||||
| (*kernel_json)[kJOpInfo] = op_info_json; | (*kernel_json)[kJOpInfo] = op_info_json; | ||||
| (*kernel_json)[kJFullName] = anf_node->fullname_with_scope(); | (*kernel_json)[kJFullName] = anf_node->fullname_with_scope(); | ||||
| if (creater_type_ == SINGLE_BUILD) { | |||||
| TbeUtils::SaveJsonInfo(json_name_, json_info_); | |||||
| } | |||||
| MS_LOG(INFO) << "Operate type:" << creater_type_ << ", full scope name is :" << anf_node->fullname_with_scope() | MS_LOG(INFO) << "Operate type:" << creater_type_ << ", full scope name is :" << anf_node->fullname_with_scope() | ||||
| << ", json info name is : " << json_name_ << ", kernel json:" << kernel_json->dump(); | << ", json info name is : " << json_name_ << ", kernel json:" << kernel_json->dump(); | ||||
| @@ -47,6 +47,7 @@ bool TbeOpParallelBuild(const std::vector<AnfNodePtr> &anf_nodes) { | |||||
| TbeKernelJsonCreator creator(SINGLE_BUILD); | TbeKernelJsonCreator creator(SINGLE_BUILD); | ||||
| if (!creator.GenTbeSingleKernelJson(anf_node, &kernel_json)) { | if (!creator.GenTbeSingleKernelJson(anf_node, &kernel_json)) { | ||||
| MS_LOG(ERROR) << "GenTbeSingleKernelJson failed"; | MS_LOG(ERROR) << "GenTbeSingleKernelJson failed"; | ||||
| TbeUtils::SaveJsonInfo(kernel_json["op_info"]["kernel_name"], kernel_json["op_info"].dump()); | |||||
| return false; | return false; | ||||
| } | } | ||||
| // get size | // get size | ||||
| @@ -69,6 +70,7 @@ bool TbeOpParallelBuild(const std::vector<AnfNodePtr> &anf_nodes) { | |||||
| } | } | ||||
| (void)processed_kernel.insert(json_name); | (void)processed_kernel.insert(json_name); | ||||
| // op build | // op build | ||||
| TbeUtils::SaveJsonInfo(kernel_json["op_info"]["kernel_name"], kernel_json["op_info"].dump()); | |||||
| auto task_id = build_manger->StartCompileOp(kernel_json); | auto task_id = build_manger->StartCompileOp(kernel_json); | ||||
| build_manger->SaveTaskInfo(task_id, anf_node, json_name, input_size_list, output_size_list); | build_manger->SaveTaskInfo(task_id, anf_node, json_name, input_size_list, output_size_list); | ||||
| } | } | ||||
| @@ -492,10 +492,10 @@ std::string TbeKernelSelect::OpSelectFormat() { | |||||
| } | } | ||||
| res_json_str = AscendKernelBuildClient::Instance().SelectFormat(kernel_json.dump()); | res_json_str = AscendKernelBuildClient::Instance().SelectFormat(kernel_json.dump()); | ||||
| if (res_json_str.empty()) { | if (res_json_str.empty()) { | ||||
| MS_LOG(EXCEPTION) << "Op select format error."; | |||||
| MS_LOG(EXCEPTION) << "Op select format error, input args: " << kernel_json.dump(); | |||||
| } | } | ||||
| if (res_json_str.find("TBEException") != std::string::npos) { | if (res_json_str.find("TBEException") != std::string::npos) { | ||||
| MS_LOG(EXCEPTION) << "Dynamic op select failed: " << res_json_str; | |||||
| MS_LOG(EXCEPTION) << "Dynamic op select failed: " << res_json_str << ", input args: " << kernel_json.dump(); | |||||
| } | } | ||||
| MS_LOG(INFO) << "Dynamic select foramt response result:" << res_json_str; | MS_LOG(INFO) << "Dynamic select foramt response result:" << res_json_str; | ||||
| return res_json_str; | return res_json_str; | ||||
| @@ -44,23 +44,24 @@ void TbeUtils::SaveJsonInfo(const std::string &json_name, const std::string &inf | |||||
| char real_path[PATH_MAX] = {0}; | char real_path[PATH_MAX] = {0}; | ||||
| std::string path = kCceKernelMeta + json_name + kInfoSuffix; | std::string path = kCceKernelMeta + json_name + kInfoSuffix; | ||||
| if (path.size() > PATH_MAX) { | if (path.size() > PATH_MAX) { | ||||
| MS_LOG(ERROR) << "file path: " << path << "is too long."; | |||||
| MS_LOG(ERROR) << "File path: " << path << "is too long."; | |||||
| return; | return; | ||||
| } | } | ||||
| std::ifstream fin(path); | std::ifstream fin(path); | ||||
| if (fin) { | if (fin) { | ||||
| MS_LOG(INFO) << "json file exist, no need to create."; | |||||
| MS_LOG(INFO) << "Json file exist(" << path << "), no need to create."; | |||||
| return; | return; | ||||
| } | } | ||||
| std::ofstream file_write; | std::ofstream file_write; | ||||
| file_write.open(path); | file_write.open(path); | ||||
| if (!file_write.is_open()) { | if (!file_write.is_open()) { | ||||
| MS_LOG(WARNING) << "Create info file failed(" << path << ")."; | |||||
| return; | return; | ||||
| } | } | ||||
| file_write << info << std::endl; | file_write << info << std::endl; | ||||
| file_write.close(); | file_write.close(); | ||||
| if (realpath(path.c_str(), real_path) == nullptr) { | if (realpath(path.c_str(), real_path) == nullptr) { | ||||
| MS_LOG(INFO) << "dir: " << path << "does not exit."; | |||||
| MS_LOG(WARNING) << "Get realpath failed(" << path << ")."; | |||||
| return; | return; | ||||
| } | } | ||||
| MS_LOG(INFO) << "real path is: " << real_path; | MS_LOG(INFO) << "real path is: " << real_path; | ||||