!12147 dynamic op add to cache

From: @jjfeing
Reviewed-by: @chujinjin,@zhoufeng54
Signed-off-by: @zhoufeng54
This commit is contained in:
mindspore-ci-bot 2021-02-05 14:14:53 +08:00 committed by Gitee
commit 07c01cecee
2 changed files with 7 additions and 4 deletions

View File

@ -94,6 +94,7 @@ constexpr auto kJListArgs = "list_args";
constexpr auto kJSocVersion = "socVersion"; constexpr auto kJSocVersion = "socVersion";
constexpr auto kSOC_VERSION = "SOC_VERSION"; constexpr auto kSOC_VERSION = "SOC_VERSION";
constexpr auto kJIsDynamicShape = "is_dynamic_shape"; constexpr auto kJIsDynamicShape = "is_dynamic_shape";
constexpr auto kJDynamicIndex = "dynamic_index";
bool IsNeedChangeDefaultFormat(const CNodePtr &cnode) { bool IsNeedChangeDefaultFormat(const CNodePtr &cnode) {
MS_EXCEPTION_IF_NULL(cnode); MS_EXCEPTION_IF_NULL(cnode);
@ -137,6 +138,10 @@ bool TbeKernelJsonCreator::GenTbeSingleKernelJson(const std::shared_ptr<mindspor
op_info_json[kJAttrs] = attrs_json; op_info_json[kJAttrs] = attrs_json;
auto soc_version = TbeKernelJsonCreator::GetSocVersion(); auto soc_version = TbeKernelJsonCreator::GetSocVersion();
op_info_json[kJSocVersion] = soc_version; op_info_json[kJSocVersion] = soc_version;
if (op_info_json[kJIsDynamicShape]) {
static int32_t dynamic_index = 0;
op_info_json[kJDynamicIndex] = dynamic_index++;
}
std::string json_str = op_info_json.dump(); std::string json_str = op_info_json.dump();
size_t hash_id = std::hash<std::string>()(json_str); size_t hash_id = std::hash<std::string>()(json_str);
auto context_ptr = MsContext::GetInstance(); auto context_ptr = MsContext::GetInstance();

View File

@ -56,13 +56,11 @@ bool TbeOpParallelBuild(const std::vector<AnfNodePtr> &anf_nodes) {
(void)TbeKernelBuild::GetIOSize(kernel_json, &input_size_list, &output_size_list, anf_node); (void)TbeKernelBuild::GetIOSize(kernel_json, &input_size_list, &output_size_list, anf_node);
// search cache // search cache
const std::string &json_name = creator.json_name(); const std::string &json_name = creator.json_name();
auto IsDynamicShape = tbe::TbeDynamicShapeUtil::GetDynamicShapeAttr(anf_node); if (build_manger->SearchInCache(json_name, processor, input_size_list, output_size_list, anf_node.get())) {
if (build_manger->SearchInCache(json_name, processor, input_size_list, output_size_list, anf_node.get()) &&
!IsDynamicShape) {
continue; continue;
} }
// same op not need build, but need wait build finish to set kernel mode // same op not need build, but need wait build finish to set kernel mode
if (processed_kernel.find(json_name) != processed_kernel.end() && !IsDynamicShape) { if (processed_kernel.find(json_name) != processed_kernel.end()) {
build_manger->SaveSameOpInfo(anf_node, json_name, input_size_list, output_size_list); build_manger->SaveSameOpInfo(anf_node, json_name, input_size_list, output_size_list);
continue; continue;
} }