mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-06 09:07:10 +08:00
【Hackthon_4th 180】Support HORIZON BPU Backend for FastDeploy (#1822)
* add horizon backend and PPYOLOE examples * 更改horizon头文件编码规范 * 更改horizon头文件编码规范 * 更改horizon头文件编码规范 * 增加horizon packages下载及自动安装 * Add UseHorizonNPUBackend Method * 删除编译FD SDK后多余的头文件,同时更改部分规范 * Update horizon.md * Update horizon.md --------- Co-authored-by: DefTruth <31974251+DefTruth@users.noreply.github.com>
This commit is contained in:
@@ -77,6 +77,7 @@ bool FastDeployModel::InitRuntimeWithSpecifiedBackend() {
|
||||
bool use_gpu = (runtime_option.device == Device::GPU);
|
||||
bool use_ipu = (runtime_option.device == Device::IPU);
|
||||
bool use_rknpu = (runtime_option.device == Device::RKNPU);
|
||||
bool use_horizon = (runtime_option.device == Device::SUNRISENPU);
|
||||
bool use_sophgotpu = (runtime_option.device == Device::SOPHGOTPUD);
|
||||
bool use_timvx = (runtime_option.device == Device::TIMVX);
|
||||
bool use_ascend = (runtime_option.device == Device::ASCEND);
|
||||
@@ -97,6 +98,13 @@ bool FastDeployModel::InitRuntimeWithSpecifiedBackend() {
|
||||
<< " is not supported." << std::endl;
|
||||
return false;
|
||||
}
|
||||
} else if (use_horizon) {
|
||||
if (!IsSupported(valid_horizon_backends, runtime_option.backend)) {
|
||||
FDERROR << "The valid horizon backends of model " << ModelName()
|
||||
<< " are " << Str(valid_horizon_backends) << ", "
|
||||
<< runtime_option.backend << " is not supported." << std::endl;
|
||||
return false;
|
||||
}
|
||||
} else if (use_sophgotpu) {
|
||||
if (!IsSupported(valid_sophgonpu_backends, runtime_option.backend)) {
|
||||
FDERROR << "The valid sophgo backends of model " << ModelName() << " are "
|
||||
@@ -169,6 +177,8 @@ bool FastDeployModel::InitRuntimeWithSpecifiedDevice() {
|
||||
#endif
|
||||
} else if (runtime_option.device == Device::RKNPU) {
|
||||
return CreateRKNPUBackend();
|
||||
} else if (runtime_option.device == Device::SUNRISENPU) {
|
||||
return CreateHorizonBackend();
|
||||
} else if (runtime_option.device == Device::TIMVX) {
|
||||
return CreateTimVXBackend();
|
||||
} else if (runtime_option.device == Device::ASCEND) {
|
||||
@@ -188,9 +198,9 @@ bool FastDeployModel::InitRuntimeWithSpecifiedDevice() {
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
FDERROR
|
||||
<< "Only support CPU/GPU/IPU/RKNPU/TIMVX/KunlunXin/ASCEND/DirectML now."
|
||||
<< std::endl;
|
||||
FDERROR << "Only support "
|
||||
"CPU/GPU/IPU/RKNPU/HORIZONNPU/TIMVX/KunlunXin/ASCEND/DirectML now."
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -278,6 +288,28 @@ bool FastDeployModel::CreateRKNPUBackend() {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FastDeployModel::CreateHorizonBackend() {
|
||||
if (valid_horizon_backends.empty()) {
|
||||
FDERROR << "There's no valid npu backends for model: " << ModelName()
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
for (size_t i = 0; i < valid_horizon_backends.size(); ++i) {
|
||||
if (!IsBackendAvailable(valid_horizon_backends[i])) {
|
||||
continue;
|
||||
}
|
||||
runtime_option.backend = valid_horizon_backends[i];
|
||||
runtime_ = std::unique_ptr<Runtime>(new Runtime());
|
||||
if (!runtime_->Init(runtime_option)) {
|
||||
return false;
|
||||
}
|
||||
runtime_initialized_ = true;
|
||||
return true;
|
||||
}
|
||||
FDERROR << "Cannot find an available npu backend to load this model."
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
bool FastDeployModel::CreateSophgoNPUBackend() {
|
||||
if (valid_sophgonpu_backends.empty()) {
|
||||
FDERROR << "There's no valid npu backends for model: " << ModelName()
|
||||
|
Reference in New Issue
Block a user