| 23 | namespace jit { |
| 24 | |
| 25 | PredictorEngine::PredictorEngine( |
| 26 | const std::shared_ptr<FunctionInfo> &info, |
| 27 | const std::shared_ptr<VariableMap> ¶ms_dict, |
| 28 | const Place &place) |
| 29 | : info_(info), |
| 30 | params_dict_(params_dict), |
| 31 | scope_(new framework::Scope()), |
| 32 | place_(place) { |
| 33 | utils::ShareParamsIntoScope(info_->ParamNames(), params_dict_, scope_.get()); |
| 34 | VLOG(6) << framework::GenScopeTreeDebugInfo(scope_.get()); |
| 35 | |
| 36 | // TODO(Aurelius84): Expose AnalysisConfig to user. |
| 37 | AnalysisConfig config; |
| 38 | config.SetProgFile(info->ProgramFilePath()); |
| 39 | if (phi::is_gpu_place(place_)) { |
| 40 | config.EnableUseGpu(100, place_.GetDeviceId()); |
| 41 | } else if (phi::is_cpu_place(place_)) { |
| 42 | config.DisableGpu(); |
| 43 | config.EnableONEDNN(); |
| 44 | config.EnableOnednnInt8(); |
| 45 | config.SetOnednnCacheCapacity(0); |
| 46 | } |
| 47 | config.SetSkipLoadParams(true); |
| 48 | config.SetApplyOptim(true); |
| 49 | config.SwitchIrOptim(true); |
| 50 | |
| 51 | predictor_.reset(new AnalysisPredictor(config)); |
| 52 | |
| 53 | predictor_->Init( |
| 54 | scope_, std::make_shared<framework::ProgramDesc>(info_->ProgramDesc())); |
| 55 | } |
| 56 | |
| 57 | PredictorEngine::PredictorEngine( |
| 58 | const std::shared_ptr<FunctionInfo> &info, |
nothing calls this directly
no test coverage detected