-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[Unity][Pass] Include FoldDataflowBlockOutput in CanonicalizeBindings
#15791
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
[Unity][Pass] Include FoldDataflowBlockOutput in CanonicalizeBindings
#15791
Conversation
|
Please review @sunggg @kparzysz-quic |
kparzysz-quic
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For
@tvm.script.ir_module
class Input:
@R.function
def main() -> R.Tensor((), "int32"):
with R.dataflow():
a = R.const(1)
b = a
c = b
d = c
n = d
R.output(n)
return n
the result is
@I.ir_module
class Module:
@R.function
def main() -> R.Tensor((), dtype="int32"):
with R.dataflow():
a: R.Tensor((), dtype="int32") = R.const(1, "int32")
b: R.Tensor((), dtype="int32") = a
c: R.Tensor((), dtype="int32") = a
d: R.Tensor((), dtype="int32") = a
n: R.Tensor((), dtype="int32") = a
R.output(n)
return n
The result should be
class Module:
@R.function
def main() -> R.Tensor((), dtype="int32"):
with R.dataflow():
n: R.Tensor((), dtype="int32") = R.const(1, "int32")
R.output(n)
return n
kparzysz-quic
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A more general question is whether we also want to eliminate a = b, where both are solely dataflow vars. All occurrences of a could be replaced with b.
|
I hadn't thrown in the functionality from dead code elimination, but it would probably be easy to add it, so I'll try that. |
|
It was indeed easy to throw in the extra functionality. |
416e47b to
9437e91
Compare
|
As it happens, #15840 handles the elision of unnecessary bindings, so I'll remove it from this PR. |
9437e91 to
896f464
Compare
|
@tvm-bot rerun |
|
Failed to re-run CI in https://github.com/apache/tvm/actions/runs/6397260771 Detailswith response |
kparzysz-quic
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
As discussed in certain community meetings,
FoldDataflowBlockOutputis a bit of a clumsy outlier of a pass, resulting in a cludge like #15474 to try to make it easier to use. In this PR, the functionality of that pass is included inCanonicalizeBindings(it can be done just as a further transformation onDataflowBlocks) and the separate pass is removed.