-
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
[tvm][any] broadcast with values other than one #3967
Conversation
I am a bit confused by the semantics, how does this work? for example imagine that I have two any dimensions which will be (say 20, and 15 at runtime) it doesn't make sense to broad cast against non-1 dimensions. |
@jroesch sorry. I think the example I gave missed something. I updated it. |
close for now. need more consideration about the auto_broadcast binding. |
6e13f72
to
af6bd7e
Compare
Hey this is super helpful! Btw, I notice that in the compile engine it assumes that checked type exists. Does it mean that for now we are only able to deal with the case that dims are fixed and certain dimensions are Any? |
@junrushao1994 Yes, you are right, only the bound is dynamic but rank is fixed. |
It will generate runtime error when actual shape is incompatible? |
@kevinthesun Yes, both the interpreter and VM would fail if the real values are incompatible. I can probably add a few tests for them as well. |
The shape function will perform the type checking at runtime (see https://github.com/dmlc/tvm/blob/master/python/tvm/relay/op/_tensor.py#L130). |
@icemelon9 yeah, that might be a different between Any and tvm symbolic var. |
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.
Is it possible to have a pass replace attr::buffer_bind_scope
? current impl seems to be a little bit adhoc.
@yzhliu Yeah, I actually thought about replacing it as well. But I ended up skipping it because it looks there is not much difference. I think we probably want to keep compact memory as much as possible because auto broadcast will bring in the if_then_else guard which may not as performant as the compact version. How do you think? |
@icemelon9 @yzhliu @kevinthesun I think we've probably forgotten this PR. |
Is this ready for review? |
@junrushao1994 yes |
so it won't work for those ops written in hybrid script, right? |
@yzhliu Thanks. Removed the binding in hybrid script as it will go through |
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
* [tvm][any] broadcast with values other than 1 * Add test for incompatible runtime values * Remove hybrid script compact buffer binding * retrigger ci
* [tvm][any] broadcast with values other than 1 * Add test for incompatible runtime values * Remove hybrid script compact buffer binding * retrigger ci
This PR makes relay Any type broadcast with values other than one, i.e.:
It makes all symbolic vars as
auto_broadcast
if they haven't been bound to compact buffer before.@icemelon9 @yzhliu @tqchen @jroesch