mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-04 16:22:57 +08:00
[lite] add more options for lite backend (#313)
* [cmake] support Android arm64-v8a & armeabi-v7a native c++ sdk * [cmake] fixed patchelf download on mac and android * [lite] Add threads and power_mode option support * [pybind] update runtime pybind for lite power mode * [python] Add set_lite_power_mode api to runtime * [Lite] add lite enable_fp16 option support * [lite] add more options for lite backend. * [cmake] fixed Paddle Lite typo * [runtime] format LitePowerMode enum comments * [runtime] format lite option comments
This commit is contained in:
@@ -40,7 +40,21 @@ FDDataType LiteDataTypeToFD(const paddle::lite_api::PrecisionType& dtype) {
|
||||
}
|
||||
|
||||
void LiteBackend::BuildOption(const LiteBackendOption& option) {
|
||||
option_ = option;
|
||||
std::vector<paddle::lite_api::Place> valid_places;
|
||||
if (option.enable_fp16) {
|
||||
paddle::lite_api::MobileConfig check_fp16_config;
|
||||
// Determine whether the device supports the FP16
|
||||
// instruction set (or whether it is an arm device
|
||||
// of the armv8.2 architecture)
|
||||
supported_fp16_ = check_fp16_config.check_fp16_valid();
|
||||
if (supported_fp16_) {
|
||||
valid_places.push_back(
|
||||
paddle::lite_api::Place{TARGET(kARM), PRECISION(kFP16)});
|
||||
} else {
|
||||
FDWARNING << "This device is not supported fp16, will skip fp16 option.";
|
||||
}
|
||||
}
|
||||
valid_places.push_back(
|
||||
paddle::lite_api::Place{TARGET(kARM), PRECISION(kFloat)});
|
||||
config_.set_valid_places(valid_places);
|
||||
@@ -68,6 +82,11 @@ bool LiteBackend::InitFromPaddle(const std::string& model_file,
|
||||
predictor_ =
|
||||
paddle::lite_api::CreatePaddlePredictor<paddle::lite_api::CxxConfig>(
|
||||
config_);
|
||||
if (option_.optimized_model_dir != "") {
|
||||
FDINFO << "Optimzed model dir is not empty, will save optimized model to: "
|
||||
<< option_.optimized_model_dir << std::endl;
|
||||
predictor_->SaveOptimizedModel(option_.optimized_model_dir);
|
||||
}
|
||||
|
||||
inputs_desc_.clear();
|
||||
outputs_desc_.clear();
|
||||
|
Reference in New Issue
Block a user