Browse Source

!10229 change dynamic compile info to json

From: @jjfeing
Reviewed-by: @kisnwang,@zhoufeng54
Signed-off-by: @zhoufeng54
tags/v1.1.0
mindspore-ci-bot Gitee 5 years ago
parent
commit
b92ce84417
4 changed files with 5 additions and 39 deletions
  1. +3
    -4
      mindspore/_extends/parallel_compile/tbe_compiler/compiler.py
  2. +2
    -19
      mindspore/ccsrc/backend/kernel_compiler/tbe/tbe_kernel_parallel_build.cc
  3. +0
    -3
      mindspore/ccsrc/backend/kernel_compiler/tbe/tbe_kernel_parallel_build.h
  4. +0
    -13
      mindspore/ccsrc/runtime/device/ascend/executor/ai_core_dynamic_kernel.cc

+ 3
- 4
mindspore/_extends/parallel_compile/tbe_compiler/compiler.py View File

@@ -25,8 +25,6 @@ build_in_impl_path = get_build_in_impl_path()

# op function list
op_build = "compile"
fusion_pattern_start_flag = "fusion_pattern_start"
fusion_pattern_end_flag = "fusion_pattern_end"

def _initialize(impl_path):
"""Initialize"""
@@ -157,5 +155,6 @@ def compile_with_json(json_str):
if __name__ == "__main__":
in_args = sys.stdin.readline()
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()

+ 2
- 19
mindspore/ccsrc/backend/kernel_compiler/tbe/tbe_kernel_parallel_build.cc View File

@@ -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,
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);
if (task_iter == task_map_.end()) {
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);
if (set_kernel_mod) {
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);
(void)task_map_.erase(task_iter);
@@ -258,19 +255,5 @@ AnfNodePtr ParallelBuildManager::GetAnfNodeByTaskID(int32_t task_id) {
}
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 mindspore

+ 0
- 3
mindspore/ccsrc/backend/kernel_compiler/tbe/tbe_kernel_parallel_build.h View File

@@ -66,9 +66,6 @@ class ParallelBuildManager {
void ResetTaskInfo();
AnfNodePtr GetAnfNodeByTaskID(int32_t task_id);

private:
std::string ProcessBuildRetStr(const std::string &build_result);

private:
std::map<int32_t, AnfNodePtr> pre_task_map_;
std::map<int32_t, KernelBuildTaskInfo> task_map_;


+ 0
- 13
mindspore/ccsrc/runtime/device/ascend/executor/ai_core_dynamic_kernel.cc View File

@@ -15,8 +15,6 @@
*/

#include "runtime/device/ascend/executor/ai_core_dynamic_kernel.h"

#include <regex>
#include <algorithm>
#include <memory>
#include "framework/common/debug/log.h"
@@ -54,15 +52,6 @@ void AiCoreDynamicKernel::Execute() {
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() {
if (!AnfAlgo::IsDynamicShape(cnode_ptr_)) {
return;
@@ -71,8 +60,6 @@ void AiCoreDynamicKernel::ParseCompileJson() {
MS_LOG(EXCEPTION) << "Get compile_info failed";
}
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;
op_compile_info_.str = compile_info_attr;
op_compile_info_.key = "";


Loading…
Cancel
Save