Browse Source

!1413 fix ts 4g memory question

From: @wan_xuelei
Reviewed-by: @xchu42,@wqtshg
Signed-off-by: @wqtshg
tags/v1.3.0
mindspore-ci-bot Gitee 3 years ago
parent
commit
7cc2f736e3
4 changed files with 27 additions and 3 deletions
  1. +14
    -3
      ge/graph/load/model_manager/davinci_model.cc
  2. +1
    -0
      ge/graph/load/model_manager/davinci_model.h
  3. +6
    -0
      tests/ut/ge/graph/load/davinci_model_unittest.cc
  4. +6
    -0
      third_party/fwkacllib/inc/runtime/dev.h

+ 14
- 3
ge/graph/load/model_manager/davinci_model.cc View File

@@ -3068,6 +3068,14 @@ Status DavinciModel::InitTaskInfo(domi::ModelTaskDef &model_task_def) {
return SUCCESS; return SUCCESS;
} }


Status DavinciModel::CheckCapability(rtFeatureType_t featureType, int32_t featureInfo, bool &is_support) const {
int64_t value = RT_CAPABILITY_SUPPORT;
auto rt_ret = rtGetRtCapability(featureType, featureInfo, &value);
GE_CHK_BOOL_RET_STATUS(rt_ret == RT_ERROR_NONE, FAILED, "call rtGetRtCapability failed!");
is_support = (value == RT_CAPABILITY_SUPPORT) ? true : false;
return SUCCESS;
}

Status DavinciModel::MallocKnownArgs() { Status DavinciModel::MallocKnownArgs() {
GELOGI("DavinciModel::MallocKnownArgs in"); GELOGI("DavinciModel::MallocKnownArgs in");
const auto &model_task_def = ge_model_->GetModelTaskDefPtr(); const auto &model_task_def = ge_model_->GetModelTaskDefPtr();
@@ -3087,9 +3095,12 @@ Status DavinciModel::MallocKnownArgs() {
} }
} }
rtError_t rt_ret; rtError_t rt_ret;
bool is_support = false;
GE_CHK_STATUS_RET_NOLOG(CheckCapability(FEATURE_TYPE_MEMORY, MEMORY_INFO_TS_4G_LIMITED, is_support));
auto mem_type = is_support ? RT_MEMORY_TS_4G : RT_MEMORY_HBM;
// malloc args memory // malloc args memory
if (total_args_size_ != 0) { if (total_args_size_ != 0) {
rt_ret = rtMalloc(&args_, total_args_size_, RT_MEMORY_HBM);
rt_ret = rtMalloc(&args_, total_args_size_, mem_type);
if (rt_ret != RT_ERROR_NONE) { if (rt_ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtMalloc failed, size:%u, ret: 0x%X when DavinciModel %s", REPORT_CALL_ERROR("E19999", "Call rtMalloc failed, size:%u, ret: 0x%X when DavinciModel %s",
total_args_size_, rt_ret, __FUNCTION__); total_args_size_, rt_ret, __FUNCTION__);
@@ -3099,7 +3110,7 @@ Status DavinciModel::MallocKnownArgs() {
} }
// malloc dynamic and static hybrid memory // malloc dynamic and static hybrid memory
if (total_hybrid_args_size_ != 0) { if (total_hybrid_args_size_ != 0) {
rt_ret = rtMalloc(&hybrid_addrs_, total_hybrid_args_size_, RT_MEMORY_HBM);
rt_ret = rtMalloc(&hybrid_addrs_, total_hybrid_args_size_, mem_type);
if (rt_ret != RT_ERROR_NONE) { if (rt_ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtMalloc failed, size:%u, ret: 0x%X when DavinciModel %s", REPORT_CALL_ERROR("E19999", "Call rtMalloc failed, size:%u, ret: 0x%X when DavinciModel %s",
total_hybrid_args_size_, rt_ret, __FUNCTION__); total_hybrid_args_size_, rt_ret, __FUNCTION__);
@@ -3110,7 +3121,7 @@ Status DavinciModel::MallocKnownArgs() {
// malloc fixed addr memory, eg: rts op // malloc fixed addr memory, eg: rts op
if (total_fixed_addr_size_ != 0) { if (total_fixed_addr_size_ != 0) {
GELOGI("Begin to allocate fixed addr."); GELOGI("Begin to allocate fixed addr.");
rt_ret = rtMalloc(&fixed_addrs_, total_fixed_addr_size_, RT_MEMORY_HBM);
rt_ret = rtMalloc(&fixed_addrs_, total_fixed_addr_size_, mem_type);
if (rt_ret != RT_ERROR_NONE) { if (rt_ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtMalloc failed, size:%u, ret: 0x%X when DavinciModel %s", REPORT_CALL_ERROR("E19999", "Call rtMalloc failed, size:%u, ret: 0x%X when DavinciModel %s",
total_hybrid_args_size_, rt_ret, __FUNCTION__); total_hybrid_args_size_, rt_ret, __FUNCTION__);


+ 1
- 0
ge/graph/load/model_manager/davinci_model.h View File

@@ -531,6 +531,7 @@ class DavinciModel {
void SetKnownNode(bool known_node) { known_node_ = known_node; } void SetKnownNode(bool known_node) { known_node_ = known_node; }
bool IsKnownNode() { return known_node_; } bool IsKnownNode() { return known_node_; }
Status MallocKnownArgs(); Status MallocKnownArgs();
Status CheckCapability(rtFeatureType_t featureType, int32_t featureInfo, bool &is_support) const;
Status UpdateKnownNodeArgs(const vector<void *> &inputs, const vector<void *> &outputs); Status UpdateKnownNodeArgs(const vector<void *> &inputs, const vector<void *> &outputs);
Status CreateKnownZeroCopyMap(const vector<void *> &inputs, const vector<void *> &outputs); Status CreateKnownZeroCopyMap(const vector<void *> &inputs, const vector<void *> &outputs);
Status UpdateKnownZeroCopyAddr(vector<void *> &total_io_addrs, bool update_args = true); Status UpdateKnownZeroCopyAddr(vector<void *> &total_io_addrs, bool update_args = true);


+ 6
- 0
tests/ut/ge/graph/load/davinci_model_unittest.cc View File

@@ -146,6 +146,12 @@ TEST_F(UtestDavinciModel, init_success) {
ProfilingManager::Instance().is_load_profiling_ = false; ProfilingManager::Instance().is_load_profiling_ = false;
} }


TEST_F(UtestDavinciModel, CheckCapability) {
DavinciModel model(0, nullptr);
bool is_support = false;
(void)model.CheckCapability(FEATURE_TYPE_MEMORY, MEMORY_INFO_TS_4G_LIMITED, is_support);
}

TEST_F(UtestDavinciModel, init_data_op) { TEST_F(UtestDavinciModel, init_data_op) {
DavinciModel model(0, nullptr); DavinciModel model(0, nullptr);
model.ge_model_ = make_shared<GeModel>(); model.ge_model_ = make_shared<GeModel>();


+ 6
- 0
third_party/fwkacllib/inc/runtime/dev.h View File

@@ -59,6 +59,7 @@ typedef enum tagRtAicpuDeployType {


typedef enum tagRtFeatureType { typedef enum tagRtFeatureType {
FEATURE_TYPE_MEMCPY = 0, FEATURE_TYPE_MEMCPY = 0,
FEATURE_TYPE_MEMORY = 1,
FEATURE_TYPE_RSV FEATURE_TYPE_RSV
} rtFeatureType_t; } rtFeatureType_t;


@@ -67,6 +68,11 @@ typedef enum tagMemcpyInfo {
MEMCPY_INFO_RSV MEMCPY_INFO_RSV
} rtMemcpyInfo_t; } rtMemcpyInfo_t;


typedef enum tagMemoryInfo {
MEMORY_INFO_TS_4G_LIMITED = 0,
MEMORY_INFO_RSV
} rtMemoryInfo_t;

/** /**
* @ingroup dvrt_dev * @ingroup dvrt_dev
* @brief get total device number. * @brief get total device number.


Loading…
Cancel
Save