-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[Arith] Implement statistics counters for RewriteSimplifier #14532
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
Changes from 5 commits
b3b75ee
82d1068
f5c3c8d
1f949a1
60fbf77
02a0249
405eab3
2a8f181
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,13 +42,20 @@ namespace tir { | |
|
|
||
| struct RemoveNoOpConfigNode : public tvm::AttrsNode<RemoveNoOpConfigNode> { | ||
| bool use_dataflow_analysis; | ||
| int64_t max_simplification_steps; | ||
|
|
||
| TVM_DECLARE_ATTRS(RemoveNoOpConfigNode, "tir.transform.RemoveNoOpConfig") { | ||
| TVM_ATTR_FIELD(use_dataflow_analysis) | ||
| .describe( | ||
| "If true, known buffer values are propagated and used " | ||
| "to statically prove statements as no-ops.") | ||
| .set_default(false); | ||
| TVM_ATTR_FIELD(max_simplification_steps) | ||
| .describe( | ||
| "If non-zero, RewriteSimplifier will throw an error " | ||
| "after the number of steps specified. " | ||
| "For use in debug and testing purposes.") | ||
| .set_default(0); | ||
| } | ||
| }; | ||
|
|
||
|
|
@@ -316,14 +323,19 @@ Pass RemoveNoOp() { | |
|
|
||
| RemoveNoOpConfig config = ctx->GetConfig<RemoveNoOpConfig>("tir.RemoveNoOp") | ||
| .value_or(AttrsWithDefaultValues<RemoveNoOpConfig>()); | ||
|
|
||
| if (config->use_dataflow_analysis) { | ||
| touch_pattern.emplace(f->body); | ||
| touch_pattern.emplace(f->body, config->max_simplification_steps); | ||
| } | ||
|
|
||
| arith::Analyzer analyzer; | ||
| analyzer.rewrite_simplify.SetMaximumRewriteSteps(config->max_simplification_steps); | ||
|
|
||
| auto* n = f.CopyOnWrite(); | ||
| n->body = NoOpRemover::Apply(std::move(n->body), &analyzer, std::move(touch_pattern), nullptr); | ||
| { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a specific reason for adding curly braces here?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They aren't necessary for correctness here, but were added present to limit the scope of That said, the implementation no longer requires updating the signature of |
||
| auto* write_ptr = f.CopyOnWrite(); | ||
| write_ptr->body = NoOpRemover::Apply(std::move(write_ptr->body), &analyzer, | ||
| std::move(touch_pattern), nullptr); | ||
| } | ||
| return f; | ||
| }; | ||
| return CreatePrimFuncPass(pass_func, 0, "tir.RemoveNoOp", {}); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.