-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[Relay][Pass] CanonicalizeCast #3280
Conversation
db277fd
to
6179faf
Compare
8b599d6
to
38964db
Compare
@ZihengJiang @eqy please help to review this PR |
Can we come up with a better name and put in some docs explaining how this pass works in the text format? Tianqi wrote this example to me yesterday:
then
|
74d4e64
to
6c985db
Compare
I have updated this PR. Here are some of the alternative names in my mind: |
CanonicalizeCast seems to be a good name, @jroesch what do you think about it |
I think we should use |
I think it will always be a perf win. |
In the case that upcast is multi-refed like:
if we fuse
cast(i32)
to the previous op, the sub-function after fusion will have 32-bit output, instead of 8-bit output, which has larger memory access overhead.In such case, it is better to create a copy of
cast(i32)
:Previously we did special handling in CSE to ignore some common expressions in order to make quantization efficient.
This trick is too fragile for example the recent pr #3233 broke it.
This pass makes it easier as we can transform any expressions into such form that has more efficient fusion result.
cc @tqchen @ZihengJiang @eqy
also feel free to give a better name for this pass