This repository has been archived by the owner on May 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 58
[DISCUSS] Some thoughts on the shape pattern matching #33
Comments
I agree that this looks cleaner and I think we considered this approach during the design. One thing to think about is how we would match the dimensions without binding the left to a tensor, for example currently we could write
one option is to overload the binding syntax with something like
although this seems a bit strange if |
great discussions, from syntax(sugar) pov they makes sense. We can make these pieces de-sugar to match_shape. On the other hand from the IR pov we will need to differentiate between match(which defines or creates an assertion) and x.shape field(an invariance due to inference). So we still likely need an explicit match_shape construct |
tqchen
changed the title
Some thoughts on the shape pattern matching
[DISCUSS] Some thoughts on the shape pattern matching
Nov 17, 2021
jinhongyii
pushed a commit
to jinhongyii/relax
that referenced
this issue
Nov 28, 2022
jinhongyii
pushed a commit
to jinhongyii/relax
that referenced
this issue
Dec 10, 2022
vinx13
pushed a commit
to vinx13/relax
that referenced
this issue
Dec 14, 2022
see more updates in match cast #293 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I moved the discussion from tvm forum to here because relax has not been upstreamed yet.
In relax wiki,
did a pattern matching that assigns the shape of
lhs
topattern
.And when you define something like
n
andm
are defined on the right side and the(n,m)
on the type annotation is used for assertion.However, in most programming languages, variables are defined on the left of
=
. I wonder can we make the pattern matching happen on the left side of=
?In the following example:
we assign the value of
y + 1
tox
, and assign the shape ofy
to(n,m)
.When the same value appeared twice, we do an assertion check:
Also, this could simplify the dynamic shape matching:
can be simplified as:
The text was updated successfully, but these errors were encountered: