|
|
@ -927,7 +927,7 @@ Status ModelManager::GetInputOutputDescInfo(const uint32_t model_id, vector<Inpu
|
|
|
|
Status ModelManager::GetDynamicBatchInfo(const uint32_t model_id, std::vector<std::vector<int64_t>> &batch_info,
|
|
|
|
Status ModelManager::GetDynamicBatchInfo(const uint32_t model_id, std::vector<std::vector<int64_t>> &batch_info,
|
|
|
|
int32_t &dynamic_type) {
|
|
|
|
int32_t &dynamic_type) {
|
|
|
|
std::shared_ptr<DavinciModel> davinci_model = GetModel(model_id);
|
|
|
|
std::shared_ptr<DavinciModel> davinci_model = GetModel(model_id);
|
|
|
|
GE_CHK_BOOL_RET_STATUS(davinci_model != nullptr, GE_EXEC_MODEL_ID_INVALID,
|
|
|
|
GE_CHK_BOOL_RET_STATUS(davinci_model != nullptr, ACL_ERROR_GE_EXEC_MODEL_ID_INVALID,
|
|
|
|
"GetDynamicBatchInfo failed, Invalid model id %u!", model_id);
|
|
|
|
"GetDynamicBatchInfo failed, Invalid model id %u!", model_id);
|
|
|
|
|
|
|
|
|
|
|
|
return davinci_model->GetDynamicBatchInfo(batch_info, dynamic_type);
|
|
|
|
return davinci_model->GetDynamicBatchInfo(batch_info, dynamic_type);
|
|
|
@ -942,8 +942,8 @@ Status ModelManager::GetDynamicBatchInfo(const uint32_t model_id, std::vector<st
|
|
|
|
///
|
|
|
|
///
|
|
|
|
Status ModelManager::GetCombinedDynamicDims(const uint32_t model_id, vector<vector<int64_t>> &batch_info) {
|
|
|
|
Status ModelManager::GetCombinedDynamicDims(const uint32_t model_id, vector<vector<int64_t>> &batch_info) {
|
|
|
|
std::shared_ptr<DavinciModel> davinci_model = GetModel(model_id);
|
|
|
|
std::shared_ptr<DavinciModel> davinci_model = GetModel(model_id);
|
|
|
|
GE_CHK_BOOL_RET_STATUS(davinci_model != nullptr, PARAM_INVALID, "GetCombinedDynamicDims Failed, Invalid Model ID %u!",
|
|
|
|
GE_CHK_BOOL_RET_STATUS(davinci_model != nullptr, ACL_ERROR_GE_EXEC_MODEL_ID_INVALID,
|
|
|
|
model_id);
|
|
|
|
"GetCombinedDynamicDims Failed, Invalid Model ID %u!", model_id);
|
|
|
|
|
|
|
|
|
|
|
|
davinci_model->GetCombinedDynamicDims(batch_info);
|
|
|
|
davinci_model->GetCombinedDynamicDims(batch_info);
|
|
|
|
return SUCCESS;
|
|
|
|
return SUCCESS;
|
|
|
@ -959,7 +959,7 @@ Status ModelManager::GetCombinedDynamicDims(const uint32_t model_id, vector<vect
|
|
|
|
Status ModelManager::GetUserDesignateShapeOrder(const uint32_t model_id,
|
|
|
|
Status ModelManager::GetUserDesignateShapeOrder(const uint32_t model_id,
|
|
|
|
std::vector<std::string> &user_input_shape_order) {
|
|
|
|
std::vector<std::string> &user_input_shape_order) {
|
|
|
|
auto davinci_model = GetModel(model_id);
|
|
|
|
auto davinci_model = GetModel(model_id);
|
|
|
|
GE_CHK_BOOL_RET_STATUS(davinci_model != nullptr, PARAM_INVALID,
|
|
|
|
GE_CHK_BOOL_RET_STATUS(davinci_model != nullptr, ACL_ERROR_GE_EXEC_MODEL_ID_INVALID,
|
|
|
|
"GetUserDesignateShapeOrder Failed, Invalid Model ID %u!", model_id)
|
|
|
|
"GetUserDesignateShapeOrder Failed, Invalid Model ID %u!", model_id)
|
|
|
|
davinci_model->GetUserDesignateShapeOrder(user_input_shape_order);
|
|
|
|
davinci_model->GetUserDesignateShapeOrder(user_input_shape_order);
|
|
|
|
return SUCCESS;
|
|
|
|
return SUCCESS;
|
|
|
@ -1000,7 +1000,8 @@ Status ModelManager::GetInputOutputDescInfoForZeroCopy(const uint32_t model_id,
|
|
|
|
///
|
|
|
|
///
|
|
|
|
Status ModelManager::GetAIPPInfo(const uint32_t model_id, uint32_t index, AippConfigInfo &aipp_info) {
|
|
|
|
Status ModelManager::GetAIPPInfo(const uint32_t model_id, uint32_t index, AippConfigInfo &aipp_info) {
|
|
|
|
std::shared_ptr<DavinciModel> davinci_model = GetModel(model_id);
|
|
|
|
std::shared_ptr<DavinciModel> davinci_model = GetModel(model_id);
|
|
|
|
GE_CHK_BOOL_RET_STATUS(davinci_model != nullptr, PARAM_INVALID, "GetAIPPInfo failed, invalid model_id is %u.",
|
|
|
|
GE_CHK_BOOL_RET_STATUS(davinci_model != nullptr, ACL_ERROR_GE_EXEC_MODEL_ID_INVALID,
|
|
|
|
|
|
|
|
"GetAIPPInfo failed, invalid model_id is %u.",
|
|
|
|
model_id);
|
|
|
|
model_id);
|
|
|
|
|
|
|
|
|
|
|
|
return davinci_model->GetAIPPInfo(index, aipp_info);
|
|
|
|
return davinci_model->GetAIPPInfo(index, aipp_info);
|
|
|
@ -1008,7 +1009,8 @@ Status ModelManager::GetAIPPInfo(const uint32_t model_id, uint32_t index, AippCo
|
|
|
|
|
|
|
|
|
|
|
|
Status ModelManager::GetAippType(uint32_t model_id, uint32_t index, InputAippType &type, size_t &aipp_index) {
|
|
|
|
Status ModelManager::GetAippType(uint32_t model_id, uint32_t index, InputAippType &type, size_t &aipp_index) {
|
|
|
|
std::shared_ptr<DavinciModel> davinci_model = GetModel(model_id);
|
|
|
|
std::shared_ptr<DavinciModel> davinci_model = GetModel(model_id);
|
|
|
|
GE_CHK_BOOL_RET_STATUS(davinci_model != nullptr, PARAM_INVALID, "GetAIPPInfo failed, invalid model_id is %u.",
|
|
|
|
GE_CHK_BOOL_RET_STATUS(davinci_model != nullptr, ACL_ERROR_GE_EXEC_MODEL_ID_INVALID,
|
|
|
|
|
|
|
|
"GetAIPPInfo failed, invalid model_id is %u.",
|
|
|
|
model_id);
|
|
|
|
model_id);
|
|
|
|
|
|
|
|
|
|
|
|
return davinci_model->GetAippType(index, type, aipp_index);
|
|
|
|
return davinci_model->GetAippType(index, type, aipp_index);
|
|
|
@ -1035,7 +1037,8 @@ Status ModelManager::GenSessionId(uint64_t &session_id) {
|
|
|
|
|
|
|
|
|
|
|
|
Status ModelManager::LoadModelOffline(uint32_t &model_id, const ModelData &model, shared_ptr<ModelListener> listener,
|
|
|
|
Status ModelManager::LoadModelOffline(uint32_t &model_id, const ModelData &model, shared_ptr<ModelListener> listener,
|
|
|
|
void *dev_ptr, size_t mem_size, void *weight_ptr, size_t weight_size) {
|
|
|
|
void *dev_ptr, size_t mem_size, void *weight_ptr, size_t weight_size) {
|
|
|
|
GE_CHK_BOOL_RET_STATUS(model.key.empty() || access(model.key.c_str(), F_OK) == 0, GE_EXEC_MODEL_KEY_PATH_INVALID,
|
|
|
|
GE_CHK_BOOL_RET_STATUS(model.key.empty() || access(model.key.c_str(), F_OK) == 0,
|
|
|
|
|
|
|
|
ACL_ERROR_GE_EXEC_MODEL_KEY_PATH_INVALID,
|
|
|
|
"input key file path %s is invalid, %s", model.key.c_str(), strerror(errno));
|
|
|
|
"input key file path %s is invalid, %s", model.key.c_str(), strerror(errno));
|
|
|
|
GenModelId(&model_id);
|
|
|
|
GenModelId(&model_id);
|
|
|
|
|
|
|
|
|
|
|
@ -1054,8 +1057,8 @@ Status ModelManager::LoadModelOffline(uint32_t &model_id, const ModelData &model
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
davinci_model = std::make_shared<DavinciModel>(model.priority, listener);
|
|
|
|
davinci_model = std::make_shared<DavinciModel>(model.priority, listener);
|
|
|
|
} catch (std::bad_alloc &) {
|
|
|
|
} catch (std::bad_alloc &) {
|
|
|
|
GELOGE(MEMALLOC_FAILED, "Make shared failed");
|
|
|
|
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "Make shared failed");
|
|
|
|
return MEMALLOC_FAILED;
|
|
|
|
return ACL_ERROR_GE_MEMORY_ALLOCATION;
|
|
|
|
} catch (...) {
|
|
|
|
} catch (...) {
|
|
|
|
GELOGE(INTERNAL_ERROR, "Make shared failed since other exception raise");
|
|
|
|
GELOGE(INTERNAL_ERROR, "Make shared failed since other exception raise");
|
|
|
|
return INTERNAL_ERROR;
|
|
|
|
return INTERNAL_ERROR;
|
|
|
@ -1094,7 +1097,6 @@ Status ModelManager::LoadModelOffline(uint32_t &model_id, const ModelData &model
|
|
|
|
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(ret != SUCCESS, break, "DavinciInit failed.");
|
|
|
|
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(ret != SUCCESS, break, "DavinciInit failed.");
|
|
|
|
|
|
|
|
|
|
|
|
InsertModel(model_id, davinci_model);
|
|
|
|
InsertModel(model_id, davinci_model);
|
|
|
|
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(davinci_model == nullptr, ret = PARAM_INVALID; break, "Insert model failed");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GELOGI("Parse model %u success.", model_id);
|
|
|
|
GELOGI("Parse model %u success.", model_id);
|
|
|
|
|
|
|
|
|
|
|
@ -1122,7 +1124,7 @@ Status ModelManager::LoadModelWithQ(uint32_t &model_id, const ModelData &model_d
|
|
|
|
const std::vector<uint32_t> &input_queue_ids,
|
|
|
|
const std::vector<uint32_t> &input_queue_ids,
|
|
|
|
const std::vector<uint32_t> &output_queue_ids) {
|
|
|
|
const std::vector<uint32_t> &output_queue_ids) {
|
|
|
|
GE_CHK_BOOL_RET_STATUS(model_data.key.empty() || access(model_data.key.c_str(), F_OK) == 0,
|
|
|
|
GE_CHK_BOOL_RET_STATUS(model_data.key.empty() || access(model_data.key.c_str(), F_OK) == 0,
|
|
|
|
GE_EXEC_MODEL_KEY_PATH_INVALID, "input key file path %s is not valid, %s",
|
|
|
|
ACL_ERROR_GE_EXEC_MODEL_KEY_PATH_INVALID, "input key file path %s is not valid, %s",
|
|
|
|
model_data.key.c_str(), strerror(errno));
|
|
|
|
model_data.key.c_str(), strerror(errno));
|
|
|
|
|
|
|
|
|
|
|
|
ModelHelper model_helper;
|
|
|
|
ModelHelper model_helper;
|
|
|
@ -1134,8 +1136,8 @@ Status ModelManager::LoadModelWithQ(uint32_t &model_id, const ModelData &model_d
|
|
|
|
|
|
|
|
|
|
|
|
shared_ptr<DavinciModel> davinci_model = MakeShared<DavinciModel>(model_data.priority, nullptr);
|
|
|
|
shared_ptr<DavinciModel> davinci_model = MakeShared<DavinciModel>(model_data.priority, nullptr);
|
|
|
|
if (davinci_model == nullptr) {
|
|
|
|
if (davinci_model == nullptr) {
|
|
|
|
GELOGE(MEMALLOC_FAILED, "create model failed.");
|
|
|
|
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "create model failed.");
|
|
|
|
return MEMALLOC_FAILED;
|
|
|
|
return ACL_ERROR_GE_MEMORY_ALLOCATION;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ret = davinci_model->Assign(model_helper.GetGeModel());
|
|
|
|
ret = davinci_model->Assign(model_helper.GetGeModel());
|
|
|
@ -1390,13 +1392,13 @@ Status ModelManager::GetModelMemAndWeightSize(const ModelData &model, size_t &me
|
|
|
|
|
|
|
|
|
|
|
|
auto partition_table = reinterpret_cast<ModelPartitionTable *>(model_data);
|
|
|
|
auto partition_table = reinterpret_cast<ModelPartitionTable *>(model_data);
|
|
|
|
if (partition_table->num == 1) {
|
|
|
|
if (partition_table->num == 1) {
|
|
|
|
GELOGE(GE_EXEC_MODEL_PARTITION_NUM_INVALID, "om model is error,please use executable om model");
|
|
|
|
GELOGE(ACL_ERROR_GE_EXEC_MODEL_PARTITION_NUM_INVALID, "om model is error,please use executable om model");
|
|
|
|
return GE_EXEC_MODEL_PARTITION_NUM_INVALID;
|
|
|
|
return ACL_ERROR_GE_EXEC_MODEL_PARTITION_NUM_INVALID;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ModelPartition task_partition;
|
|
|
|
ModelPartition task_partition;
|
|
|
|
if (om_file_helper.GetModelPartition(ModelPartitionType::TASK_INFO, task_partition) != SUCCESS) {
|
|
|
|
if (om_file_helper.GetModelPartition(ModelPartitionType::TASK_INFO, task_partition) != SUCCESS) {
|
|
|
|
GELOGE(GE_EXEC_LOAD_TASK_PARTITION_FAILED, "get task model partition failed.");
|
|
|
|
GELOGE(ACL_ERROR_GE_EXEC_LOAD_TASK_PARTITION_FAILED, "get task model partition failed.");
|
|
|
|
return GE_EXEC_LOAD_TASK_PARTITION_FAILED;
|
|
|
|
return ACL_ERROR_GE_EXEC_LOAD_TASK_PARTITION_FAILED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<domi::ModelTaskDef> model_task_def = MakeShared<domi::ModelTaskDef>();
|
|
|
|
std::shared_ptr<domi::ModelTaskDef> model_task_def = MakeShared<domi::ModelTaskDef>();
|
|
|
@ -1405,14 +1407,14 @@ Status ModelManager::GetModelMemAndWeightSize(const ModelData &model, size_t &me
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (task_partition.size != 0) {
|
|
|
|
if (task_partition.size != 0) {
|
|
|
|
if (!ReadProtoFromArray(task_partition.data, static_cast<int>(task_partition.size), model_task_def.get())) {
|
|
|
|
if (!ReadProtoFromArray(task_partition.data, static_cast<int>(task_partition.size), model_task_def.get())) {
|
|
|
|
GELOGE(GE_EXEC_LOAD_TASK_PARTITION_FAILED, "ReadProtoFromArray failed.");
|
|
|
|
GELOGE(ACL_ERROR_GE_EXEC_LOAD_TASK_PARTITION_FAILED, "ReadProtoFromArray failed.");
|
|
|
|
return GE_EXEC_LOAD_TASK_PARTITION_FAILED;
|
|
|
|
return ACL_ERROR_GE_EXEC_LOAD_TASK_PARTITION_FAILED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ModelPartition partition_weight;
|
|
|
|
ModelPartition partition_weight;
|
|
|
|
ret = om_file_helper.GetModelPartition(ModelPartitionType::WEIGHTS_DATA, partition_weight);
|
|
|
|
ret = om_file_helper.GetModelPartition(ModelPartitionType::WEIGHTS_DATA, partition_weight);
|
|
|
|
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(ret != SUCCESS, return GE_EXEC_LOAD_WEIGHT_PARTITION_FAILED,
|
|
|
|
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(ret != SUCCESS, return ACL_ERROR_GE_EXEC_LOAD_WEIGHT_PARTITION_FAILED,
|
|
|
|
"Get weight partition failed. ret = %u", ret);
|
|
|
|
"Get weight partition failed. ret = %u", ret);
|
|
|
|
|
|
|
|
|
|
|
|
mem_size = model_task_def->memory_size();
|
|
|
|
mem_size = model_task_def->memory_size();
|
|
|
@ -1431,7 +1433,8 @@ void ModelManager::GenModelId(uint32_t *id) {
|
|
|
|
|
|
|
|
|
|
|
|
Status ModelManager::GetOrigInputInfo(uint32_t model_id, uint32_t index, OriginInputInfo &orig_input_info) {
|
|
|
|
Status ModelManager::GetOrigInputInfo(uint32_t model_id, uint32_t index, OriginInputInfo &orig_input_info) {
|
|
|
|
std::shared_ptr<DavinciModel> davinci_model = GetModel(model_id);
|
|
|
|
std::shared_ptr<DavinciModel> davinci_model = GetModel(model_id);
|
|
|
|
GE_CHK_BOOL_RET_STATUS(davinci_model != nullptr, PARAM_INVALID, "GetOrigInputInfo failed, invalid model_id is %u.",
|
|
|
|
GE_CHK_BOOL_RET_STATUS(davinci_model != nullptr, ACL_ERROR_GE_EXEC_MODEL_ID_INVALID,
|
|
|
|
|
|
|
|
"GetOrigInputInfo failed, invalid model_id is %u.",
|
|
|
|
model_id);
|
|
|
|
model_id);
|
|
|
|
|
|
|
|
|
|
|
|
return davinci_model->GetOrigInputInfo(index, orig_input_info);
|
|
|
|
return davinci_model->GetOrigInputInfo(index, orig_input_info);
|
|
|
@ -1441,7 +1444,7 @@ Status ModelManager::GetAllAippInputOutputDims(uint32_t model_id, uint32_t index
|
|
|
|
std::vector<InputOutputDims> &input_dims,
|
|
|
|
std::vector<InputOutputDims> &input_dims,
|
|
|
|
std::vector<InputOutputDims> &output_dims) {
|
|
|
|
std::vector<InputOutputDims> &output_dims) {
|
|
|
|
std::shared_ptr<DavinciModel> davinci_model = GetModel(model_id);
|
|
|
|
std::shared_ptr<DavinciModel> davinci_model = GetModel(model_id);
|
|
|
|
GE_CHK_BOOL_RET_STATUS(davinci_model != nullptr, PARAM_INVALID,
|
|
|
|
GE_CHK_BOOL_RET_STATUS(davinci_model != nullptr, ACL_ERROR_GE_EXEC_MODEL_ID_INVALID,
|
|
|
|
"GetAllAippInputOutputDims failed, invalid model_id is %u.", model_id);
|
|
|
|
"GetAllAippInputOutputDims failed, invalid model_id is %u.", model_id);
|
|
|
|
|
|
|
|
|
|
|
|
return davinci_model->GetAllAippInputOutputDims(index, input_dims, output_dims);
|
|
|
|
return davinci_model->GetAllAippInputOutputDims(index, input_dims, output_dims);
|
|
|
|