Skip to content
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

[Transform] Remove R.Object parameters after LazyTransformParams #16699

Merged

Conversation

Lunderberg
Copy link
Contributor

Prior to this commit, the output of relax.transform.LazyTransformParams would include all parameters that are not R.Tensor, in case they defined symbolic variables. However, this added too many unnecessary parameters, such as R.Object which cannot define symbolic variables. This commit updates relax.transform.LazyTransformParams to only retain R.Prim and R.Shape parameters, which can define symbolic variables.

@Lunderberg Lunderberg changed the title [Transform] Remove R.Object parameters after LazyTranformParams [Transform] Remove R.Object parameters after LazyTransformParams Mar 11, 2024
Prior to this commit, the output of
`relax.transform.LazyTransformParams` would include all parameters
that are not `R.Tensor`, in case they defined symbolic variables.
However, this added too many unnecessary parameters, such as
`R.Object` which cannot define symbolic variables.  This commit
updates `relax.transform.LazyTransformParams` to only retain `R.Prim`
and `R.Shape` parameters, which can define symbolic variables.
@Lunderberg Lunderberg force-pushed the relax_lazy_transform_params_object_sinfo branch from 11f3c44 to 69995d1 Compare March 11, 2024 17:29
@masahi
Copy link
Member

masahi commented Mar 11, 2024

@Lunderberg Can you take a look at the failed test?

@Lunderberg
Copy link
Contributor Author

Failed test should now be resolved. The root issue was in TVMScript parsing, that while a variable could be annotated with an object or tensor class (e.g. var: R.Tensor instead of var: R.Tensor()), this was not handled in match cast (e.g. R.match_cast(obj, R.Tensor). PR is now updated with a fix.

@Lunderberg Lunderberg force-pushed the relax_lazy_transform_params_object_sinfo branch from 292c5a2 to 9605bca Compare March 12, 2024 15:40
Prior to this commit, bare `StructInfoProxy` annotations could be used
to annotate variables (e.g. `var: R.Tensor`).  However, they could
not be used as the argument of a match cast (e.g. `R.match_cast(obj,
R.Tensor)`).  This breaks round-trips, as the `R.match_cast` printing
generates base `StructInfoProxy` objects.

This commit updates TVMScript parsing to handle bare `StructInfoProxy`
annotations as an argument to `R.match_cast`.
@Lunderberg Lunderberg force-pushed the relax_lazy_transform_params_object_sinfo branch from 9605bca to 94ce183 Compare March 12, 2024 15:56
@masahi masahi merged commit 831d769 into apache:main Mar 13, 2024
18 checks passed
@Lunderberg Lunderberg deleted the relax_lazy_transform_params_object_sinfo branch March 13, 2024 12:55
thaisacs pushed a commit to thaisacs/tvm that referenced this pull request Apr 3, 2024
…che#16699)

* [Transform] Remove R.Object parameters after LazyTranformParams

Prior to this commit, the output of
`relax.transform.LazyTransformParams` would include all parameters
that are not `R.Tensor`, in case they defined symbolic variables.
However, this added too many unnecessary parameters, such as
`R.Object` which cannot define symbolic variables.  This commit
updates `relax.transform.LazyTransformParams` to only retain `R.Prim`
and `R.Shape` parameters, which can define symbolic variables.

* [TVMScript][Bugfix] Check for StructInfoProxy in R.match_cast

Prior to this commit, bare `StructInfoProxy` annotations could be used
to annotate variables (e.g. `var: R.Tensor`).  However, they could
not be used as the argument of a match cast (e.g. `R.match_cast(obj,
R.Tensor)`).  This breaks round-trips, as the `R.match_cast` printing
generates base `StructInfoProxy` objects.

This commit updates TVMScript parsing to handle bare `StructInfoProxy`
annotations as an argument to `R.match_cast`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants