From: @jjfeing Reviewed-by: @kisnwang,@zhoufeng54 Signed-off-by: @zhoufeng54tags/v1.1.0
| @@ -25,8 +25,6 @@ build_in_impl_path = get_build_in_impl_path() | |||||
| # op function list | # op function list | ||||
| op_build = "compile" | op_build = "compile" | ||||
| fusion_pattern_start_flag = "fusion_pattern_start" | |||||
| fusion_pattern_end_flag = "fusion_pattern_end" | |||||
| def _initialize(impl_path): | def _initialize(impl_path): | ||||
| """Initialize""" | """Initialize""" | ||||
| @@ -157,5 +155,6 @@ def compile_with_json(json_str): | |||||
| if __name__ == "__main__": | 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) | ||||
| sys.stdout.write(fusion_pattern_start_flag + str(result) + fusion_pattern_end_flag) | |||||
| sys.stdout.flush() | |||||
| if isinstance(result, dict): | |||||
| sys.stdout.write(json.dumps(result)) | |||||
| sys.stdout.flush() | |||||
| @@ -145,9 +145,6 @@ void ParallelBuildManager::PreTaskFinishProcess(int32_t task_id, const std::stri | |||||
| std::pair<int32_t, KernelModPtr> ParallelBuildManager::TaskFinishProcess(int32_t task_id, const std::string &build_ret, | std::pair<int32_t, KernelModPtr> ParallelBuildManager::TaskFinishProcess(int32_t task_id, const std::string &build_ret, | ||||
| bool set_kernel_mod) { | bool set_kernel_mod) { | ||||
| auto compile_info = ProcessBuildRetStr(build_ret); | |||||
| MS_LOG(DEBUG) << "Tbe build ret:" << compile_info; | |||||
| auto task_iter = task_map_.find(task_id); | auto task_iter = task_map_.find(task_id); | ||||
| if (task_iter == task_map_.end()) { | if (task_iter == task_map_.end()) { | ||||
| MS_EXCEPTION(ArgumentError) << "can find task_id:" << task_id; | MS_EXCEPTION(ArgumentError) << "can find task_id:" << task_id; | ||||
| @@ -170,8 +167,8 @@ std::pair<int32_t, KernelModPtr> ParallelBuildManager::TaskFinishProcess(int32_t | |||||
| MS_EXCEPTION_IF_NULL(kernel_mod); | MS_EXCEPTION_IF_NULL(kernel_mod); | ||||
| if (set_kernel_mod) { | if (set_kernel_mod) { | ||||
| AnfAlgo::SetKernelMod(kernel_mod, task_iter->second.node.get()); | AnfAlgo::SetKernelMod(kernel_mod, task_iter->second.node.get()); | ||||
| AnfAlgo::SetNodeAttr(kAttrCompileInfo, MakeValue(compile_info), task_iter->second.node); | |||||
| MS_LOG(DEBUG) << "Set Node Attr compile_info:" << compile_info; | |||||
| AnfAlgo::SetNodeAttr(kAttrCompileInfo, MakeValue(build_ret), task_iter->second.node); | |||||
| MS_LOG(INFO) << "Set Node Attr compile_info:" << build_ret; | |||||
| } | } | ||||
| auto ret = std::make_pair(task_iter->second.scope_id, kernel_mod); | auto ret = std::make_pair(task_iter->second.scope_id, kernel_mod); | ||||
| (void)task_map_.erase(task_iter); | (void)task_map_.erase(task_iter); | ||||
| @@ -258,19 +255,5 @@ AnfNodePtr ParallelBuildManager::GetAnfNodeByTaskID(int32_t task_id) { | |||||
| } | } | ||||
| return nullptr; | return nullptr; | ||||
| } | } | ||||
| std::string ParallelBuildManager::ProcessBuildRetStr(const std::string &build_result) { | |||||
| std::string start_flag = "fusion_pattern_start"; | |||||
| std::string end_flag = "fusion_pattern_end"; | |||||
| int start = build_result.find(start_flag); | |||||
| int end = build_result.find(end_flag); | |||||
| if (start != -1 && end != -1 && end >= start) { | |||||
| std::string result = build_result.substr(start + start_flag.size(), end - start - start_flag.size()); | |||||
| if (!result.empty()) { | |||||
| return result; | |||||
| } | |||||
| } | |||||
| return ""; | |||||
| } | |||||
| } // namespace kernel | } // namespace kernel | ||||
| } // namespace mindspore | } // namespace mindspore | ||||
| @@ -66,9 +66,6 @@ class ParallelBuildManager { | |||||
| void ResetTaskInfo(); | void ResetTaskInfo(); | ||||
| AnfNodePtr GetAnfNodeByTaskID(int32_t task_id); | AnfNodePtr GetAnfNodeByTaskID(int32_t task_id); | ||||
| private: | |||||
| std::string ProcessBuildRetStr(const std::string &build_result); | |||||
| private: | private: | ||||
| std::map<int32_t, AnfNodePtr> pre_task_map_; | std::map<int32_t, AnfNodePtr> pre_task_map_; | ||||
| std::map<int32_t, KernelBuildTaskInfo> task_map_; | std::map<int32_t, KernelBuildTaskInfo> task_map_; | ||||
| @@ -15,8 +15,6 @@ | |||||
| */ | */ | ||||
| #include "runtime/device/ascend/executor/ai_core_dynamic_kernel.h" | #include "runtime/device/ascend/executor/ai_core_dynamic_kernel.h" | ||||
| #include <regex> | |||||
| #include <algorithm> | #include <algorithm> | ||||
| #include <memory> | #include <memory> | ||||
| #include "framework/common/debug/log.h" | #include "framework/common/debug/log.h" | ||||
| @@ -54,15 +52,6 @@ void AiCoreDynamicKernel::Execute() { | |||||
| MS_LOG(INFO) << "End Execute node:" << cnode_ptr_->fullname_with_scope(); | MS_LOG(INFO) << "End Execute node:" << cnode_ptr_->fullname_with_scope(); | ||||
| } | } | ||||
| std::string ReplaceInvalidJsonStr(const std::string &str) { | |||||
| auto ret = std::regex_replace(str, std::regex("100000000"), R"("100000000")"); | |||||
| ret = std::regex_replace(ret, std::regex("100000001"), R"("100000001")"); | |||||
| ret = std::regex_replace(ret, std::regex("100000002"), R"("100000002")"); | |||||
| ret = std::regex_replace(ret, std::regex("True"), R"(true)"); | |||||
| ret = std::regex_replace(ret, std::regex("False"), R"(false)"); | |||||
| return ret; | |||||
| } | |||||
| void AiCoreDynamicKernel::ParseCompileJson() { | void AiCoreDynamicKernel::ParseCompileJson() { | ||||
| if (!AnfAlgo::IsDynamicShape(cnode_ptr_)) { | if (!AnfAlgo::IsDynamicShape(cnode_ptr_)) { | ||||
| return; | return; | ||||
| @@ -71,8 +60,6 @@ void AiCoreDynamicKernel::ParseCompileJson() { | |||||
| MS_LOG(EXCEPTION) << "Get compile_info failed"; | MS_LOG(EXCEPTION) << "Get compile_info failed"; | ||||
| } | } | ||||
| auto compile_info_attr = AnfAlgo::GetNodeAttr<std::string>(cnode_ptr_, kAttrCompileInfo); | auto compile_info_attr = AnfAlgo::GetNodeAttr<std::string>(cnode_ptr_, kAttrCompileInfo); | ||||
| std::replace(compile_info_attr.begin(), compile_info_attr.end(), '\'', '\"'); | |||||
| compile_info_attr = ReplaceInvalidJsonStr(compile_info_attr); | |||||
| MS_LOG(INFO) << "Get compile_info:" << compile_info_attr; | MS_LOG(INFO) << "Get compile_info:" << compile_info_attr; | ||||
| op_compile_info_.str = compile_info_attr; | op_compile_info_.str = compile_info_attr; | ||||
| op_compile_info_.key = ""; | op_compile_info_.key = ""; | ||||