[Unity] Ignore R.ExternFunc in EliminateCommonSubexpr#15900
Merged
Hzfengsy merged 1 commit intoapache:unityfrom Oct 11, 2023
Merged
[Unity] Ignore R.ExternFunc in EliminateCommonSubexpr#15900Hzfengsy merged 1 commit intoapache:unityfrom
Hzfengsy merged 1 commit intoapache:unityfrom
Conversation
Prior to this commit, `relax::ExternFunc` nodes would be de-duplicated as part of the `EliminateCommonSubexpr` pass. This commit instead ignores the `relax::ExternFunc` nodes, retaining the in-line definitions.
| @R.function(pure=False) | ||
| def foo(x: R.Tensor((2, 3), dtype="float32")): | ||
| y = R.call_packed("extern_func_name", x, sinfo_args=R.Tensor([2, 3])) | ||
| z = R.call_packed("extern_func_name", y, sinfo_args=R.Tensor([2, 3])) |
Contributor
There was a problem hiding this comment.
If this was commoned before, then something else is probably wrong. This is equivalent to extern_func(extern_func(x)), so there is no opportunity to common anything even if the external function was known to be pure.
Contributor
Author
There was a problem hiding this comment.
Previously, it wasn't a computational step that was being extracted as the common subexpression, but the R.ExternFunc object itself.
@I.ir_module
class Module:
@R.function(pure=False)
def foo(x: R.Tensor((2, 3), dtype="float32")):
gv = R.ExternFunc("extern_func_name")
y = gv(x, sinfo_args=(R.Tensor((2, 3)),))
z = gv(y, sinfo_args=(R.Tensor((2, 3)),))
return z
Contributor
There was a problem hiding this comment.
I see. Yeah, that seems unnecessary.
kparzysz-quic
approved these changes
Oct 9, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prior to this commit,
relax::ExternFuncnodes would be de-duplicated as part of theEliminateCommonSubexprpass. This commit instead ignores therelax::ExternFuncnodes, retaining the in-line definitions.