Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PIR] adjust pir pass log printing #60723

Merged
merged 5 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update
  • Loading branch information
yuanlehome committed Jan 10, 2024
commit 628ff043e8d2f5ca9020123435d804cd14ca142e
1 change: 1 addition & 0 deletions paddle/fluid/framework/executor_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,7 @@ std::unique_ptr<::pir::Program> ConstructBackwardIrProgram(
pm.AddPass(::pir::CreateInplacePass());
if (VLOG_IS_ON(6)) {
pm.EnableIRPrinting();
pm.EnablePrintStatistics();
}
pm.Run(res.get());
if (FLAGS_print_ir) {
Expand Down
10 changes: 9 additions & 1 deletion paddle/fluid/inference/api/analysis_predictor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -844,8 +844,16 @@ bool AnalysisPredictor::PrepareExecutor() {
if (FLAGS_pir_apply_inplace_pass) {
lowered_pm.AddPass(::pir::CreateInplacePass());
}
if (!config_.glog_info_disabled()) {
lowered_pm.EnablePrintStatistics();
}
if (config_.ir_debug_) {
lowered_pm.EnableIRPrinting();
}
lowered_pm.Run(pir_program_.get());

LOG(INFO) << "======= pir optimization completed =======";

executor_->PrepareInterpreterCore(
sub_scope_, *pir_program_, execution_config);
} else {
Expand Down Expand Up @@ -1867,7 +1875,7 @@ void AnalysisPredictor::OptimizeInferenceProgram() {
argument_.reset(nullptr);
}
#endif
LOG(INFO) << "======= optimize end =======";
LOG(INFO) << "======= ir optimization completed =======";
}

template <>
Expand Down
13 changes: 3 additions & 10 deletions paddle/pir/pass/pass.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,9 @@ class IR_API Pass {
void Set(const std::string& attr_name, AttrType* attr) {
VLOG(3) << "Setting the attribute " << attr_name << " for the pass "
<< name();
IR_ENFORCE(
!Has(attr_name), "Attribute %s already set in the %s.", attr_name);
if (Has(attr_name)) {
Erase(attr_name);
}
attrs_[attr_name] = attr;
attr_dels_[attr_name] = [attr, attr_name]() {
VLOG(8) << "deleting " << attr_name;
Expand All @@ -166,23 +167,15 @@ class IR_API Pass {
virtual bool Initialize(IrContext* context) { return true; }

void AddStatistics(int64_t match_count) {
IR_ENFORCE(!Has("__match_count__"),
"Attribute __match_count__ already set in the pass.");
Set<int64_t>("__match_count__", new int64_t{match_count});
}

void AddStatistics(int64_t match_count, int64_t all_count) {
IR_ENFORCE(!Has("__match_count__"),
"Attribute __match_count__ already set in the pass.");
IR_ENFORCE(!Has("__all_count__"),
"Attribute __all_count__ already set in the pass.");
Set<int64_t>("__match_count__", new int64_t{match_count});
Set<int64_t>("__all_count__", new int64_t{all_count});
}

void AddStatistics(const std::string& custom_log) {
IR_ENFORCE(!Has("__custom_log__"),
"Attribute __custom_log__ already set in the pass.");
Set<std::string>("__custom_log__", new std::string{custom_log});
}

Expand Down