Browse Source

!1197 fixed issue of dt_string

From: @li-lei0106
Reviewed-by: @xchu42,@wqtshg
Signed-off-by: @ji_chen
tags/v1.2.0
mindspore-ci-bot Gitee 3 years ago
parent
commit
d4b9601f52
2 changed files with 17 additions and 8 deletions
  1. +10
    -2
      ge/ge_runtime/runtime_model.cc
  2. +7
    -6
      ge/hybrid/model/hybrid_model_builder.cc

+ 10
- 2
ge/ge_runtime/runtime_model.cc View File

@@ -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<DavinciModel> &davinci_model
return false;
}
uint64_t *buff = reinterpret_cast<uint64_t *>(const_cast<char *>(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<uintptr_t>(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]);
}
}



+ 7
- 6
ge/hybrid/model/hybrid_model_builder.cc View File

@@ -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<GeTensor &>(tensor);
uint64_t *buff = reinterpret_cast<uint64_t *>(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<uint64_t>(elem_num * kBytes);
auto offset = static_cast<uint64_t>(elem_num * kBytes * kStringHeadElems);
auto hbm_raw_data_base_addr =
static_cast<uint64_t>(reinterpret_cast<uintptr_t>(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<int>(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);
}



Loading…
Cancel
Save