mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-11-03 02:53:26 +08:00
Merge branch 'develop' of https://github.com/paddlepaddle/fastdeploy into set_stream_infer-shareExData
This commit is contained in:
@@ -51,8 +51,9 @@ void LiteBackend::ConfigureCpu(const LiteBackendOption& option) {
|
||||
|
||||
void LiteBackend::ConfigureKunlunXin(const LiteBackendOption& option) {
|
||||
std::vector<paddle::lite_api::Place> valid_places;
|
||||
valid_places.push_back(
|
||||
paddle::lite_api::Place{TARGET(kXPU), PRECISION(kInt8)});
|
||||
// TODO(yeliang): Placing kInt8 first may cause accuracy issues of some model
|
||||
// valid_places.push_back(
|
||||
// paddle::lite_api::Place{TARGET(kXPU), PRECISION(kInt8)});
|
||||
if (option.enable_fp16) {
|
||||
valid_places.push_back(
|
||||
paddle::lite_api::Place{TARGET(kXPU), PRECISION(kFP16)});
|
||||
|
||||
@@ -32,7 +32,7 @@ class LiteBackend : public BaseBackend {
|
||||
LiteBackend() {}
|
||||
virtual ~LiteBackend() = default;
|
||||
|
||||
bool Init(const RuntimeOption& option);
|
||||
bool Init(const RuntimeOption& option) override;
|
||||
|
||||
bool Infer(std::vector<FDTensor>& inputs,
|
||||
std::vector<FDTensor>* outputs,
|
||||
|
||||
@@ -75,6 +75,16 @@ struct PaddleBackendOption {
|
||||
delete_pass_names.push_back(pass_name);
|
||||
}
|
||||
|
||||
void SetIpuConfig(bool enable_fp16, int replica_num,
|
||||
float available_memory_proportion,
|
||||
bool enable_half_partial) {
|
||||
ipu_option.ipu_enable_fp16 = enable_fp16;
|
||||
ipu_option.ipu_replica_num = replica_num;
|
||||
ipu_option.ipu_available_memory_proportion =
|
||||
available_memory_proportion;
|
||||
ipu_option.ipu_enable_half_partial = enable_half_partial;
|
||||
}
|
||||
|
||||
// The belowing parameters may be removed, please do not
|
||||
// read or write them directly
|
||||
TrtBackendOption trt_option;
|
||||
|
||||
@@ -47,7 +47,8 @@ void BindPaddleOption(pybind11::module& m) {
|
||||
.def_readwrite("gpu_mem_init_size",
|
||||
&PaddleBackendOption::gpu_mem_init_size)
|
||||
.def("disable_trt_ops", &PaddleBackendOption::DisableTrtOps)
|
||||
.def("delete_pass", &PaddleBackendOption::DeletePass);
|
||||
.def("delete_pass", &PaddleBackendOption::DeletePass)
|
||||
.def("set_ipu_config", &PaddleBackendOption::SetIpuConfig);
|
||||
}
|
||||
|
||||
} // namespace fastdeploy
|
||||
|
||||
@@ -45,7 +45,10 @@ void PaddleBackend::BuildOption(const PaddleBackendOption& option) {
|
||||
"file will save to the directory where paddle model saved."
|
||||
<< std::endl;
|
||||
use_static = true;
|
||||
config_.SetOptimCacheDir(option.trt_option.serialize_file);
|
||||
std::string opt_cache_dir =
|
||||
GetDirFromPath(option.trt_option.serialize_file);
|
||||
|
||||
config_.SetOptimCacheDir(opt_cache_dir);
|
||||
}
|
||||
config_.EnableTensorRtEngine(option.trt_option.max_workspace_size,
|
||||
option.trt_option.max_batch_size, 20,
|
||||
|
||||
Reference in New Issue
Block a user