From: @shenwei41 Reviewed-by: @lilongfei15,@xsmq Signed-off-by: @xsmqtags/v1.2.0
@@ -1,8 +1,8 @@ | |||||
[submodule "parser"] | [submodule "parser"] | ||||
path = parser | path = parser | ||||
url = https://gitee.com/ascend/parser.git | url = https://gitee.com/ascend/parser.git | ||||
branch = development | |||||
branch = master | |||||
[submodule "metadef"] | [submodule "metadef"] | ||||
path = metadef | path = metadef | ||||
url = https://gitee.com/ascend/metadef.git | url = https://gitee.com/ascend/metadef.git | ||||
branch = development | |||||
branch = master |
@@ -11,13 +11,13 @@ if ((${CMAKE_INSTALL_PREFIX} STREQUAL /usr/local) OR | |||||
endif() | endif() | ||||
if (GE_PB_PKG) | if (GE_PB_PKG) | ||||
set(REQ_URL "${GE_PB_PKG}/libs/ge_gtest/release-1.8.0.tar.gz") | |||||
set(REQ_URL "${GE_PB_PKG}/libs/ge_gtest/release-1.8.1.tar.gz") | |||||
set(MD5 "") | set(MD5 "") | ||||
elseif (ENABLE_GITEE) | elseif (ENABLE_GITEE) | ||||
set(REQ_URL "https://gitee.com/mirrors/googletest/repository/archive/release-1.8.0.tar.gz") | |||||
set(REQ_URL "https://gitee.com/mirrors/googletest/repository/archive/release-1.8.1.tar.gz") | |||||
set(MD5 "") | set(MD5 "") | ||||
else() | else() | ||||
set(REQ_URL "https://github.com/google/googletest/archive/release-1.8.0.tar.gz") | |||||
set(REQ_URL "https://github.com/google/googletest/archive/release-1.8.1.tar.gz") | |||||
set(MD5 "") | set(MD5 "") | ||||
endif () | endif () | ||||
@@ -1,3 +1,7 @@ | |||||
if (HAVE_PROTOBUF_STATIC) | |||||
return() | |||||
endif() | |||||
include(ExternalProject) | include(ExternalProject) | ||||
include(GNUInstallDirs) | include(GNUInstallDirs) | ||||
#set(CMAKE_INSTALL_PREFIX ${GE_CODE_DIR}/output) | #set(CMAKE_INSTALL_PREFIX ${GE_CODE_DIR}/output) | ||||
@@ -58,3 +62,5 @@ include_directories(${PROTOBUF_STATIC_PKG_DIR}/include) | |||||
endif () | endif () | ||||
add_dependencies(ascend_protobuf_static protobuf_static_build) | add_dependencies(ascend_protobuf_static protobuf_static_build) | ||||
set(HAVE_PROTOBUF_STATIC TRUE) |
@@ -170,7 +170,7 @@ target_include_directories(ge_common_static PRIVATE | |||||
target_link_libraries(ge_common_static PRIVATE | target_link_libraries(ge_common_static PRIVATE | ||||
$<BUILD_INTERFACE:intf_pub> | $<BUILD_INTERFACE:intf_pub> | ||||
ascend_protobuf | |||||
ascend_protobuf_static | |||||
json | json | ||||
c_sec | c_sec | ||||
$<$<NOT:$<STREQUAL:${TARGET_SYSTEM_NAME},Android>>:-lrt> | $<$<NOT:$<STREQUAL:${TARGET_SYSTEM_NAME},Android>>:-lrt> | ||||
@@ -78,19 +78,6 @@ Status ModelHelper::SaveModelPartition(std::shared_ptr<OmFileSaveHelper> &om_fil | |||||
Status ModelHelper::SaveSizeToModelDef(const GeModelPtr &ge_model) { | Status ModelHelper::SaveSizeToModelDef(const GeModelPtr &ge_model) { | ||||
vector<int64_t> om_info; | vector<int64_t> om_info; | ||||
ModelPtr model_tmp = ge::MakeShared<ge::Model>(ge_model->GetName(), ge_model->GetPlatformVersion()); | |||||
if (model_tmp == nullptr) { | |||||
GELOGE(FAILED, "Create Model %s Ptr failed", ge_model->GetName().c_str()); | |||||
return FAILED; | |||||
} | |||||
model_tmp->SetGraph(ge_model->GetGraph()); | |||||
model_tmp->SetVersion(ge_model->GetVersion()); | |||||
model_tmp->SetAttr(ge_model->MutableAttrMap()); | |||||
ge::Buffer model_buffer; | |||||
(void)model_tmp->Save(model_buffer); | |||||
GELOGD("SaveSizeToModelDef modeldef_size is %zu", model_buffer.GetSize()); | |||||
om_info.push_back(model_buffer.GetSize()); | |||||
auto ge_model_weight = ge_model->GetWeight(); | auto ge_model_weight = ge_model->GetWeight(); | ||||
GELOGD("SaveSizeToModelDef weight_data_size is %zu, %p", ge_model_weight.GetSize(), ge_model_weight.GetData()); | GELOGD("SaveSizeToModelDef weight_data_size is %zu, %p", ge_model_weight.GetSize(), ge_model_weight.GetData()); | ||||
om_info.push_back(ge_model_weight.GetSize()); | om_info.push_back(ge_model_weight.GetSize()); | ||||
@@ -202,7 +202,7 @@ target_include_directories(ge_executor SYSTEM PRIVATE | |||||
target_link_libraries(ge_executor PRIVATE | target_link_libraries(ge_executor PRIVATE | ||||
$<BUILD_INTERFACE:intf_pub> | $<BUILD_INTERFACE:intf_pub> | ||||
json | json | ||||
ascend_protobuf | |||||
ascend_protobuf_static | |||||
c_sec | c_sec | ||||
$<$<NOT:$<STREQUAL:${TARGET_SYSTEM_NAME},Android>>:-lrt> | $<$<NOT:$<STREQUAL:${TARGET_SYSTEM_NAME},Android>>:-lrt> | ||||
-ldl | -ldl | ||||
@@ -627,12 +627,11 @@ namespace { | |||||
bool is_dynamic = false; | bool is_dynamic = false; | ||||
for (const auto &node : graph->GetDirectNode()) { | for (const auto &node : graph->GetDirectNode()) { | ||||
GE_CHECK_NOTNULL(node); | GE_CHECK_NOTNULL(node); | ||||
if (node->GetType() == DATA || node->GetType() == CONSTANT || node->GetType() == CONSTANTOP || | |||||
node->GetType() == NETOUTPUT) { | |||||
continue; | |||||
} | |||||
auto op_desc = node->GetOpDesc(); | auto op_desc = node->GetOpDesc(); | ||||
GE_CHECK_NOTNULL(op_desc); | GE_CHECK_NOTNULL(op_desc); | ||||
if (op_desc->GetOpEngineName() != kAIcoreEngine) { | |||||
continue; | |||||
} | |||||
if (AttrUtils::HasAttr(op_desc, kAttrSupportDynamicShape)) { | if (AttrUtils::HasAttr(op_desc, kAttrSupportDynamicShape)) { | ||||
is_dynamic = true; | is_dynamic = true; | ||||
(void) AttrUtils::GetBool(op_desc, kAttrSupportDynamicShape, support_dynamic); | (void) AttrUtils::GetBool(op_desc, kAttrSupportDynamicShape, support_dynamic); | ||||
@@ -147,7 +147,6 @@ DavinciModel::DavinciModel(int32_t priority, const std::shared_ptr<ModelListener | |||||
runtime_model_id_(0), | runtime_model_id_(0), | ||||
version_(0), | version_(0), | ||||
ge_model_(nullptr), | ge_model_(nullptr), | ||||
thread_id_(), | |||||
listener_(listener), | listener_(listener), | ||||
run_flg_(false), | run_flg_(false), | ||||
priority_(priority), | priority_(priority), | ||||
@@ -168,6 +167,8 @@ DavinciModel::DavinciModel(int32_t priority, const std::shared_ptr<ModelListener | |||||
DavinciModel::~DavinciModel() { | DavinciModel::~DavinciModel() { | ||||
try { | try { | ||||
GE_CHK_STATUS(ModelRunStop()); | |||||
Status ret = data_dumper_.UnloadDumpInfo(); | Status ret = data_dumper_.UnloadDumpInfo(); | ||||
if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
GELOGW("UnloadDumpInfo failed, ret: %u.", ret); | GELOGW("UnloadDumpInfo failed, ret: %u.", ret); | ||||
@@ -175,8 +176,6 @@ DavinciModel::~DavinciModel() { | |||||
ClearTaskAddrs(); | ClearTaskAddrs(); | ||||
GE_CHK_STATUS(ModelRunStop()); | |||||
op_list_.clear(); | op_list_.clear(); | ||||
tensor_name_to_fixed_addr_size_.clear(); | tensor_name_to_fixed_addr_size_.clear(); | ||||
tensor_name_to_peer_output_index_.clear(); | tensor_name_to_peer_output_index_.clear(); | ||||
@@ -730,9 +729,9 @@ Status DavinciModel::Init(void *dev_ptr, size_t mem_size, void *weight_ptr, size | |||||
SetProfileTime(MODEL_LOAD_END); | SetProfileTime(MODEL_LOAD_END); | ||||
// collect profiling for ge | // collect profiling for ge | ||||
GE_CHK_STATUS_RET(InitModelProfile(), "Init model profile failed"); | |||||
auto &profiling_manager = ProfilingManager::Instance(); | auto &profiling_manager = ProfilingManager::Instance(); | ||||
if (profiling_manager.ProfilingModelLoadOn()) { | if (profiling_manager.ProfilingModelLoadOn()) { | ||||
GE_CHK_STATUS_RET(InitModelProfile(), "Init model profile failed"); | |||||
Status p_ret = ReportProfilingData(); | Status p_ret = ReportProfilingData(); | ||||
if (p_ret != SUCCESS) { | if (p_ret != SUCCESS) { | ||||
GELOGE(p_ret, "Report profiling data failed."); | GELOGE(p_ret, "Report profiling data failed."); | ||||
@@ -740,7 +739,7 @@ Status DavinciModel::Init(void *dev_ptr, size_t mem_size, void *weight_ptr, size | |||||
} | } | ||||
} | } | ||||
Shrink(); | |||||
CREATE_STD_THREAD(shrink_id_, &DavinciModel::Shrink, this); | |||||
return SUCCESS; | return SUCCESS; | ||||
} | } | ||||
@@ -1096,6 +1095,7 @@ Status DavinciModel::InitNetOutput(const ComputeGraphPtr &graph, const NodePtr & | |||||
GELOGI("Init NetOutput node: %s.", op_desc->GetName().c_str()); | GELOGI("Init NetOutput node: %s.", op_desc->GetName().c_str()); | ||||
output_op_list.push_back(op_desc); | output_op_list.push_back(op_desc); | ||||
has_output_node_ = true; | |||||
if (known_node_) { | if (known_node_) { | ||||
return SUCCESS; | return SUCCESS; | ||||
} | } | ||||
@@ -2423,9 +2423,8 @@ void DavinciModel::SetProfileTime(ModelProcStage stage, int64_t endTime) { | |||||
/// @author | /// @author | ||||
/// | /// | ||||
Status DavinciModel::CopyOutputData(uint32_t data_id, OutputData &output_data, rtMemcpyKind_t kind) { | Status DavinciModel::CopyOutputData(uint32_t data_id, OutputData &output_data, rtMemcpyKind_t kind) { | ||||
if (output_addrs_list_.empty()) { | |||||
Status ret = SyncVarData(); | |||||
return ret; | |||||
if (!has_output_node_) { | |||||
return SyncVarData(); | |||||
} | } | ||||
output_data.index = data_id; | output_data.index = data_id; | ||||
@@ -2583,7 +2582,7 @@ Status DavinciModel::ReturnResult(uint32_t data_id, const bool rslt_flg, const b | |||||
return INTERNAL_ERROR; | return INTERNAL_ERROR; | ||||
} | } | ||||
if (output_addrs_list_.empty()) { | |||||
if (!has_output_node_) { | |||||
GELOGW("Output tensor list is empty, model id: %u", model_id_); | GELOGW("Output tensor list is empty, model id: %u", model_id_); | ||||
GE_CHK_STATUS(listener_->OnComputeDone(model_id_, data_id, INTERNAL_ERROR, outputs), "OnComputeDone failed."); | GE_CHK_STATUS(listener_->OnComputeDone(model_id_, data_id, INTERNAL_ERROR, outputs), "OnComputeDone failed."); | ||||
return INTERNAL_ERROR; | return INTERNAL_ERROR; | ||||
@@ -2736,10 +2735,10 @@ void *DavinciModel::Run(DavinciModel *model) { | |||||
model->SetProfileTime(MODEL_AFTER_PROC_START)); | model->SetProfileTime(MODEL_AFTER_PROC_START)); | ||||
GE_TIMESTAMP_START(ReturnResult3); | GE_TIMESTAMP_START(ReturnResult3); | ||||
// copy output data from device to host | // copy output data from device to host | ||||
GE_IF_BOOL_EXEC(!model->output_addrs_list_.empty(), | |||||
(void)model->ReturnResult(current_data.index, rslt_flg, false, data_wrapper->GetOutput())) | |||||
GE_IF_BOOL_EXEC(model->has_output_node_, | |||||
(void)model->ReturnResult(current_data.index, rslt_flg, false, data_wrapper->GetOutput())); | |||||
// copy output data from device to host for variable graph | // copy output data from device to host for variable graph | ||||
GE_IF_BOOL_EXEC(model->output_addrs_list_.empty(), (void)model->ReturnNoOutput(current_data.index)); | |||||
GE_IF_BOOL_EXEC(!model->has_output_node_, (void)model->ReturnNoOutput(current_data.index)); | |||||
GE_IF_BOOL_EXEC(model->is_first_execute_, | GE_IF_BOOL_EXEC(model->is_first_execute_, | ||||
GE_TIMESTAMP_EVENT_END(ReturnResult3, "GraphExcute::CopyDataFromDeviceToHost")); | GE_TIMESTAMP_EVENT_END(ReturnResult3, "GraphExcute::CopyDataFromDeviceToHost")); | ||||
GE_IF_BOOL_EXEC(ProfilingManager::Instance().ProfilingModelExecuteOn(), | GE_IF_BOOL_EXEC(ProfilingManager::Instance().ProfilingModelExecuteOn(), | ||||
@@ -2764,16 +2763,20 @@ void *DavinciModel::Run(DavinciModel *model) { | |||||
/// @author | /// @author | ||||
/// | /// | ||||
Status DavinciModel::DestroyThread() { | Status DavinciModel::DestroyThread() { | ||||
GE_CHK_BOOL_RET_STATUS(data_inputer_ != nullptr, INTERNAL_ERROR, "data_inputer_ is nullptr."); | |||||
run_flg_ = false; | run_flg_ = false; | ||||
data_inputer_->Stop(); | |||||
if (data_inputer_ != nullptr) { | |||||
data_inputer_->Stop(); | |||||
} | |||||
if (thread_id_.joinable()) { | if (thread_id_.joinable()) { | ||||
thread_id_.join(); | thread_id_.join(); | ||||
} | } | ||||
if (shrink_id_.joinable()) { | |||||
shrink_id_.join(); | |||||
} | |||||
return SUCCESS; | return SUCCESS; | ||||
} | } | ||||
@@ -2820,8 +2823,6 @@ Status DavinciModel::ModelRunStop() { | |||||
LockRunFlg(); | LockRunFlg(); | ||||
GE_MAKE_GUARD(tmp_lock, [&] { UnlockRunFlg(); }); | GE_MAKE_GUARD(tmp_lock, [&] { UnlockRunFlg(); }); | ||||
GE_IF_BOOL_EXEC(!run_flg_, return SUCCESS); | |||||
GE_CHK_STATUS_RET(DestroyThread(), "DestoyThead failed."); | GE_CHK_STATUS_RET(DestroyThread(), "DestoyThead failed."); | ||||
return SUCCESS; | return SUCCESS; | ||||
@@ -2889,7 +2890,7 @@ Status DavinciModel::CreateKnownZeroCopyMap(const vector<void *> &inputs, const | |||||
GELOGI("input %zu, v addr %p, r addr %p, p addr %p", i, addr_list[kDataIndex], addr, inputs[i]); | GELOGI("input %zu, v addr %p, r addr %p, p addr %p", i, addr_list[kDataIndex], addr, inputs[i]); | ||||
} | } | ||||
if (output_addrs_list_.empty()) { | |||||
if (!has_output_node_) { | |||||
GELOGW("output op num in graph is %zu", output_addrs_list_.size()); | GELOGW("output op num in graph is %zu", output_addrs_list_.size()); | ||||
return SUCCESS; | return SUCCESS; | ||||
} | } | ||||
@@ -907,6 +907,7 @@ class DavinciModel { | |||||
vector<int64_t> output_memory_size_list_; | vector<int64_t> output_memory_size_list_; | ||||
thread thread_id_; | thread thread_id_; | ||||
thread shrink_id_; | |||||
shared_ptr<ModelListener> listener_; | shared_ptr<ModelListener> listener_; | ||||
@@ -1041,6 +1042,7 @@ class DavinciModel { | |||||
// For super kernel. | // For super kernel. | ||||
SuperKernelTaskInfo skt_info_; | SuperKernelTaskInfo skt_info_; | ||||
bool has_output_node_ = false; | |||||
bool is_dynamic_aipp_ = false; | bool is_dynamic_aipp_ = false; | ||||
vector<string> dynamic_output_shape_info_; | vector<string> dynamic_output_shape_info_; | ||||
@@ -270,18 +270,6 @@ ModelManager::~ModelManager() { | |||||
GE_IF_BOOL_EXEC(device_count > 0, GE_CHK_RT(rtDeviceReset(0))); | GE_IF_BOOL_EXEC(device_count > 0, GE_CHK_RT(rtDeviceReset(0))); | ||||
} | } | ||||
/// | |||||
/// @ingroup domi_ome | |||||
/// @brief set Device. If no device available, return failure | |||||
/// @return Status run result | |||||
/// @author | |||||
/// | |||||
Status ModelManager::SetDevice(int32_t deviceId) const { | |||||
GE_CHK_RT_RET(rtSetDevice(deviceId)); | |||||
return SUCCESS; | |||||
} | |||||
ge::Status ModelManager::SetDynamicSize(uint32_t model_id, const std::vector<uint64_t> &batch_num, | ge::Status ModelManager::SetDynamicSize(uint32_t model_id, const std::vector<uint64_t> &batch_num, | ||||
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); | ||||
@@ -322,8 +310,6 @@ Status ModelManager::LoadModelOnline(uint32_t &model_id, const shared_ptr<ge::Ge | |||||
return DoLoadHybridModelOnline(model_id, ge_root_model, listener); | return DoLoadHybridModelOnline(model_id, ge_root_model, listener); | ||||
} | } | ||||
GE_CHK_STATUS_RET(SetDevice(static_cast<int32_t>(GetContext().DeviceId())), "Set device failed, model id:%u.", | |||||
model_id); | |||||
mmTimespec timespec = mmGetTickCount(); | mmTimespec timespec = mmGetTickCount(); | ||||
std::shared_ptr<DavinciModel> davinci_model = MakeShared<DavinciModel>(0, listener); | std::shared_ptr<DavinciModel> davinci_model = MakeShared<DavinciModel>(0, listener); | ||||
if (davinci_model == nullptr) { | if (davinci_model == nullptr) { | ||||
@@ -360,8 +346,6 @@ Status ModelManager::LoadModelOnline(uint32_t &model_id, const shared_ptr<ge::Ge | |||||
GELOGI("Parse model %u success.", model_id); | GELOGI("Parse model %u success.", model_id); | ||||
} while (0); | } while (0); | ||||
GE_CHK_RT(rtDeviceReset(static_cast<int32_t>(GetContext().DeviceId()))); | |||||
return ret; | return ret; | ||||
} | } | ||||
@@ -1055,11 +1039,15 @@ Status ModelManager::LoadModelOffline(uint32_t &model_id, const ModelData &model | |||||
ACL_ERROR_GE_PARAM_INVALID, "input key file path %s is invalid, %s", model.key.c_str(), strerror(errno)); | ACL_ERROR_GE_PARAM_INVALID, "input key file path %s is invalid, %s", model.key.c_str(), strerror(errno)); | ||||
GenModelId(&model_id); | GenModelId(&model_id); | ||||
shared_ptr<DavinciModel> davinci_model = nullptr; | |||||
mmTimespec timespec = mmGetTickCount(); | mmTimespec timespec = mmGetTickCount(); | ||||
ModelHelper model_helper; | ModelHelper model_helper; | ||||
Status ret = model_helper.LoadRootModel(model); | Status ret = model_helper.LoadRootModel(model); | ||||
if (ret != SUCCESS) { | |||||
GELOGE(ret, "load model failed."); | |||||
return ret; | |||||
} | |||||
if (model_helper.GetModelType()) { | if (model_helper.GetModelType()) { | ||||
bool is_shape_unknown = false; | bool is_shape_unknown = false; | ||||
GE_CHK_STATUS_RET(model_helper.GetGeRootModel()->CheckIsUnknownShape(is_shape_unknown), | GE_CHK_STATUS_RET(model_helper.GetGeRootModel()->CheckIsUnknownShape(is_shape_unknown), | ||||
@@ -1068,21 +1056,13 @@ Status ModelManager::LoadModelOffline(uint32_t &model_id, const ModelData &model | |||||
return DoLoadHybridModelOnline(model_id, model_helper.GetGeRootModel(), listener); | return DoLoadHybridModelOnline(model_id, model_helper.GetGeRootModel(), listener); | ||||
} | } | ||||
} | } | ||||
if (ret != SUCCESS) { | |||||
GELOGE(ret, "load model failed."); | |||||
return ret; | |||||
} | |||||
do { | do { | ||||
GeModelPtr ge_model = model_helper.GetGeModel(); | GeModelPtr ge_model = model_helper.GetGeModel(); | ||||
try { | |||||
davinci_model = std::make_shared<DavinciModel>(model.priority, listener); | |||||
} catch (std::bad_alloc &) { | |||||
shared_ptr<DavinciModel> davinci_model = MakeShared<DavinciModel>(model.priority, listener); | |||||
if (davinci_model == nullptr) { | |||||
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "Make shared failed"); | GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "Make shared failed"); | ||||
return ACL_ERROR_GE_MEMORY_ALLOCATION; | return ACL_ERROR_GE_MEMORY_ALLOCATION; | ||||
} catch (...) { | |||||
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "Make shared failed since other exception raise"); | |||||
return ACL_ERROR_GE_MEMORY_ALLOCATION; | |||||
} | } | ||||
davinci_model->SetProfileTime(MODEL_LOAD_START, (timespec.tv_sec * kTimeSpecNano + | davinci_model->SetProfileTime(MODEL_LOAD_START, (timespec.tv_sec * kTimeSpecNano + | ||||
timespec.tv_nsec)); // 1000 ^ 3 converts second to nanosecond | timespec.tv_nsec)); // 1000 ^ 3 converts second to nanosecond | ||||
@@ -1122,9 +1102,8 @@ Status ModelManager::LoadModelOffline(uint32_t &model_id, const ModelData &model | |||||
InsertModel(model_id, davinci_model); | InsertModel(model_id, davinci_model); | ||||
GELOGI("Parse model %u success.", model_id); | GELOGI("Parse model %u success.", model_id); | ||||
GE_IF_BOOL_EXEC(ret == SUCCESS, device_count++); | GE_IF_BOOL_EXEC(ret == SUCCESS, device_count++); | ||||
return SUCCESS; | |||||
} while (0); | } while (0); | ||||
return ret; | return ret; | ||||
@@ -247,8 +247,6 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ModelManager { | |||||
ge::Status GetModelAttr(uint32_t model_id, std::vector<string> &dynamic_output_shape_info); | ge::Status GetModelAttr(uint32_t model_id, std::vector<string> &dynamic_output_shape_info); | ||||
ge::Status SetDevice(int32_t deviceId) const; | |||||
ge::Status SetDynamicSize(uint32_t model_id, const std::vector<uint64_t> &batch_num, int32_t dynamic_type); | ge::Status SetDynamicSize(uint32_t model_id, const std::vector<uint64_t> &batch_num, int32_t dynamic_type); | ||||
/// | /// | ||||
@@ -2622,14 +2622,9 @@ Status GraphManager::IncreBuild(const GraphNodePtr &graph_node, GeModelPtr &ge_m | |||||
return FAILED; | return FAILED; | ||||
} | } | ||||
void GraphManager::ConstructGeInput(std::vector<ge::GeTensor> &ge_inputs, PreRunArgs &args) { | |||||
for (auto const &input : args.input_tensor) { | |||||
std::vector<int64_t> input_dims; | |||||
std::transform(input.dims.begin(), input.dims.end(), std::back_inserter(input_dims), | |||||
[](int64_t x) -> int64_t { return x; }); | |||||
GeShape input_shape(input_dims); | |||||
GeTensorDesc input_tensor_desc; | |||||
input_tensor_desc.SetShape(input_shape); | |||||
void GraphManager::ConstructGeInput(const vector<InputTensorInfo> &inputs, vector<GeTensor> &ge_inputs) { | |||||
for (auto const &input : inputs) { | |||||
GeTensorDesc input_tensor_desc(GeShape(input.dims)); | |||||
input_tensor_desc.SetDataType(static_cast<ge::DataType>(input.data_type)); | input_tensor_desc.SetDataType(static_cast<ge::DataType>(input.data_type)); | ||||
ge_inputs.emplace_back(input_tensor_desc); | ge_inputs.emplace_back(input_tensor_desc); | ||||
} | } | ||||
@@ -2653,9 +2648,6 @@ void GraphManager::PreRunThread(GraphManager *graph_manager) { | |||||
GetThreadLocalContext() = args.context; | GetThreadLocalContext() = args.context; | ||||
graph_manager->UpdateLocalOmgContext(args.graph_id); | graph_manager->UpdateLocalOmgContext(args.graph_id); | ||||
std::vector<ge::GeTensor> ge_inputs; | |||||
ConstructGeInput(ge_inputs, args); | |||||
// find graph | // find graph | ||||
GraphNodePtr graph_node = nullptr; | GraphNodePtr graph_node = nullptr; | ||||
Status ret = graph_manager->GetGraphNode(args.graph_id, graph_node); | Status ret = graph_manager->GetGraphNode(args.graph_id, graph_node); | ||||
@@ -2709,6 +2701,8 @@ void GraphManager::PreRunThread(GraphManager *graph_manager) { | |||||
// check need incre build. | // check need incre build. | ||||
GeModelPtr ge_model = nullptr; | GeModelPtr ge_model = nullptr; | ||||
if (graph_manager->IncreBuild(graph_node, ge_model) != SUCCESS) { | if (graph_manager->IncreBuild(graph_node, ge_model) != SUCCESS) { | ||||
std::vector<GeTensor> ge_inputs; | |||||
ConstructGeInput(args.input_tensor, ge_inputs); | |||||
ret = graph_manager->PreRun(graph_node, ge_inputs, ge_root_model, args.session_id); | ret = graph_manager->PreRun(graph_node, ge_inputs, ge_root_model, args.session_id); | ||||
// release rts generate context | // release rts generate context | ||||
RtContextUtil::GetInstance().DestroyRtContexts(args.session_id, graph_node->GetGraphId()); | RtContextUtil::GetInstance().DestroyRtContexts(args.session_id, graph_node->GetGraphId()); | ||||
@@ -336,7 +336,7 @@ class GraphManager { | |||||
void RemoveModelCacheHelper(const GraphId &graph_id); | void RemoveModelCacheHelper(const GraphId &graph_id); | ||||
ModelCacheHelperPtr FindModelCacheHelper(GraphId graph_id); | ModelCacheHelperPtr FindModelCacheHelper(GraphId graph_id); | ||||
static void ConstructGeInput(std::vector<ge::GeTensor> &ge_inputs, PreRunArgs &args); | |||||
static void ConstructGeInput(const std::vector<InputTensorInfo> &inputs, std::vector<GeTensor> &ge_inputs); | |||||
static void PreRunThread(GraphManager *graph_manager); | static void PreRunThread(GraphManager *graph_manager); | ||||
static void RunThread(GraphManager *graph_manager); | static void RunThread(GraphManager *graph_manager); | ||||
static void StopQueue(GraphManager *graph_manager); | static void StopQueue(GraphManager *graph_manager); | ||||
@@ -71,7 +71,7 @@ const char *const kOutputTypeError = "The multiple out nodes set in output_type | |||||
const size_t kNodeNameIndex = 0; | const size_t kNodeNameIndex = 0; | ||||
const size_t kIndexStrIndex = 1; | const size_t kIndexStrIndex = 1; | ||||
const size_t kDTValueIndex = 2; | const size_t kDTValueIndex = 2; | ||||
const size_t kOmInfoSize = 5; | |||||
const size_t kOmInfoSize = 4; | |||||
} // namespace | } // namespace | ||||
// When the model is converted to a JSON file, the following operator attributes in the blacklist will be ignored | // When the model is converted to a JSON file, the following operator attributes in the blacklist will be ignored | ||||
@@ -828,7 +828,7 @@ void GetGroupName(ge::proto::ModelDef &model_def) { | |||||
}); | }); | ||||
} | } | ||||
FMK_FUNC_HOST_VISIBILITY void PrintModelInfo(ge::proto::ModelDef *model_def) { | |||||
FMK_FUNC_HOST_VISIBILITY void PrintModelInfo(ge::proto::ModelDef *model_def, uint32_t modeldef_size) { | |||||
std::cout << "============ Display Model Info start ============" << std::endl; | std::cout << "============ Display Model Info start ============" << std::endl; | ||||
auto model_attr_map = model_def->mutable_attr(); | auto model_attr_map = model_def->mutable_attr(); | ||||
@@ -879,15 +879,15 @@ FMK_FUNC_HOST_VISIBILITY void PrintModelInfo(ge::proto::ModelDef *model_def) { | |||||
if (list_size == kOmInfoSize) { | if (list_size == kOmInfoSize) { | ||||
std::cout << "om info: " | std::cout << "om info: " | ||||
<< "modeldef_size" | << "modeldef_size" | ||||
<< "[" << iter->second.list().i(0) << " B], " | |||||
<< "[" << modeldef_size << " B], " | |||||
<< "weight_data_size" | << "weight_data_size" | ||||
<< "[" << iter->second.list().i(1) << " B], " | |||||
<< "[" << iter->second.list().i(0) << " B], " | |||||
<< "tbe_kernels_size" | << "tbe_kernels_size" | ||||
<< "[" << iter->second.list().i(2) << " B], " | |||||
<< "[" << iter->second.list().i(1) << " B], " | |||||
<< "cust_aicpu_kernel_store_size" | << "cust_aicpu_kernel_store_size" | ||||
<< "[" << iter->second.list().i(3) << " B], " | |||||
<< "[" << iter->second.list().i(2) << " B], " | |||||
<< "task_info_size" | << "task_info_size" | ||||
<< "[" << iter->second.list().i(4) << " B]." << std::endl; | |||||
<< "[" << iter->second.list().i(3) << " B]." << std::endl; | |||||
} else { | } else { | ||||
std::cout << "Display Model Info error, please check!" << std::endl; | std::cout << "Display Model Info error, please check!" << std::endl; | ||||
}; | }; | ||||
@@ -955,7 +955,7 @@ FMK_FUNC_HOST_VISIBILITY Status ConvertOm(const char *model_file, const char *js | |||||
ret = ModelSaver::SaveJsonToFile(json_file, j); | ret = ModelSaver::SaveJsonToFile(json_file, j); | ||||
} else { | } else { | ||||
PrintModelInfo(&model_def); | |||||
PrintModelInfo(&model_def, ir_part.size); | |||||
} | } | ||||
} else { | } else { | ||||
ret = INTERNAL_ERROR; | ret = INTERNAL_ERROR; | ||||
@@ -43,8 +43,8 @@ namespace ge { | |||||
* @brief init omg context | * @brief init omg context | ||||
* @return void | * @return void | ||||
*/ | */ | ||||
GE_FUNC_VISIBILITY Status InitDomiOmgContext(const string &input_shape, const string &input_format, const string &net_format, | |||||
bool is_dynamic_input); | |||||
GE_FUNC_VISIBILITY Status InitDomiOmgContext(const string &input_shape, const string &input_format, | |||||
const string &net_format, bool is_dynamic_input); | |||||
/** | /** | ||||
* @ingroup domi_omg | * @ingroup domi_omg | ||||
@@ -61,9 +61,10 @@ GE_FUNC_VISIBILITY Status InitDomiOmgContext(const string &input_shape, const st | |||||
* @param [in] atc_params multiply atc params | * @param [in] atc_params multiply atc params | ||||
* @return Status result code | * @return Status result code | ||||
*/ | */ | ||||
GE_FUNC_VISIBILITY Status ParseGraph(ge::Graph &graph, const std::map<string, string> &atc_params, const char *model_file, | |||||
const char *weights_file, domi::FrameworkType type, const char *op_conf = nullptr, | |||||
const char *target = nullptr, RunMode run_mode = GEN_OM_MODEL, bool is_dynamic_input = false); | |||||
GE_FUNC_VISIBILITY Status ParseGraph(ge::Graph &graph, const std::map<string, string> &atc_params, | |||||
const char *model_file, const char *weights_file, domi::FrameworkType type, | |||||
const char *op_conf = nullptr, const char *target = nullptr, | |||||
RunMode run_mode = GEN_OM_MODEL, bool is_dynamic_input = false); | |||||
/** | /** | ||||
* @ingroup domi_omg | * @ingroup domi_omg | ||||
@@ -85,7 +86,8 @@ GE_FUNC_VISIBILITY Status ConvertPbtxtToJson(const char *model_file, const char | |||||
* @param [key] encrypted key | * @param [key] encrypted key | ||||
* @return Status result code | * @return Status result code | ||||
*/ | */ | ||||
GE_FUNC_VISIBILITY Status ConvertFwkModelToJson(domi::FrameworkType framework, const char *model_file, const char *json_file); | |||||
GE_FUNC_VISIBILITY Status ConvertFwkModelToJson(domi::FrameworkType framework, const char *model_file, | |||||
const char *json_file); | |||||
GE_FUNC_VISIBILITY void GetGroupName(ge::proto::ModelDef &model); | GE_FUNC_VISIBILITY void GetGroupName(ge::proto::ModelDef &model); | ||||
@@ -93,18 +95,20 @@ GE_FUNC_VISIBILITY void FindParserSo(const string &path, vector<string> &fileLis | |||||
GE_FUNC_VISIBILITY Status DumpInfershapeJson(const ge::Graph &graph, const char *json_file); | GE_FUNC_VISIBILITY Status DumpInfershapeJson(const ge::Graph &graph, const char *json_file); | ||||
GE_FUNC_VISIBILITY Status SetOutputNodeInfo(ge::Graph &graph, const std::string &output_type, const std::string &output_format); | |||||
GE_FUNC_VISIBILITY Status SetOutputNodeInfo(ge::Graph &graph, const std::string &output_type, | |||||
const std::string &output_format); | |||||
GE_FUNC_VISIBILITY Status GetOutputLeaf(ge::NodePtr node, std::vector<std::pair<ge::NodePtr, int32_t>> &output_nodes_info); | |||||
GE_FUNC_VISIBILITY Status GetOutputLeaf(ge::NodePtr node, | |||||
std::vector<std::pair<ge::NodePtr, int32_t>> &output_nodes_info); | |||||
GE_FUNC_VISIBILITY void GetOutputNodesNameAndIndex(std::vector<std::pair<ge::NodePtr, int32_t>> &output_nodes_info, | GE_FUNC_VISIBILITY void GetOutputNodesNameAndIndex(std::vector<std::pair<ge::NodePtr, int32_t>> &output_nodes_info, | ||||
std::vector<std::string> &output_nodes_name); | |||||
std::vector<std::string> &output_nodes_name); | |||||
GE_FUNC_VISIBILITY void UpdateOmgCtxWithParserCtx(); | GE_FUNC_VISIBILITY void UpdateOmgCtxWithParserCtx(); | ||||
GE_FUNC_VISIBILITY void UpdateParserCtxWithOmgCtx(); | GE_FUNC_VISIBILITY void UpdateParserCtxWithOmgCtx(); | ||||
GE_FUNC_VISIBILITY void PrintModelInfo(ge::proto::ModelDef *model_def); | |||||
GE_FUNC_VISIBILITY void PrintModelInfo(ge::proto::ModelDef *model_def, uint32_t modeldef_size); | |||||
} // namespace ge | } // namespace ge | ||||
namespace domi { | namespace domi { | ||||
@@ -1 +1 @@ | |||||
Subproject commit 40e2d5c974eda1d1f5716b18fc776dede7da4370 | |||||
Subproject commit a2b80cb22a62a6757c7dd31e684ca632e0b79268 |
@@ -1 +1 @@ | |||||
Subproject commit 3c534dc831eeedd13ad86d9c2b52879f345403e0 | |||||
Subproject commit cfabf622b803d5957563a73652a0ce5086aab99d |
@@ -58,7 +58,7 @@ namespace { | |||||
/// relu1 | /// relu1 | ||||
/// | | /// | | ||||
/// conv1 | /// conv1 | ||||
/// / \ | |||||
/// / \. | |||||
/// var1 var2 | /// var1 var2 | ||||
/// | /// | ||||
ut::GraphBuilder BuildGraph1() { | ut::GraphBuilder BuildGraph1() { | ||||
@@ -95,9 +95,9 @@ ut::GraphBuilder BuildGraph1() { | |||||
/// relu1 | /// relu1 | ||||
/// | | /// | | ||||
/// bn1 ----------------- | /// bn1 ----------------- | ||||
/// | \ \ \ \ | |||||
/// | \ \ \ \. | |||||
/// conv1 var3 var4 var5 var6 | /// conv1 var3 var4 var5 var6 | ||||
/// | \ | |||||
/// | \. | |||||
/// var1 var2 | /// var1 var2 | ||||
/// | /// | ||||
ut::GraphBuilder BuildGraph2() { | ut::GraphBuilder BuildGraph2() { | ||||
@@ -142,11 +142,11 @@ ut::GraphBuilder BuildGraph2() { | |||||
/// netoutput1 | /// netoutput1 | ||||
/// | | /// | | ||||
/// conv2 | /// conv2 | ||||
/// | \ | |||||
/// | \. | |||||
/// relu1 var3 | /// relu1 var3 | ||||
/// | | /// | | ||||
/// conv1 | /// conv1 | ||||
/// / \ | |||||
/// / \. | |||||
/// var1 var2 | /// var1 var2 | ||||
/// | /// | ||||
ut::GraphBuilder BuildGraph3() { | ut::GraphBuilder BuildGraph3() { | ||||
@@ -197,13 +197,13 @@ ut::GraphBuilder BuildGraph3() { | |||||
/// netoutput1 | /// netoutput1 | ||||
/// | | /// | | ||||
/// conv2 | /// conv2 | ||||
/// | \ | |||||
/// | \. | |||||
/// relu1 var3 | /// relu1 var3 | ||||
/// | | /// | | ||||
/// bn1 | /// bn1 | ||||
/// | | /// | | ||||
/// conv1 | /// conv1 | ||||
/// / \ | |||||
/// / \. | |||||
/// var1 var2 | /// var1 var2 | ||||
/// | /// | ||||
ut::GraphBuilder BuildGraph4() { | ut::GraphBuilder BuildGraph4() { | ||||
@@ -256,10 +256,10 @@ ut::GraphBuilder BuildGraph4() { | |||||
/// netoutput1 | /// netoutput1 | ||||
/// | | /// | | ||||
/// apply1 | /// apply1 | ||||
/// / \ | |||||
/// relug1 --> bng1 \ | |||||
/// \ / | \ \ | |||||
/// relu1 | | \ | |||||
/// / \. | |||||
/// relug1 --> bng1 \. | |||||
/// \ / | \ \. | |||||
/// relu1 | | \. | |||||
/// \| | | | /// \| | | | ||||
/// | | | | /// | | | | ||||
/// bn1 | | | /// bn1 | | | ||||
@@ -313,9 +313,9 @@ ut::GraphBuilder BuilderGraph5() { | |||||
/// netoutput1 | /// netoutput1 | ||||
/// | | /// | | ||||
/// AddN | /// AddN | ||||
/// / \ \ | |||||
/// / \ \. | |||||
/// L2Loss GatherV2 Constant | /// L2Loss GatherV2 Constant | ||||
/// / \ | |||||
/// / \. | |||||
/// Data1 Data2 | /// Data1 Data2 | ||||
/// | /// | ||||
ut::GraphBuilder BuildGraph6() { | ut::GraphBuilder BuildGraph6() { | ||||
@@ -362,9 +362,9 @@ ut::GraphBuilder BuildGraph6() { | |||||
/// netoutput1 | /// netoutput1 | ||||
/// | | /// | | ||||
/// AddN | /// AddN | ||||
/// / \ \ | |||||
/// / \ \. | |||||
/// L2Loss GatherV2 Constant | /// L2Loss GatherV2 Constant | ||||
/// / \ | |||||
/// / \. | |||||
/// Data1 Data2 | /// Data1 Data2 | ||||
/// | /// | ||||
ut::GraphBuilder BuildGraph7() { | ut::GraphBuilder BuildGraph7() { | ||||
@@ -30,7 +30,7 @@ | |||||
using namespace ge; | using namespace ge; | ||||
using namespace std; | using namespace std; | ||||
class UtestGeAnchor : public testing::Test { | |||||
class UtestGeAnchor : public testing::Test { | |||||
protected: | protected: | ||||
void SetUp() {} | void SetUp() {} | ||||
@@ -294,7 +294,7 @@ TEST_F(UtestGeAnchor, data_anchor_replace_peer) { | |||||
EXPECT_EQ(node1->GetOutDataAnchor(1)->LinkTo(node2->GetInDataAnchor(1)), GRAPH_SUCCESS); | EXPECT_EQ(node1->GetOutDataAnchor(1)->LinkTo(node2->GetInDataAnchor(1)), GRAPH_SUCCESS); | ||||
EXPECT_EQ(node1->GetOutDataAnchor(1)->LinkTo(node2->GetInDataAnchor(2)), GRAPH_SUCCESS); | EXPECT_EQ(node1->GetOutDataAnchor(1)->LinkTo(node2->GetInDataAnchor(2)), GRAPH_SUCCESS); | ||||
int out_idx = 0; | |||||
size_t out_idx = 0; | |||||
for (; out_idx < out_data_anchor->peer_anchors_.size(); out_idx++) { | for (; out_idx < out_data_anchor->peer_anchors_.size(); out_idx++) { | ||||
if (out_data_anchor->peer_anchors_[out_idx].lock() == in_data_anchor) { | if (out_data_anchor->peer_anchors_[out_idx].lock() == in_data_anchor) { | ||||
break; | break; | ||||
@@ -302,7 +302,7 @@ TEST_F(UtestGeAnchor, data_anchor_replace_peer) { | |||||
} | } | ||||
EXPECT_EQ(out_idx, 1); | EXPECT_EQ(out_idx, 1); | ||||
int in_idx = 0; | |||||
size_t in_idx = 0; | |||||
for (; in_idx < in_data_anchor->peer_anchors_.size(); in_idx++) { | for (; in_idx < in_data_anchor->peer_anchors_.size(); in_idx++) { | ||||
if (in_data_anchor->peer_anchors_[in_idx].lock() == out_data_anchor) { | if (in_data_anchor->peer_anchors_[in_idx].lock() == out_data_anchor) { | ||||
break; | break; | ||||
@@ -312,7 +312,7 @@ TEST_F(UtestGeAnchor, data_anchor_replace_peer) { | |||||
out_data_anchor->ReplacePeer(in_data_anchor, node3->GetInDataAnchor(1), node3->GetOutDataAnchor(1)); | out_data_anchor->ReplacePeer(in_data_anchor, node3->GetInDataAnchor(1), node3->GetOutDataAnchor(1)); | ||||
int out_idx1 = 0; | |||||
size_t out_idx1 = 0; | |||||
for (; out_idx1 < out_data_anchor->peer_anchors_.size(); out_idx1++) { | for (; out_idx1 < out_data_anchor->peer_anchors_.size(); out_idx1++) { | ||||
if (out_data_anchor->peer_anchors_[out_idx1].lock() == node3->GetInDataAnchor(1)) { | if (out_data_anchor->peer_anchors_[out_idx1].lock() == node3->GetInDataAnchor(1)) { | ||||
break; | break; | ||||
@@ -320,7 +320,7 @@ TEST_F(UtestGeAnchor, data_anchor_replace_peer) { | |||||
} | } | ||||
EXPECT_EQ(out_idx1, out_idx); | EXPECT_EQ(out_idx1, out_idx); | ||||
int in_idx1 = 0; | |||||
size_t in_idx1 = 0; | |||||
for (; in_idx1 < in_data_anchor->peer_anchors_.size(); in_idx1++) { | for (; in_idx1 < in_data_anchor->peer_anchors_.size(); in_idx1++) { | ||||
if (in_data_anchor->peer_anchors_[in_idx1].lock() == node3->GetOutDataAnchor(1)) { | if (in_data_anchor->peer_anchors_[in_idx1].lock() == node3->GetOutDataAnchor(1)) { | ||||
break; | break; | ||||
@@ -350,7 +350,7 @@ TEST_F(UtestGeAnchor, graph_utils_insert_node) { | |||||
EXPECT_EQ(node1->GetOutDataAnchor(1)->LinkTo(node2->GetInDataAnchor(1)), GRAPH_SUCCESS); | EXPECT_EQ(node1->GetOutDataAnchor(1)->LinkTo(node2->GetInDataAnchor(1)), GRAPH_SUCCESS); | ||||
EXPECT_EQ(node1->GetOutDataAnchor(1)->LinkTo(node2->GetInDataAnchor(2)), GRAPH_SUCCESS); | EXPECT_EQ(node1->GetOutDataAnchor(1)->LinkTo(node2->GetInDataAnchor(2)), GRAPH_SUCCESS); | ||||
int out_idx = 0; | |||||
size_t out_idx = 0; | |||||
for (; out_idx < out_data_anchor->peer_anchors_.size(); out_idx++) { | for (; out_idx < out_data_anchor->peer_anchors_.size(); out_idx++) { | ||||
if (out_data_anchor->peer_anchors_[out_idx].lock() == in_data_anchor) { | if (out_data_anchor->peer_anchors_[out_idx].lock() == in_data_anchor) { | ||||
break; | break; | ||||
@@ -358,7 +358,7 @@ TEST_F(UtestGeAnchor, graph_utils_insert_node) { | |||||
} | } | ||||
EXPECT_EQ(out_idx, 1); | EXPECT_EQ(out_idx, 1); | ||||
int in_idx = 0; | |||||
size_t in_idx = 0; | |||||
for (; in_idx < in_data_anchor->peer_anchors_.size(); in_idx++) { | for (; in_idx < in_data_anchor->peer_anchors_.size(); in_idx++) { | ||||
if (in_data_anchor->peer_anchors_[in_idx].lock() == out_data_anchor) { | if (in_data_anchor->peer_anchors_[in_idx].lock() == out_data_anchor) { | ||||
break; | break; | ||||
@@ -368,7 +368,7 @@ TEST_F(UtestGeAnchor, graph_utils_insert_node) { | |||||
GraphUtils::InsertNodeBetweenDataAnchors(out_data_anchor, in_data_anchor, node3); | GraphUtils::InsertNodeBetweenDataAnchors(out_data_anchor, in_data_anchor, node3); | ||||
int out_idx1 = 0; | |||||
size_t out_idx1 = 0; | |||||
for (; out_idx1 < out_data_anchor->peer_anchors_.size(); out_idx1++) { | for (; out_idx1 < out_data_anchor->peer_anchors_.size(); out_idx1++) { | ||||
if (out_data_anchor->peer_anchors_[out_idx1].lock() == node3->GetInDataAnchor(0)) { | if (out_data_anchor->peer_anchors_[out_idx1].lock() == node3->GetInDataAnchor(0)) { | ||||
break; | break; | ||||
@@ -376,7 +376,7 @@ TEST_F(UtestGeAnchor, graph_utils_insert_node) { | |||||
} | } | ||||
EXPECT_EQ(out_idx1, out_idx); | EXPECT_EQ(out_idx1, out_idx); | ||||
int in_idx1 = 0; | |||||
size_t in_idx1 = 0; | |||||
for (; in_idx1 < in_data_anchor->peer_anchors_.size(); in_idx1++) { | for (; in_idx1 < in_data_anchor->peer_anchors_.size(); in_idx1++) { | ||||
if (in_data_anchor->peer_anchors_[in_idx1].lock() == node3->GetOutDataAnchor(0)) { | if (in_data_anchor->peer_anchors_[in_idx1].lock() == node3->GetOutDataAnchor(0)) { | ||||
break; | break; | ||||
@@ -59,7 +59,7 @@ NodePtr CreateNode(OpDescPtr op, ComputeGraphPtr owner_graph) { return owner_gra | |||||
void CompareShape(const vector<int64_t> &shape1, const vector<int64_t> &shape2) { | void CompareShape(const vector<int64_t> &shape1, const vector<int64_t> &shape2) { | ||||
EXPECT_EQ(shape1.size(), shape2.size()); | EXPECT_EQ(shape1.size(), shape2.size()); | ||||
if (shape1.size() == shape2.size()) { | if (shape1.size() == shape2.size()) { | ||||
for (int i = 0; i < shape1.size(); i++) { | |||||
for (size_t i = 0; i < shape1.size(); i++) { | |||||
EXPECT_EQ(shape1[i], shape2[i]); | EXPECT_EQ(shape1[i], shape2[i]); | ||||
} | } | ||||
} | } | ||||
@@ -69,7 +69,7 @@ template <typename T> | |||||
void CompareList(const vector<T> &val1, const vector<T> &val2) { | void CompareList(const vector<T> &val1, const vector<T> &val2) { | ||||
EXPECT_EQ(val1.size(), val2.size()); | EXPECT_EQ(val1.size(), val2.size()); | ||||
if (val1.size() == val2.size()) { | if (val1.size() == val2.size()) { | ||||
for (int i = 0; i < val1.size(); i++) { | |||||
for (size_t i = 0; i < val1.size(); i++) { | |||||
EXPECT_EQ(val1[i], val2[i]); | EXPECT_EQ(val1[i], val2[i]); | ||||
} | } | ||||
} | } | ||||
@@ -129,6 +129,9 @@ static bool NamedAttrsSimpleCmp(const GeAttrValue &left, const GeAttrValue &righ | |||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
default: { | |||||
return true; | |||||
} | |||||
} | } | ||||
} | } | ||||
return true; | return true; | ||||
@@ -625,7 +625,7 @@ set(DISTINCT_GRAPH_LOAD_TEST_FILES | |||||
"graph/load/data_dumper_unittest.cc" | "graph/load/data_dumper_unittest.cc" | ||||
#"graph/load/new_model_manager_data_inputer_unittest.cc" | #"graph/load/new_model_manager_data_inputer_unittest.cc" | ||||
#"graph/load/new_model_manager_davinci_model_unittest.cc" | #"graph/load/new_model_manager_davinci_model_unittest.cc" | ||||
"graph/load/new_model_manager_model_manager_unittest.cc" | |||||
"graph/load/model_manager_unittest.cc" | |||||
#"graph/load/new_model_manager_task_build_unittest.cc" | #"graph/load/new_model_manager_task_build_unittest.cc" | ||||
"graph/load/new_model_manager_model_manager_aicpu_unittest.cc" | "graph/load/new_model_manager_model_manager_aicpu_unittest.cc" | ||||
"graph/load/end_graph_task_unittest.cc" | "graph/load/end_graph_task_unittest.cc" | ||||
@@ -27,6 +27,16 @@ using namespace std; | |||||
namespace ge { | namespace ge { | ||||
extern OpDescPtr CreateOpDesc(string name, string type); | extern OpDescPtr CreateOpDesc(string name, string type); | ||||
class DModelListener : public ModelListener { | |||||
public: | |||||
DModelListener(){}; | |||||
uint32_t OnComputeDone(uint32_t model_id, uint32_t data_index, uint32_t result, vector<OutputTensorInfo> &outputs) { | |||||
return 0; | |||||
} | |||||
}; | |||||
shared_ptr<ModelListener> g_local_call_back(new DModelListener()); | |||||
class UtestDavinciModel : public testing::Test { | class UtestDavinciModel : public testing::Test { | ||||
protected: | protected: | ||||
void SetUp() {} | void SetUp() {} | ||||
@@ -38,7 +48,6 @@ int32_t MsprofReport(uint32_t moduleId, uint32_t type, void *data, uint32_t len) | |||||
return 0; | return 0; | ||||
} | } | ||||
/* | |||||
TEST_F(UtestDavinciModel, init_success) { | TEST_F(UtestDavinciModel, init_success) { | ||||
DavinciModel model(0, nullptr); | DavinciModel model(0, nullptr); | ||||
ComputeGraphPtr graph = make_shared<ComputeGraph>("default"); | ComputeGraphPtr graph = make_shared<ComputeGraph>("default"); | ||||
@@ -46,7 +55,7 @@ TEST_F(UtestDavinciModel, init_success) { | |||||
GeModelPtr ge_model = make_shared<GeModel>(); | GeModelPtr ge_model = make_shared<GeModel>(); | ||||
ge_model->SetGraph(GraphUtils::CreateGraphFromComputeGraph(graph)); | ge_model->SetGraph(GraphUtils::CreateGraphFromComputeGraph(graph)); | ||||
AttrUtils::SetInt(ge_model, ATTR_MODEL_MEMORY_SIZE, 5120000); | |||||
AttrUtils::SetInt(ge_model, ATTR_MODEL_MEMORY_SIZE, 10240); | |||||
AttrUtils::SetInt(ge_model, ATTR_MODEL_STREAM_NUM, 1); | AttrUtils::SetInt(ge_model, ATTR_MODEL_STREAM_NUM, 1); | ||||
shared_ptr<domi::ModelTaskDef> model_task_def = make_shared<domi::ModelTaskDef>(); | shared_ptr<domi::ModelTaskDef> model_task_def = make_shared<domi::ModelTaskDef>(); | ||||
@@ -54,60 +63,66 @@ TEST_F(UtestDavinciModel, init_success) { | |||||
GeTensorDesc tensor(GeShape(), FORMAT_NCHW, DT_FLOAT); | GeTensorDesc tensor(GeShape(), FORMAT_NCHW, DT_FLOAT); | ||||
TensorUtils::SetSize(tensor, 512); | TensorUtils::SetSize(tensor, 512); | ||||
{ | |||||
OpDescPtr op_desc = CreateOpDesc("data", DATA); | |||||
op_desc->AddInputDesc(tensor); | |||||
op_desc->AddOutputDesc(tensor); | |||||
op_desc->SetInputOffset({1024}); | |||||
op_desc->SetOutputOffset({1024}); | |||||
NodePtr node = graph->AddNode(op_desc); // op_index = 0 | |||||
} | |||||
OpDescPtr op_input = CreateOpDesc("data", DATA); | |||||
op_input->AddInputDesc(tensor); | |||||
op_input->AddOutputDesc(tensor); | |||||
op_input->SetInputOffset({1024}); | |||||
op_input->SetOutputOffset({1024}); | |||||
NodePtr node_input = graph->AddNode(op_input); // op_index = 0 | |||||
OpDescPtr op_kernel = CreateOpDesc("square", "Square"); | |||||
op_kernel->AddInputDesc(tensor); | |||||
op_kernel->AddOutputDesc(tensor); | |||||
op_kernel->SetInputOffset({1024}); | |||||
op_kernel->SetOutputOffset({1024}); | |||||
NodePtr node_kernel = graph->AddNode(op_kernel); // op_index = 1 | |||||
OpDescPtr op_memcpy = CreateOpDesc("memcpy", MEMCPYASYNC); | |||||
op_memcpy->AddInputDesc(tensor); | |||||
op_memcpy->AddOutputDesc(tensor); | |||||
op_memcpy->SetInputOffset({1024}); | |||||
op_memcpy->SetOutputOffset({5120}); | |||||
NodePtr node_memcpy = graph->AddNode(op_memcpy); // op_index = 2 | |||||
OpDescPtr op_output = CreateOpDesc("output", NETOUTPUT); | |||||
op_output->AddInputDesc(tensor); | |||||
op_output->SetInputOffset({5120}); | |||||
op_output->SetSrcName( { "memcpy" } ); | |||||
op_output->SetSrcIndex( { 0 } ); | |||||
NodePtr node_output = graph->AddNode(op_output); // op_index = 3 | |||||
{ | |||||
OpDescPtr op_desc = CreateOpDesc("square", "Square"); | |||||
op_desc->AddInputDesc(tensor); | |||||
op_desc->AddOutputDesc(tensor); | |||||
op_desc->SetInputOffset({1024}); | |||||
op_desc->SetOutputOffset({1024}); | |||||
NodePtr node = graph->AddNode(op_desc); // op_index = 1 | |||||
domi::TaskDef *task_def = model_task_def->add_task(); | |||||
task_def->set_stream_id(0); | |||||
task_def->set_type(RT_MODEL_TASK_KERNEL); | |||||
domi::KernelDef *kernel_def = task_def->mutable_kernel(); | |||||
kernel_def->set_stub_func("stub_func"); | |||||
kernel_def->set_args_size(64); | |||||
string args(64, '1'); | |||||
kernel_def->set_args(args.data(), 64); | |||||
domi::KernelContext *context = kernel_def->mutable_context(); | |||||
context->set_op_index(op_desc->GetId()); | |||||
context->set_kernel_type(2); // ccKernelType::TE | |||||
uint16_t args_offset[9] = {0}; | |||||
context->set_args_offset(args_offset, 9 * sizeof(uint16_t)); | |||||
} | |||||
domi::TaskDef *task_def1 = model_task_def->add_task(); | |||||
task_def1->set_stream_id(0); | |||||
task_def1->set_type(RT_MODEL_TASK_KERNEL); | |||||
domi::KernelDef *kernel_def = task_def1->mutable_kernel(); | |||||
kernel_def->set_stub_func("stub_func"); | |||||
kernel_def->set_args_size(64); | |||||
string args(64, '1'); | |||||
kernel_def->set_args(args.data(), 64); | |||||
domi::KernelContext *context = kernel_def->mutable_context(); | |||||
context->set_op_index(1); | |||||
context->set_kernel_type(2); // ccKernelType::TE | |||||
uint16_t args_offset[9] = {0}; | |||||
context->set_args_offset(args_offset, 9 * sizeof(uint16_t)); | |||||
{ | |||||
OpDescPtr op_desc = CreateOpDesc("memcpy", MEMCPYASYNC); | |||||
op_desc->AddInputDesc(tensor); | |||||
op_desc->AddOutputDesc(tensor); | |||||
op_desc->SetInputOffset({1024}); | |||||
op_desc->SetOutputOffset({5120}); | |||||
NodePtr node = graph->AddNode(op_desc); // op_index = 2 | |||||
domi::TaskDef *task_def = model_task_def->add_task(); | |||||
task_def->set_stream_id(0); | |||||
task_def->set_type(RT_MODEL_TASK_MEMCPY_ASYNC); | |||||
domi::MemcpyAsyncDef *memcpy_async = task_def->mutable_memcpy_async(); | |||||
memcpy_async->set_src(1024); | |||||
memcpy_async->set_dst(5120); | |||||
memcpy_async->set_dst_max(512); | |||||
memcpy_async->set_count(1); | |||||
memcpy_async->set_kind(RT_MEMCPY_DEVICE_TO_DEVICE); | |||||
memcpy_async->set_op_index(op_desc->GetId()); | |||||
} | |||||
domi::TaskDef *task_def2 = model_task_def->add_task(); | |||||
task_def2->set_stream_id(0); | |||||
task_def2->set_type(RT_MODEL_TASK_MEMCPY_ASYNC); | |||||
domi::MemcpyAsyncDef *memcpy_async = task_def2->mutable_memcpy_async(); | |||||
memcpy_async->set_src(1024); | |||||
memcpy_async->set_dst(5120); | |||||
memcpy_async->set_dst_max(512); | |||||
memcpy_async->set_count(1); | |||||
memcpy_async->set_kind(RT_MEMCPY_DEVICE_TO_DEVICE); | |||||
memcpy_async->set_op_index(2); | |||||
{ | |||||
OpDescPtr op_desc = CreateOpDesc("output", NETOUTPUT); | |||||
op_desc->AddInputDesc(tensor); | |||||
op_desc->SetInputOffset({5120}); | |||||
op_desc->SetSrcName( { "memcpy" } ); | |||||
op_desc->SetSrcIndex( { 0 } ); | |||||
NodePtr node = graph->AddNode(op_desc); // op_index = 3 | |||||
} | |||||
EXPECT_EQ(model.Assign(ge_model), SUCCESS); | EXPECT_EQ(model.Assign(ge_model), SUCCESS); | ||||
EXPECT_EQ(model.Init(), SUCCESS); | EXPECT_EQ(model.Init(), SUCCESS); | ||||
@@ -124,7 +139,6 @@ TEST_F(UtestDavinciModel, init_success) { | |||||
ProfilingManager::Instance().is_load_profiling_ = false; | ProfilingManager::Instance().is_load_profiling_ = false; | ||||
} | } | ||||
*/ | |||||
TEST_F(UtestDavinciModel, init_data_op) { | TEST_F(UtestDavinciModel, init_data_op) { | ||||
DavinciModel model(0, nullptr); | DavinciModel model(0, nullptr); | ||||
@@ -280,7 +294,9 @@ TEST_F(UtestDavinciModel, init_unknown) { | |||||
memcpy_async->set_op_index(2); | memcpy_async->set_op_index(2); | ||||
EXPECT_EQ(model.Assign(ge_model), SUCCESS); | EXPECT_EQ(model.Assign(ge_model), SUCCESS); | ||||
ProfilingManager::Instance().is_load_profiling_ = true; | |||||
EXPECT_EQ(model.Init(), SUCCESS); | EXPECT_EQ(model.Init(), SUCCESS); | ||||
ProfilingManager::Instance().is_load_profiling_ = false; | |||||
EXPECT_EQ(model.input_addrs_list_.size(), 1); | EXPECT_EQ(model.input_addrs_list_.size(), 1); | ||||
EXPECT_EQ(model.output_addrs_list_.size(), 1); | EXPECT_EQ(model.output_addrs_list_.size(), 1); | ||||
@@ -303,7 +319,7 @@ TEST_F(UtestDavinciModel, init_unknown) { | |||||
} | } | ||||
TEST_F(UtestDavinciModel, Init_variable_op) { | TEST_F(UtestDavinciModel, Init_variable_op) { | ||||
DavinciModel model(0, nullptr); | |||||
DavinciModel model(0, g_local_call_back); | |||||
model.ge_model_ = make_shared<GeModel>(); | model.ge_model_ = make_shared<GeModel>(); | ||||
model.runtime_param_.mem_base = (uint8_t *)0x08000000; | model.runtime_param_.mem_base = (uint8_t *)0x08000000; | ||||
model.runtime_param_.mem_size = 5120000; | model.runtime_param_.mem_size = 5120000; | ||||
@@ -329,8 +345,14 @@ TEST_F(UtestDavinciModel, Init_variable_op) { | |||||
EXPECT_EQ(model.InitNodes(graph), SUCCESS); | EXPECT_EQ(model.InitNodes(graph), SUCCESS); | ||||
EXPECT_EQ(model.ReturnNoOutput(1), PARAM_INVALID); | |||||
EXPECT_EQ(model.ReturnNoOutput(1), SUCCESS); | |||||
EXPECT_EQ(model.SyncVarData(), SUCCESS); | EXPECT_EQ(model.SyncVarData(), SUCCESS); | ||||
OutputData output_data; | |||||
EXPECT_FALSE(model.has_output_node_); | |||||
EXPECT_EQ(model.CopyOutputData(1, output_data, RT_MEMCPY_DEVICE_TO_HOST), SUCCESS); | |||||
EXPECT_EQ(model.ReturnResult(1, false, true, &output_data), INTERNAL_ERROR); | |||||
} | } | ||||
TEST_F(UtestDavinciModel, InitRealSizeAndShapeInfo_succ1) { | TEST_F(UtestDavinciModel, InitRealSizeAndShapeInfo_succ1) { | ||||
@@ -752,7 +774,6 @@ TEST_F(UtestDavinciModel, init_data_aipp_input_dims_normal) { | |||||
EXPECT_EQ(model.op_list_.size(), 1); | EXPECT_EQ(model.op_list_.size(), 1); | ||||
} | } | ||||
/* | |||||
// test label_set_task Init | // test label_set_task Init | ||||
TEST_F(UtestDavinciModel, label_task_success) { | TEST_F(UtestDavinciModel, label_task_success) { | ||||
DavinciModel model(0, nullptr); | DavinciModel model(0, nullptr); | ||||
@@ -760,7 +781,7 @@ TEST_F(UtestDavinciModel, label_task_success) { | |||||
GeModelPtr ge_model = make_shared<GeModel>(); | GeModelPtr ge_model = make_shared<GeModel>(); | ||||
ge_model->SetGraph(GraphUtils::CreateGraphFromComputeGraph(graph)); | ge_model->SetGraph(GraphUtils::CreateGraphFromComputeGraph(graph)); | ||||
AttrUtils::SetInt(ge_model, ATTR_MODEL_MEMORY_SIZE, 5120000); | |||||
AttrUtils::SetInt(ge_model, ATTR_MODEL_MEMORY_SIZE, 10240); | |||||
AttrUtils::SetInt(ge_model, ATTR_MODEL_STREAM_NUM, 1); | AttrUtils::SetInt(ge_model, ATTR_MODEL_STREAM_NUM, 1); | ||||
shared_ptr<domi::ModelTaskDef> model_task_def = make_shared<domi::ModelTaskDef>(); | shared_ptr<domi::ModelTaskDef> model_task_def = make_shared<domi::ModelTaskDef>(); | ||||
@@ -769,7 +790,6 @@ TEST_F(UtestDavinciModel, label_task_success) { | |||||
GeTensorDesc tensor(GeShape(), FORMAT_ND, DT_INT32); | GeTensorDesc tensor(GeShape(), FORMAT_ND, DT_INT32); | ||||
TensorUtils::SetSize(tensor, 64); | TensorUtils::SetSize(tensor, 64); | ||||
uint32_t op_index = 0; | |||||
{ | { | ||||
OpDescPtr op_desc = CreateOpDesc("label_switch", LABELSWITCHBYINDEX); | OpDescPtr op_desc = CreateOpDesc("label_switch", LABELSWITCHBYINDEX); | ||||
op_desc->AddInputDesc(tensor); | op_desc->AddInputDesc(tensor); | ||||
@@ -781,7 +801,7 @@ TEST_F(UtestDavinciModel, label_task_success) { | |||||
task_def1->set_stream_id(0); | task_def1->set_stream_id(0); | ||||
task_def1->set_type(RT_MODEL_TASK_STREAM_LABEL_SWITCH_BY_INDEX); | task_def1->set_type(RT_MODEL_TASK_STREAM_LABEL_SWITCH_BY_INDEX); | ||||
domi::LabelSwitchByIndexDef *label_task_def = task_def1->mutable_label_switch_by_index(); | domi::LabelSwitchByIndexDef *label_task_def = task_def1->mutable_label_switch_by_index(); | ||||
label_task_def->set_op_index(op_index++); | |||||
label_task_def->set_op_index(op_desc->GetId()); | |||||
label_task_def->set_label_max(2); | label_task_def->set_label_max(2); | ||||
} | } | ||||
@@ -794,7 +814,7 @@ TEST_F(UtestDavinciModel, label_task_success) { | |||||
task_def1->set_stream_id(0); | task_def1->set_stream_id(0); | ||||
task_def1->set_type(RT_MODEL_TASK_LABEL_SET); | task_def1->set_type(RT_MODEL_TASK_LABEL_SET); | ||||
domi::LabelSetDef *label_task_def = task_def1->mutable_label_set(); | domi::LabelSetDef *label_task_def = task_def1->mutable_label_set(); | ||||
label_task_def->set_op_index(op_index++); | |||||
label_task_def->set_op_index(op_desc->GetId()); | |||||
} | } | ||||
{ | { | ||||
@@ -806,7 +826,7 @@ TEST_F(UtestDavinciModel, label_task_success) { | |||||
task_def2->set_stream_id(0); | task_def2->set_stream_id(0); | ||||
task_def2->set_type(RT_MODEL_TASK_STREAM_LABEL_GOTO); | task_def2->set_type(RT_MODEL_TASK_STREAM_LABEL_GOTO); | ||||
domi::LabelGotoExDef *label_task_def = task_def2->mutable_label_goto_ex(); | domi::LabelGotoExDef *label_task_def = task_def2->mutable_label_goto_ex(); | ||||
label_task_def->set_op_index(op_index++); | |||||
label_task_def->set_op_index(op_desc->GetId()); | |||||
} | } | ||||
{ | { | ||||
@@ -818,7 +838,7 @@ TEST_F(UtestDavinciModel, label_task_success) { | |||||
task_def1->set_stream_id(0); | task_def1->set_stream_id(0); | ||||
task_def1->set_type(RT_MODEL_TASK_LABEL_SET); | task_def1->set_type(RT_MODEL_TASK_LABEL_SET); | ||||
domi::LabelSetDef *label_task_def = task_def1->mutable_label_set(); | domi::LabelSetDef *label_task_def = task_def1->mutable_label_set(); | ||||
label_task_def->set_op_index(op_index++); | |||||
label_task_def->set_op_index(op_desc->GetId()); | |||||
} | } | ||||
{ | { | ||||
@@ -830,7 +850,7 @@ TEST_F(UtestDavinciModel, label_task_success) { | |||||
task_def1->set_stream_id(0); | task_def1->set_stream_id(0); | ||||
task_def1->set_type(RT_MODEL_TASK_LABEL_SET); | task_def1->set_type(RT_MODEL_TASK_LABEL_SET); | ||||
domi::LabelSetDef *label_task_def = task_def1->mutable_label_set(); | domi::LabelSetDef *label_task_def = task_def1->mutable_label_set(); | ||||
label_task_def->set_op_index(op_index++); | |||||
label_task_def->set_op_index(op_desc->GetId()); | |||||
} | } | ||||
EXPECT_TRUE(AttrUtils::SetInt(ge_model, ATTR_MODEL_LABEL_NUM, 3)); | EXPECT_TRUE(AttrUtils::SetInt(ge_model, ATTR_MODEL_LABEL_NUM, 3)); | ||||
@@ -840,7 +860,6 @@ TEST_F(UtestDavinciModel, label_task_success) { | |||||
EXPECT_EQ(model.output_addrs_list_.size(), 0); | EXPECT_EQ(model.output_addrs_list_.size(), 0); | ||||
EXPECT_EQ(model.task_list_.size(), 5); | EXPECT_EQ(model.task_list_.size(), 5); | ||||
} | } | ||||
*/ | |||||
TEST_F(UtestDavinciModel, LoadWithQueue_fail_with_diff_args) { | TEST_F(UtestDavinciModel, LoadWithQueue_fail_with_diff_args) { | ||||
DavinciModel model(0, nullptr); | DavinciModel model(0, nullptr); | ||||
@@ -15,20 +15,17 @@ | |||||
*/ | */ | ||||
#include <gtest/gtest.h> | #include <gtest/gtest.h> | ||||
#include <map> | |||||
#include "common/debug/log.h" | |||||
#include "common/types.h" | |||||
#include "graph/utils/graph_utils.h" | |||||
#define private public | #define private public | ||||
#define protected public | #define protected public | ||||
#include "graph/load/model_manager/model_manager.h" | #include "graph/load/model_manager/model_manager.h" | ||||
#include "common/helper/om_file_helper.h" | #include "common/helper/om_file_helper.h" | ||||
#include "graph/utils/graph_utils.h" | |||||
#include "graph/debug/ge_attr_define.h" | |||||
#include "common/op/ge_op_utils.h" | #include "common/op/ge_op_utils.h" | ||||
#include "graph/load/graph_loader.h" | #include "graph/load/graph_loader.h" | ||||
#include "graph/load/model_manager/davinci_model.h" | #include "graph/load/model_manager/davinci_model.h" | ||||
#include "graph/load/model_manager/davinci_model_parser.h" | #include "graph/load/model_manager/davinci_model_parser.h" | ||||
#undef private | |||||
#undef protected | |||||
using namespace std; | using namespace std; | ||||
using namespace testing; | using namespace testing; | ||||
@@ -39,20 +36,20 @@ const static std::string ENC_KEY = "0123456789abcdef0123456789abcdef0123456789ab | |||||
class UtestModelManagerModelManager : public testing::Test { | class UtestModelManagerModelManager : public testing::Test { | ||||
protected: | protected: | ||||
static Status LoadStub(const uint8_t *data, size_t len, ge::Model &model) { | |||||
static Status LoadStub(const uint8_t *data, size_t len, Model &model) { | |||||
InitModelDefault(model); | InitModelDefault(model); | ||||
return ge::SUCCESS; | |||||
return SUCCESS; | |||||
} | } | ||||
static void InitModelDefault(ge::Model &model) { | |||||
ge::AttrUtils::SetInt(&model, ge::ATTR_MODEL_MEMORY_SIZE, 0); | |||||
ge::AttrUtils::SetInt(&model, ge::ATTR_MODEL_WEIGHT_SIZE, 0); | |||||
ge::AttrUtils::SetInt(&model, ge::ATTR_MODEL_STREAM_NUM, 0); | |||||
ge::AttrUtils::SetInt(&model, ge::ATTR_MODEL_EVENT_NUM, 0); | |||||
ge::AttrUtils::SetStr(&model, ge::ATTR_MODEL_TARGET_TYPE, "MINI"); // domi::MINI | |||||
static void InitModelDefault(Model &model) { | |||||
AttrUtils::SetInt(&model, ATTR_MODEL_MEMORY_SIZE, 0); | |||||
AttrUtils::SetInt(&model, ATTR_MODEL_WEIGHT_SIZE, 0); | |||||
AttrUtils::SetInt(&model, ATTR_MODEL_STREAM_NUM, 0); | |||||
AttrUtils::SetInt(&model, ATTR_MODEL_EVENT_NUM, 0); | |||||
AttrUtils::SetStr(&model, ATTR_MODEL_TARGET_TYPE, "MINI"); // domi::MINI | |||||
auto computeGraph = std::make_shared<ge::ComputeGraph>("graph"); | |||||
auto graph = ge::GraphUtils::CreateGraphFromComputeGraph(computeGraph); | |||||
auto computeGraph = std::make_shared<ComputeGraph>("graph"); | |||||
auto graph = GraphUtils::CreateGraphFromComputeGraph(computeGraph); | |||||
model.SetGraph(graph); | model.SetGraph(graph); | ||||
} | } | ||||
@@ -60,9 +57,8 @@ class UtestModelManagerModelManager : public testing::Test { | |||||
void TearDown() {} | void TearDown() {} | ||||
void GenUnencryptModelData(ge::ModelData &data) { | |||||
void GenUnencryptModelData(ModelData &data) { | |||||
const int model_len = 10; | const int model_len = 10; | ||||
data.key; | |||||
data.model_len = sizeof(ModelFileHeader) + model_len; | data.model_len = sizeof(ModelFileHeader) + model_len; | ||||
data.model_data = new uint8_t[data.model_len]; | data.model_data = new uint8_t[data.model_len]; | ||||
memset((uint8_t *)data.model_data + sizeof(ModelFileHeader), 10, model_len); | memset((uint8_t *)data.model_data + sizeof(ModelFileHeader), 10, model_len); | ||||
@@ -75,7 +71,7 @@ class UtestModelManagerModelManager : public testing::Test { | |||||
header->is_checksum = ModelCheckType::CHECK; | header->is_checksum = ModelCheckType::CHECK; | ||||
} | } | ||||
void GenEncryptModelData(ge::ModelData &data) { | |||||
void GenEncryptModelData(ModelData &data) { | |||||
const int model_len = 10; | const int model_len = 10; | ||||
data.key = ENC_KEY; | data.key = ENC_KEY; | ||||
data.model_data = new uint8_t[data.model_len]; | data.model_data = new uint8_t[data.model_len]; | ||||
@@ -88,91 +84,152 @@ class UtestModelManagerModelManager : public testing::Test { | |||||
header->length = 10; // encrypt_len; | header->length = 10; // encrypt_len; | ||||
} | } | ||||
void LoadStandardModelData(ge::ModelData &data) { | |||||
static const std::string STANDARD_MODEL_DATA_PATH = | |||||
"llt/framework/domi/ut/ome/test/data/standard_partition_model.txt"; | |||||
ge::proto::ModelDef model_def; | |||||
ReadProtoFromText(STANDARD_MODEL_DATA_PATH.c_str(), &model_def); | |||||
data.model_len = model_def.ByteSizeLong(); | |||||
void LoadStandardModelData(ModelData &data) { | |||||
data.model_len = 512; | |||||
data.model_data = new uint8_t[data.model_len]; | data.model_data = new uint8_t[data.model_len]; | ||||
model_def.SerializePartialToArray(data.model_data, data.model_len); | |||||
uint8_t *model_data = reinterpret_cast<uint8_t *>(data.model_data); | |||||
uint32_t mem_offset = sizeof(ModelFileHeader); | |||||
ModelPartitionTable *partition_table = reinterpret_cast<ModelPartitionTable *>(model_data + mem_offset); | |||||
partition_table->num = PARTITION_SIZE; | |||||
mem_offset += sizeof(ModelPartitionTable) + sizeof(ModelPartitionMemInfo) * 5; | |||||
{ | |||||
Model model; | |||||
ComputeGraphPtr graph = make_shared<ComputeGraph>("default"); | |||||
model.SetGraph(GraphUtils::CreateGraphFromComputeGraph(graph)); | |||||
model.SetVersion(123); | |||||
Buffer buffer; | |||||
model.Save(buffer); | |||||
EXPECT_TRUE(mem_offset + buffer.GetSize() < 512); | |||||
memcpy(model_data + mem_offset, buffer.GetData(), buffer.GetSize()); | |||||
ModelPartitionMemInfo &partition_info = partition_table->partition[0]; | |||||
partition_info.type = ModelPartitionType::MODEL_DEF; | |||||
partition_info.mem_size = buffer.GetSize(); | |||||
mem_offset += buffer.GetSize(); | |||||
} | |||||
{ | |||||
ModelPartitionMemInfo &partition_info = partition_table->partition[1]; | |||||
partition_info.type = ModelPartitionType::WEIGHTS_DATA; | |||||
partition_info.mem_offset = mem_offset; | |||||
partition_info.mem_size = 0; | |||||
} | |||||
{ | |||||
ModelPartitionMemInfo &partition_info = partition_table->partition[2]; | |||||
partition_info.type = ModelPartitionType::TASK_INFO; | |||||
partition_info.mem_offset = mem_offset; | |||||
partition_info.mem_size = 0; | |||||
} | |||||
{ | |||||
ModelPartitionMemInfo &partition_info = partition_table->partition[3]; | |||||
partition_info.type = ModelPartitionType::TBE_KERNELS; | |||||
partition_info.mem_offset = mem_offset; | |||||
partition_info.mem_size = 0; | |||||
} | |||||
{ | |||||
ModelPartitionMemInfo &partition_info = partition_table->partition[4]; | |||||
partition_info.type = ModelPartitionType::CUST_AICPU_KERNELS; | |||||
partition_info.mem_offset = mem_offset; | |||||
partition_info.mem_size = 0; | |||||
} | |||||
EXPECT_TRUE(mem_offset < 512); | |||||
ModelFileHeader *header = new (data.model_data) ModelFileHeader; | |||||
header->length = mem_offset - sizeof(ModelFileHeader); | |||||
data.model_len = mem_offset; | |||||
} | } | ||||
}; | }; | ||||
class DModelListener : public ge::ModelListener { | |||||
class DModelListener : public ModelListener { | |||||
public: | public: | ||||
DModelListener(){}; | DModelListener(){}; | ||||
uint32_t OnComputeDone(uint32_t model_id, uint32_t data_index, uint32_t resultCode) { return 0; } | uint32_t OnComputeDone(uint32_t model_id, uint32_t data_index, uint32_t resultCode) { return 0; } | ||||
}; | }; | ||||
/*TEST_F(UtestModelManagerModelManager, case_load_incorrect_param) { | |||||
TEST_F(UtestModelManagerModelManager, case_load_incorrect_param) { | |||||
ModelManager mm; | ModelManager mm; | ||||
uint32_t model_id = 0; | uint32_t model_id = 0; | ||||
ge::ModelData model; | |||||
EXPECT_EQ(ge::FAILED, mm.LoadModelOffline(model_id, model, nullptr, nullptr)); | |||||
ge::ModelData data; | |||||
ModelData data; | |||||
// Load allow listener is null | // Load allow listener is null | ||||
EXPECT_EQ(ge::FAILED, mm.LoadModelOffline(model_id, data, nullptr, nullptr)); | |||||
EXPECT_EQ(mm.LoadModelOffline(model_id, data, nullptr, nullptr), ACL_ERROR_GE_EXEC_MODEL_DATA_SIZE_INVALID); | |||||
} | } | ||||
TEST_F(UtestModelManagerModelManager, case_load_model_len_too_short) { | TEST_F(UtestModelManagerModelManager, case_load_model_len_too_short) { | ||||
ModelManager mm; | ModelManager mm; | ||||
ge::ModelData data; | |||||
ModelData data; | |||||
data.model_len = 10; | data.model_len = 10; | ||||
data.model_data = (void *)&data; | |||||
uint32_t model_id = 1; | uint32_t model_id = 1; | ||||
EXPECT_EQ(ge::FAILED, mm.LoadModelOffline(model_id, data, UTEST_CALL_BACK_FUN, nullptr)); | |||||
EXPECT_EQ(mm.LoadModelOffline(model_id, data, nullptr, nullptr), ACL_ERROR_GE_PARAM_INVALID); | |||||
data.model_data = nullptr; | |||||
} | } | ||||
TEST_F(UtestModelManagerModelManager, case_load_model_len_not_match) { | TEST_F(UtestModelManagerModelManager, case_load_model_len_not_match) { | ||||
ModelManager mm; | ModelManager mm; | ||||
ge::ModelData data; | |||||
ModelData data; | |||||
GenUnencryptModelData(data); | GenUnencryptModelData(data); | ||||
data.model_len = sizeof(ModelFileHeader) + 1; | data.model_len = sizeof(ModelFileHeader) + 1; | ||||
uint32_t model_id = 1; | uint32_t model_id = 1; | ||||
EXPECT_EQ(ge::FAILED, mm.LoadModelOffline(model_id, data, UTEST_CALL_BACK_FUN, nullptr)); | |||||
EXPECT_EQ(mm.LoadModelOffline(model_id, data, nullptr, nullptr), ACL_ERROR_GE_PARAM_INVALID); | |||||
delete[](uint8_t *) data.model_data; | delete[](uint8_t *) data.model_data; | ||||
} | } | ||||
TEST_F(UtestModelManagerModelManager, case_load_model_encypt_not_match) { | TEST_F(UtestModelManagerModelManager, case_load_model_encypt_not_match) { | ||||
ModelManager mm; | ModelManager mm; | ||||
ge::ModelData data; | |||||
ModelData data; | |||||
GenUnencryptModelData(data); | GenUnencryptModelData(data); | ||||
data.key = ENC_KEY; | data.key = ENC_KEY; | ||||
uint32_t model_id = 1; | uint32_t model_id = 1; | ||||
EXPECT_EQ(ge::PARAM_INVALID, mm.LoadModelOffline(model_id, data, UTEST_CALL_BACK_FUN, nullptr)); | |||||
EXPECT_EQ(mm.LoadModelOffline(model_id, data, nullptr, nullptr), ACL_ERROR_GE_PARAM_INVALID); | |||||
delete[](uint8_t *) data.model_data; | delete[](uint8_t *) data.model_data; | ||||
} | } | ||||
TEST_F(UtestModelManagerModelManager, case_load_model_encypt_type_unsupported) { | TEST_F(UtestModelManagerModelManager, case_load_model_encypt_type_unsupported) { | ||||
ModelManager mm; | ModelManager mm; | ||||
ge::ModelData data; | |||||
ModelData data; | |||||
GenUnencryptModelData(data); | GenUnencryptModelData(data); | ||||
ModelFileHeader *header = (ModelFileHeader *)data.model_data; | ModelFileHeader *header = (ModelFileHeader *)data.model_data; | ||||
header->is_encrypt = 255; | header->is_encrypt = 255; | ||||
uint32_t model_id = 1; | uint32_t model_id = 1; | ||||
EXPECT_EQ(ge::FAILED, mm.LoadModelOffline(model_id, data, UTEST_CALL_BACK_FUN, nullptr)); | |||||
EXPECT_EQ(mm.LoadModelOffline(model_id, data, nullptr, nullptr), ACL_ERROR_GE_PARAM_INVALID); | |||||
delete[](uint8_t *) data.model_data; | |||||
} | |||||
TEST_F(UtestModelManagerModelManager, case_load_model_data_success) { | |||||
ModelData data; | |||||
LoadStandardModelData(data); | |||||
uint32_t model_id = 1; | |||||
ModelManager mm; | |||||
EXPECT_EQ(mm.LoadModelOffline(model_id, data, nullptr, nullptr), SUCCESS); | |||||
delete[](uint8_t *) data.model_data; | delete[](uint8_t *) data.model_data; | ||||
} | } | ||||
/* | |||||
shared_ptr<ModelListener> LabelCallBack(new DModelListener()); | shared_ptr<ModelListener> LabelCallBack(new DModelListener()); | ||||
// test HandleCommand | // test HandleCommand | ||||
TEST_F(UtestModelManagerModelManager, command_success1) { | TEST_F(UtestModelManagerModelManager, command_success1) { | ||||
ModelManager manager; | ModelManager manager; | ||||
ge::Command cmd; | |||||
Command cmd; | |||||
cmd.cmd_type = "INFERENCE"; | cmd.cmd_type = "INFERENCE"; | ||||
EXPECT_EQ(ge::PARAM_INVALID, manager.HandleCommand(cmd)); | |||||
EXPECT_EQ(PARAM_INVALID, manager.HandleCommand(cmd)); | |||||
cmd.cmd_type = "NOT SUPPORT"; | cmd.cmd_type = "NOT SUPPORT"; | ||||
EXPECT_EQ(ge::PARAM_INVALID, manager.HandleCommand(cmd)); | |||||
EXPECT_EQ(PARAM_INVALID, manager.HandleCommand(cmd)); | |||||
} | } | ||||
TEST_F(UtestModelManagerModelManager, command_success2) { | TEST_F(UtestModelManagerModelManager, command_success2) { | ||||
ModelManager manager; | ModelManager manager; | ||||
ge::Command cmd; | |||||
Command cmd; | |||||
cmd.cmd_type = "dump"; | cmd.cmd_type = "dump"; | ||||
cmd.cmd_params.push_back("status"); | cmd.cmd_params.push_back("status"); | ||||
@@ -184,101 +241,101 @@ TEST_F(UtestModelManagerModelManager, command_success2) { | |||||
cmd.cmd_params.push_back("layer"); | cmd.cmd_params.push_back("layer"); | ||||
cmd.cmd_params.push_back("layer1"); | cmd.cmd_params.push_back("layer1"); | ||||
EXPECT_EQ(ge::SUCCESS, manager.HandleCommand(cmd)); | |||||
EXPECT_EQ(SUCCESS, manager.HandleCommand(cmd)); | |||||
} | } | ||||
// test profile | // test profile | ||||
TEST_F(UtestModelManagerModelManager, command_profile_success) { | TEST_F(UtestModelManagerModelManager, command_profile_success) { | ||||
ModelManager manager; | ModelManager manager; | ||||
ge::Command cmd; | |||||
Command cmd; | |||||
cmd.cmd_type = "profile"; | cmd.cmd_type = "profile"; | ||||
cmd.cmd_params.push_back("ome"); | cmd.cmd_params.push_back("ome"); | ||||
cmd.cmd_params.push_back("on"); | cmd.cmd_params.push_back("on"); | ||||
EXPECT_EQ(ge::SUCCESS, manager.HandleCommand(cmd)); | |||||
EXPECT_EQ(SUCCESS, manager.HandleCommand(cmd)); | |||||
bool ome_profile_on = PropertiesManager::Instance().GetPropertyValue(OME_PROFILE) == "1"; | bool ome_profile_on = PropertiesManager::Instance().GetPropertyValue(OME_PROFILE) == "1"; | ||||
EXPECT_EQ(true, ome_profile_on); | EXPECT_EQ(true, ome_profile_on); | ||||
cmd.cmd_params.clear(); | cmd.cmd_params.clear(); | ||||
cmd.cmd_params.push_back("ome"); | cmd.cmd_params.push_back("ome"); | ||||
cmd.cmd_params.push_back("off"); | cmd.cmd_params.push_back("off"); | ||||
EXPECT_EQ(ge::SUCCESS, manager.HandleCommand(cmd)); | |||||
EXPECT_EQ(SUCCESS, manager.HandleCommand(cmd)); | |||||
ome_profile_on = PropertiesManager::Instance().GetPropertyValue(OME_PROFILE) == "1"; | ome_profile_on = PropertiesManager::Instance().GetPropertyValue(OME_PROFILE) == "1"; | ||||
EXPECT_FALSE(ome_profile_on); | EXPECT_FALSE(ome_profile_on); | ||||
cmd.cmd_params.clear(); | cmd.cmd_params.clear(); | ||||
cmd.cmd_params.push_back("cce"); | cmd.cmd_params.push_back("cce"); | ||||
cmd.cmd_params.push_back("on"); | cmd.cmd_params.push_back("on"); | ||||
EXPECT_EQ(ge::SUCCESS, manager.HandleCommand(cmd)); | |||||
EXPECT_EQ(SUCCESS, manager.HandleCommand(cmd)); | |||||
bool cce_profile_on = PropertiesManager::Instance().GetPropertyValue(CCE_PROFILE) == "1"; | bool cce_profile_on = PropertiesManager::Instance().GetPropertyValue(CCE_PROFILE) == "1"; | ||||
EXPECT_EQ(true, cce_profile_on); | EXPECT_EQ(true, cce_profile_on); | ||||
cmd.cmd_params.clear(); | cmd.cmd_params.clear(); | ||||
cmd.cmd_params.push_back("cce"); | cmd.cmd_params.push_back("cce"); | ||||
cmd.cmd_params.push_back("off"); | cmd.cmd_params.push_back("off"); | ||||
EXPECT_EQ(ge::SUCCESS, manager.HandleCommand(cmd)); | |||||
EXPECT_EQ(SUCCESS, manager.HandleCommand(cmd)); | |||||
cce_profile_on = PropertiesManager::Instance().GetPropertyValue(CCE_PROFILE) == "1"; | cce_profile_on = PropertiesManager::Instance().GetPropertyValue(CCE_PROFILE) == "1"; | ||||
EXPECT_FALSE(cce_profile_on); | EXPECT_FALSE(cce_profile_on); | ||||
cmd.cmd_params.clear(); | cmd.cmd_params.clear(); | ||||
cmd.cmd_params.push_back("runtime"); | cmd.cmd_params.push_back("runtime"); | ||||
cmd.cmd_params.push_back("on"); | cmd.cmd_params.push_back("on"); | ||||
EXPECT_EQ(ge::SUCCESS, manager.HandleCommand(cmd)); | |||||
EXPECT_EQ(SUCCESS, manager.HandleCommand(cmd)); | |||||
bool rts_profile_on = PropertiesManager::Instance().GetPropertyValue(RTS_PROFILE) == "1"; | bool rts_profile_on = PropertiesManager::Instance().GetPropertyValue(RTS_PROFILE) == "1"; | ||||
EXPECT_EQ(true, rts_profile_on); | EXPECT_EQ(true, rts_profile_on); | ||||
cmd.cmd_params.clear(); | cmd.cmd_params.clear(); | ||||
cmd.cmd_params.push_back("runtime"); | cmd.cmd_params.push_back("runtime"); | ||||
cmd.cmd_params.push_back("off"); | cmd.cmd_params.push_back("off"); | ||||
EXPECT_EQ(ge::SUCCESS, manager.HandleCommand(cmd)); | |||||
EXPECT_EQ(SUCCESS, manager.HandleCommand(cmd)); | |||||
rts_profile_on = PropertiesManager::Instance().GetPropertyValue(RTS_PROFILE) == "1"; | rts_profile_on = PropertiesManager::Instance().GetPropertyValue(RTS_PROFILE) == "1"; | ||||
EXPECT_FALSE(rts_profile_on); | EXPECT_FALSE(rts_profile_on); | ||||
cmd.cmd_params.clear(); | cmd.cmd_params.clear(); | ||||
cmd.cmd_params.push_back("profiler_jobctx"); | cmd.cmd_params.push_back("profiler_jobctx"); | ||||
cmd.cmd_params.push_back("jobctx"); | cmd.cmd_params.push_back("jobctx"); | ||||
EXPECT_EQ(ge::SUCCESS, manager.HandleCommand(cmd)); | |||||
EXPECT_EQ(SUCCESS, manager.HandleCommand(cmd)); | |||||
EXPECT_EQ("jobctx", PropertiesManager::Instance().GetPropertyValue(PROFILER_JOBCTX)); | EXPECT_EQ("jobctx", PropertiesManager::Instance().GetPropertyValue(PROFILER_JOBCTX)); | ||||
cmd.cmd_params.clear(); | cmd.cmd_params.clear(); | ||||
cmd.cmd_params.push_back("profiler_target_path"); | cmd.cmd_params.push_back("profiler_target_path"); | ||||
cmd.cmd_params.push_back("/test/target"); | cmd.cmd_params.push_back("/test/target"); | ||||
EXPECT_EQ(ge::SUCCESS, manager.HandleCommand(cmd)); | |||||
EXPECT_EQ(SUCCESS, manager.HandleCommand(cmd)); | |||||
EXPECT_EQ("/test/target", PropertiesManager::Instance().GetPropertyValue(PROFILER_TARGET_PATH)); | EXPECT_EQ("/test/target", PropertiesManager::Instance().GetPropertyValue(PROFILER_TARGET_PATH)); | ||||
cmd.cmd_params.clear(); | cmd.cmd_params.clear(); | ||||
cmd.cmd_params.push_back("RTS_PATH"); | cmd.cmd_params.push_back("RTS_PATH"); | ||||
cmd.cmd_params.push_back("/test/rts_path"); | cmd.cmd_params.push_back("/test/rts_path"); | ||||
EXPECT_EQ(ge::SUCCESS, manager.HandleCommand(cmd)); | |||||
EXPECT_EQ(SUCCESS, manager.HandleCommand(cmd)); | |||||
EXPECT_EQ("/test/rts_path", PropertiesManager::Instance().GetPropertyValue(RTS_PROFILE_PATH)); | EXPECT_EQ("/test/rts_path", PropertiesManager::Instance().GetPropertyValue(RTS_PROFILE_PATH)); | ||||
} | } | ||||
// test acl profiling | // test acl profiling | ||||
TEST_F(UtestModelManagerModelManager, command_profiling) { | TEST_F(UtestModelManagerModelManager, command_profiling) { | ||||
ModelManager manager; | ModelManager manager; | ||||
ge::Command cmd; | |||||
Command cmd; | |||||
cmd.cmd_type = "profiling"; | cmd.cmd_type = "profiling"; | ||||
cmd.cmd_params.push_back("config"); | cmd.cmd_params.push_back("config"); | ||||
cmd.cmd_params.push_back("on"); | cmd.cmd_params.push_back("on"); | ||||
EXPECT_EQ(ge::SUCCESS, manager.HandleCommand(cmd)); | |||||
EXPECT_EQ(SUCCESS, manager.HandleCommand(cmd)); | |||||
} | } | ||||
TEST_F(UtestModelManagerModelManager, command_profile_failed) { | TEST_F(UtestModelManagerModelManager, command_profile_failed) { | ||||
ModelManager manager; | ModelManager manager; | ||||
ge::Command cmd; | |||||
Command cmd; | |||||
cmd.cmd_type = "profile"; | cmd.cmd_type = "profile"; | ||||
cmd.cmd_params.push_back("ome"); | cmd.cmd_params.push_back("ome"); | ||||
EXPECT_EQ(ge::PARAM_INVALID, manager.HandleCommand(cmd)); | |||||
EXPECT_EQ(PARAM_INVALID, manager.HandleCommand(cmd)); | |||||
} | } | ||||
// test Start | // test Start | ||||
TEST_F(UtestModelManagerModelManager, start_fail) { | TEST_F(UtestModelManagerModelManager, start_fail) { | ||||
ModelManager manager; | ModelManager manager; | ||||
manager.model_map_[2] = nullptr; | manager.model_map_[2] = nullptr; | ||||
EXPECT_EQ(ge::PARAM_INVALID, manager.Start(2)); | |||||
EXPECT_EQ(PARAM_INVALID, manager.Start(2)); | |||||
} | } | ||||
// test GetMaxUsedMemory | // test GetMaxUsedMemory | ||||
@@ -286,7 +343,7 @@ TEST_F(UtestModelManagerModelManager, get_max_used_memory_fail) { | |||||
ModelManager manager; | ModelManager manager; | ||||
uint64_t max_size = 0; | uint64_t max_size = 0; | ||||
manager.model_map_[2] = nullptr; | manager.model_map_[2] = nullptr; | ||||
EXPECT_EQ(ge::PARAM_INVALID, manager.GetMaxUsedMemory(2, max_size)); | |||||
EXPECT_EQ(PARAM_INVALID, manager.GetMaxUsedMemory(2, max_size)); | |||||
} | } | ||||
// test GetInputOutputDescInfo | // test GetInputOutputDescInfo | ||||
@@ -295,7 +352,7 @@ TEST_F(UtestModelManagerModelManager, get_input_output_desc_info_fail) { | |||||
manager.model_map_[2] = nullptr; | manager.model_map_[2] = nullptr; | ||||
vector<InputOutputDescInfo> input_shape; | vector<InputOutputDescInfo> input_shape; | ||||
vector<InputOutputDescInfo> output_shape; | vector<InputOutputDescInfo> output_shape; | ||||
EXPECT_EQ(ge::PARAM_INVALID, manager.GetInputOutputDescInfo(2, input_shape, output_shape)); | |||||
EXPECT_EQ(PARAM_INVALID, manager.GetInputOutputDescInfo(2, input_shape, output_shape)); | |||||
} | } | ||||
@@ -306,7 +363,7 @@ TEST_F(UtestModelManagerModelManager, get_input_output_desc_info_zero_copy_fail) | |||||
manager.model_map_[2] = nullptr; | manager.model_map_[2] = nullptr; | ||||
vector<InputOutputDescInfo> input_shape; | vector<InputOutputDescInfo> input_shape; | ||||
vector<InputOutputDescInfo> output_shape; | vector<InputOutputDescInfo> output_shape; | ||||
EXPECT_EQ(ge::PARAM_INVALID, manager.GetInputOutputDescInfoForZeroCopy(2, input_shape, output_shape)); | |||||
EXPECT_EQ(PARAM_INVALID, manager.GetInputOutputDescInfoForZeroCopy(2, input_shape, output_shape)); | |||||
} | } | ||||
*//* | *//* | ||||
@@ -314,7 +371,7 @@ TEST_F(UtestModelManagerModelManager, get_input_output_desc_info_zero_copy_fail) | |||||
TEST_F(UtestModelManagerModelManager, stop_fail) { | TEST_F(UtestModelManagerModelManager, stop_fail) { | ||||
ModelManager manager; | ModelManager manager; | ||||
manager.model_map_[2] = nullptr; | manager.model_map_[2] = nullptr; | ||||
EXPECT_EQ(ge::PARAM_INVALID, manager.Stop(2)); | |||||
EXPECT_EQ(PARAM_INVALID, manager.Stop(2)); | |||||
} | } | ||||
// build input_data | // build input_data | ||||
@@ -322,8 +379,8 @@ TEST_F(UtestModelManagerModelManager, check_data_len_success) { | |||||
shared_ptr<ModelListener> g_label_call_back(new DModelListener()); | shared_ptr<ModelListener> g_label_call_back(new DModelListener()); | ||||
DavinciModel model(0, g_label_call_back); | DavinciModel model(0, g_label_call_back); | ||||
ModelManager model_manager; | ModelManager model_manager; | ||||
ge::InputData input_data; | |||||
ge::DataBuffer data_buffer; | |||||
InputData input_data; | |||||
DataBuffer data_buffer; | |||||
data_buffer.data = new char[51200]; | data_buffer.data = new char[51200]; | ||||
data_buffer.length = 51200; | data_buffer.length = 51200; | ||||
input_data.index = 0; | input_data.index = 0; | ||||
@@ -353,6 +410,6 @@ TEST_F(UtestModelManagerModelManager, test_data_input_tensor) { | |||||
vector<InputTensorInfo> inputs; | vector<InputTensorInfo> inputs; | ||||
inputs.emplace_back(input_tensor); | inputs.emplace_back(input_tensor); | ||||
auto ret = mm.DataInputTensor(model_id,inputs); | auto ret = mm.DataInputTensor(model_id,inputs); | ||||
EXPECT_EQ(ge::UNSUPPORTED, ret); | |||||
EXPECT_EQ(UNSUPPORTED, ret); | |||||
} | } | ||||
} // namespace ge | } // namespace ge |
@@ -33,7 +33,7 @@ class UtestOmg : public testing::Test { | |||||
TEST_F(UtestOmg, display_model_info_failed) { | TEST_F(UtestOmg, display_model_info_failed) { | ||||
ge::proto::ModelDef model_def; | ge::proto::ModelDef model_def; | ||||
PrintModelInfo(&model_def); | |||||
PrintModelInfo(&model_def, 1); | |||||
} | } | ||||
TEST_F(UtestOmg, display_model_info_success) { | TEST_F(UtestOmg, display_model_info_success) { | ||||
@@ -46,7 +46,6 @@ TEST_F(UtestOmg, display_model_info_success) { | |||||
attr_def->mutable_list()->add_i(2); | attr_def->mutable_list()->add_i(2); | ||||
attr_def->mutable_list()->add_i(3); | attr_def->mutable_list()->add_i(3); | ||||
attr_def->mutable_list()->add_i(4); | attr_def->mutable_list()->add_i(4); | ||||
attr_def->mutable_list()->add_i(5); | |||||
PrintModelInfo(&model_def); | |||||
PrintModelInfo(&model_def, 1); | |||||
} | } | ||||
} // namespace ge | } // namespace ge |