|
|
|
@ -50,7 +50,7 @@ Record ProcessALine(const std::string &line) {
|
|
|
|
|
return record;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetConfig(AnalysisConfig *cfg) {
|
|
|
|
|
void SetConfig(AnalysisConfig *cfg, bool _use_mkldnn = FLAGS_use_MKLDNN) {
|
|
|
|
|
cfg->param_file = FLAGS_infer_model + "/__params__";
|
|
|
|
|
cfg->prog_file = FLAGS_infer_model + "/__model__";
|
|
|
|
|
cfg->use_gpu = false;
|
|
|
|
@ -59,9 +59,7 @@ void SetConfig(AnalysisConfig *cfg) {
|
|
|
|
|
cfg->specify_input_name = true;
|
|
|
|
|
// TODO(TJ): fix fusion gru
|
|
|
|
|
cfg->ir_passes.push_back("fc_gru_fuse_pass");
|
|
|
|
|
#ifdef PADDLE_WITH_MKLDNN
|
|
|
|
|
cfg->_use_mkldnn = FLAGS_use_MKLDNN;
|
|
|
|
|
#endif
|
|
|
|
|
cfg->_use_mkldnn = _use_mkldnn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetInput(std::vector<std::vector<PaddleTensor>> *inputs) {
|
|
|
|
@ -125,17 +123,19 @@ TEST(Analyzer_vis, compare) {
|
|
|
|
|
std::vector<std::vector<PaddleTensor>> input_slots_all;
|
|
|
|
|
SetInput(&input_slots_all);
|
|
|
|
|
CompareNativeAndAnalysis(cfg, input_slots_all);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Compare result of NativeConfig and AnalysisConfig with MKLDNN
|
|
|
|
|
#ifdef PADDLE_WITH_MKLDNN
|
|
|
|
|
// since default config._use_mkldnn=true in this case,
|
|
|
|
|
// we should compare analysis_outputs in config._use_mkldnn=false
|
|
|
|
|
// with native_outputs as well.
|
|
|
|
|
FLAGS_use_MKLDNN = false;
|
|
|
|
|
AnalysisConfig cfg1;
|
|
|
|
|
SetConfig(&cfg1);
|
|
|
|
|
CompareNativeAndAnalysis(cfg1, input_slots_all);
|
|
|
|
|
FLAGS_use_MKLDNN = true;
|
|
|
|
|
#endif
|
|
|
|
|
TEST(Analyzer_vis, compare_mkldnn) {
|
|
|
|
|
AnalysisConfig cfg;
|
|
|
|
|
SetConfig(&cfg, true);
|
|
|
|
|
|
|
|
|
|
std::vector<std::vector<PaddleTensor>> input_slots_all;
|
|
|
|
|
SetInput(&input_slots_all);
|
|
|
|
|
CompareNativeAndAnalysis(cfg, input_slots_all);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
} // namespace analysis
|
|
|
|
|
} // namespace inference
|
|
|
|
|