From fa890092d3040d5adb14f0e7b4d4877024d7b2af Mon Sep 17 00:00:00 2001 From: Wilber Date: Tue, 16 Aug 2022 10:36:01 +0800 Subject: [PATCH] memoptim and fp16 mixed precision (#45132) --- paddle/fluid/inference/api/analysis_predictor.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/paddle/fluid/inference/api/analysis_predictor.cc b/paddle/fluid/inference/api/analysis_predictor.cc index 9c673dfc575..a8962c61e47 100644 --- a/paddle/fluid/inference/api/analysis_predictor.cc +++ b/paddle/fluid/inference/api/analysis_predictor.cc @@ -1040,7 +1040,14 @@ void AnalysisPredictor::PrepareArgument() { argument_.SetUseFcPadding(config_.use_fc_padding()); argument_.SetGPUDeviceId(config_.gpu_device_id()); argument_.SetEnableAnalysisOptim(config_.enable_ir_optim_); - argument_.SetEnableMemoryOptim(config_.enable_memory_optim()); + if (model_precision_ == phi::DataType::FLOAT32) { + argument_.SetEnableMemoryOptim(config_.enable_memory_optim()); + } else { + // TODO(inference): mixed precision temporarily not support memory_optim + LOG_FIRST_N(WARNING, 1) << "mixed precision model temporarily not support " + "memory optim, so we just turn off that."; + argument_.SetEnableMemoryOptim(false); + } argument_.SetModelFromMemory(config_.model_from_memory_); // Analyze inference_program argument_.SetPredictorID(predictor_id_); -- GitLab