-
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
[Relax] Validate StructInfo of variable bindings #17332
[Relax] Validate StructInfo of variable bindings #17332
Conversation
This validation exposed a bug in The bug in |
In Relax, both the variable and the expression in a `VarBinding` may contain `StructInfo` annotations. Prior to this commit, these `StructInfo` annotations could be inconsistent, assigning an expression to a variable of incompatible type. This commit updates the Relax well-formed checker to verify that the `StructInfo` of Relax variables accurately describes their contents.
The `StructInfoLCA` determines the lowest common ancestor between two `StructInfo` annotations. This is primarily used in Relax to determine the appropriate `StructInfo` annotation for a `relax::If` node, given the `StructInfo` of each branch. Prior to this commit, when determining the LCA of two `PrimStructInfo` annotations, the `StructInfoLCA` function only inspected the datatype of `PrimStructInfo` annotations, and did not check for known values. For example, the LCA of `R.Prim(value=T.int64(128))` and `R.Prim(value=T.int64(64))` is `R.Prim("int64")`, but was incorrectly determined as `R.Prim(value=T.int64(128))` by the `StructInfoLCA` function. This commit updates `StructInfoLCA` to inspect the known values of a `PrimStructInfo`, as well as the datatype.
8b7d373
to
c4b980b
Compare
Rebased onto main to resolve conflicts in |
cc @yongwww can you help to take a look |
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.
Looks good to me!
In Relax, both the variable and the expression in a
VarBinding
may containStructInfo
annotations. Prior to this commit, theseStructInfo
annotations could be inconsistent, assigning an expression to a variable of incompatible type.This commit updates the Relax well-formed checker to verify that the
StructInfo
of Relax variables accurately describes their contents.