From 8a58f50f8a27b3b7a9fe1e3529f3b5ce70b838aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E7=A3=8A?= Date: Thu, 4 Mar 2021 19:58:43 +0800 Subject: [PATCH] fixed issue of dt_string --- ge/ge_runtime/runtime_model.cc | 12 ++++++++++-- ge/hybrid/model/hybrid_model_builder.cc | 13 +++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/ge/ge_runtime/runtime_model.cc b/ge/ge_runtime/runtime_model.cc index b30ca1bf..71147a4b 100644 --- a/ge/ge_runtime/runtime_model.cc +++ b/ge/ge_runtime/runtime_model.cc @@ -28,7 +28,10 @@ namespace ge { namespace model_runner { +namespace { const int kOffsetUnit = 8; +const uint32_t kStringHeadElems = 2; +} // namespace RuntimeModel::~RuntimeModel() { GELOGI("RuntimeModel destructor start"); @@ -496,10 +499,15 @@ bool RuntimeModel::InitConstantInfo(std::shared_ptr &davinci_model return false; } uint64_t *buff = reinterpret_cast(const_cast(constant->weight_data.data())); - int64_t offset = elem_num * kOffsetUnit; + uint32_t head_len = kOffsetUnit * kStringHeadElems; + if (ge::CheckInt64Uint32MulOverflow(elem_num, head_len) != SUCCESS) { + GELOGE(FAILED, "Shape size is invalid"); + return false; + } + int64_t offset = elem_num * head_len; uintptr_t hbm_raw_data_base_addr = reinterpret_cast(constant->output_addrs[0]) + offset; for (int64_t i = elem_num - 1; i >= 0; --i) { - buff[i] = hbm_raw_data_base_addr + (buff[i] - buff[0]); + buff[i * kStringHeadElems] = hbm_raw_data_base_addr + (buff[i * kStringHeadElems] - buff[0]); } } diff --git a/ge/hybrid/model/hybrid_model_builder.cc b/ge/hybrid/model/hybrid_model_builder.cc index 48558e83..ac57b2ea 100755 --- a/ge/hybrid/model/hybrid_model_builder.cc +++ b/ge/hybrid/model/hybrid_model_builder.cc @@ -42,6 +42,7 @@ const uint64_t kProfilingFpStartLogid = 1U; const uint64_t kProfilingBpEndLogid = 2U; const uint64_t kProfilingIterEndLogid = 65535U; const int kBytes = 8; +const uint32_t kStringHeadElems = 2; const char *const kOwnerGraphIsUnknown = "OwnerGraphIsUnknown"; const char *const kProfilingGraph = "ProfilingGraph"; const char *const kProfilingFpNode = "ProfilingFpNode"; @@ -852,13 +853,13 @@ Status HybridModelBuilder::HandleDtString(const GeTensor &tensor, void *var_addr auto &mutable_tensor = const_cast(tensor); uint64_t *buff = reinterpret_cast(mutable_tensor.MutableData().data()); - GE_CHK_BOOL_RET_STATUS(ge::CheckInt64Uint32MulOverflow(elem_num, kBytes) == SUCCESS, FAILED, + GE_CHK_BOOL_RET_STATUS(ge::CheckInt64Uint32MulOverflow(elem_num, kBytes * kStringHeadElems) == SUCCESS, FAILED, "Shape size is invalid"); - auto offset = static_cast(elem_num * kBytes); + auto offset = static_cast(elem_num * kBytes * kStringHeadElems); auto hbm_raw_data_base_addr = static_cast(reinterpret_cast(var_addr) + offset); for (int64_t i = elem_num - 1; i >= 0; --i) { - buff[i] = hbm_raw_data_base_addr + (buff[i] - buff[0]); + buff[i * kStringHeadElems] = hbm_raw_data_base_addr + (buff[i * kStringHeadElems] - buff[0]); } } @@ -1137,11 +1138,11 @@ Status HybridModelBuilder::IndexTaskDefs(const ComputeGraphPtr &sub_graph, const GELOGD("Skip task type: %d", static_cast(task_type)); continue; } - GELOGD("op_index = %u, task_type = %d", op_index, task_type); + GELOGD("op_index = %u, task_type = %d.", op_index, task_type); auto iter = node_map.find(op_index); if (iter == node_map.end()) { - GELOGE(INTERNAL_ERROR, "Failed to get node by op_index = %u", op_index); + GELOGE(INTERNAL_ERROR, "Failed to get node by op_index = %u.", op_index); return INTERNAL_ERROR; } @@ -1150,7 +1151,7 @@ Status HybridModelBuilder::IndexTaskDefs(const ComputeGraphPtr &sub_graph, const ge_model->GetTBEKernelStore().LoadTBEKernelBinToOpDesc(node->GetOpDesc()); } - GELOGD("Task loaded for node: %s, task type = %d, op_index = %u", node->GetName().c_str(), task_type, op_index); + GELOGD("Task loaded for node: %s, task type = %d, op_index = %u.", node->GetName().c_str(), task_type, op_index); hybrid_model_.task_defs_[node].emplace_back(task_def); }