Skip to content

Commit e887d71

Browse files
authored
fix ir debug config (#15571)
1 parent 897789b commit e887d71

File tree

6 files changed

+16
-8
lines changed

6 files changed

+16
-8
lines changed

paddle/fluid/inference/analysis/ir_pass_manager.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ void IRPassManager::CreatePasses(Argument *argument,
8383
new std::string(GetOrCreateModelOptCacheDir(model_opt_cache_dir)));
8484
}
8585

86-
// graph_ = pass->Apply(std::move(graph_));
8786
pre_pass = pass_name;
8887

8988
passes_.emplace_back(std::move(pass));
@@ -97,8 +96,9 @@ std::unique_ptr<Graph> IRPassManager::Apply(std::unique_ptr<Graph> graph) {
9796
PADDLE_ENFORCE(graph.get());
9897
// Apply all the passes
9998
for (const auto &pass : passes_) {
100-
if (pass->Type() == "graph_viz_pass") continue;
101-
PrettyLogEndl(Style::H2(), "--- Running IR pass [%s]", pass->Type());
99+
if (pass->Type() != "graph_viz_pass") {
100+
PrettyLogEndl(Style::H2(), "--- Running IR pass [%s]", pass->Type());
101+
}
102102
graph = pass->Apply(std::move(graph));
103103
}
104104
return std::move(graph);

paddle/fluid/inference/api/analysis_config.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,4 +318,9 @@ NativeConfig AnalysisConfig::ToNativeConfig() const {
318318
return config;
319319
}
320320

321+
void AnalysisConfig::SwitchIrDebug(int x) {
322+
ir_debug_ = x;
323+
Update();
324+
}
325+
321326
} // namespace paddle

paddle/fluid/inference/api/analysis_predictor_tester.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ TEST(AnalysisPredictor, memory_optim) {
196196
AnalysisConfig config(FLAGS_dirname);
197197
config.DisableGpu();
198198
config.EnableMemoryOptim(true);
199-
config.pass_builder()->TurnOnDebug();
199+
config.SwitchIrDebug();
200200

201201
auto native_predictor =
202202
CreatePaddlePredictor<NativeConfig>(config.ToNativeConfig());

paddle/fluid/inference/api/paddle_analysis_config.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,12 @@ struct AnalysisConfig {
140140
*/
141141
bool tensorrt_engine_enabled() const { return use_tensorrt_; }
142142

143-
/** Control whther to debug IR graph analysis phase.
143+
/** \brief Control whether to debug IR graph analysis phase.
144+
*
145+
* This will generate DOT files for visualizing the computation graph after
146+
* each analysis pass applied.
144147
*/
145-
void SwitchIrDebug(int x = true) { ir_debug_ = x; }
148+
void SwitchIrDebug(int x = true);
146149

147150
/** Turn on MKLDNN.
148151
*/

paddle/fluid/inference/tests/api/analyzer_seq_pool1_tester.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ void SetConfig(AnalysisConfig *cfg, bool use_mkldnn = false) {
142142
cfg->SetModel(FLAGS_infer_model + "/model", FLAGS_infer_model + "/params");
143143
cfg->DisableGpu();
144144
cfg->SwitchSpecifyInputNames();
145-
cfg->pass_builder()->TurnOnDebug();
145+
cfg->SwitchIrDebug();
146146
cfg->SetCpuMathLibraryNumThreads(FLAGS_paddle_num_threads);
147147
if (use_mkldnn) {
148148
cfg->EnableMKLDNN();

paddle/fluid/inference/tests/api/analyzer_text_classification_tester.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void SetInput(std::vector<std::vector<PaddleTensor>> *inputs) {
6969
TEST(Analyzer_Text_Classification, profile) {
7070
AnalysisConfig cfg;
7171
SetConfig(&cfg);
72-
cfg.pass_builder()->TurnOnDebug();
72+
cfg.SwitchIrDebug();
7373
std::vector<PaddleTensor> outputs;
7474

7575
std::vector<std::vector<PaddleTensor>> input_slots_all;

0 commit comments

Comments
 (0)