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

[Relax] Easier use of Function.bind_params with relax.op.create.* #17323

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Lunderberg
Copy link
Contributor

The Function.bind_params method requires all bound values to have StructInfo annotations. While these are generated on construction for relax::Constant and relax::PrimValue, the most common cases of bound values, other useful expression such as relax.op.zeros(shape,dtype) do not have StructInfo until they are normalized. In addition, because Function.bind_params may be used in contexts that do not have a relax.BlockBuilder available, performing this normalization is not straightforward.

This commit updates the constructors for Relax operations within the tvm.relax.op.create namespace to infer their StructInfo on construction, if it is possible to do so. This allows these operations to be used inside Function.bind_params.

The `Function.bind_params` method requires all bound values to have
`StructInfo` annotations.  While these are generated on construction
for `relax::Constant` and `relax::PrimValue`, the most common cases of
bound values, other useful expression such as
`relax.op.zeros(shape,dtype)` do not have `StructInfo` until they are
normalized.  In addition, because `Function.bind_params` may be used
in contexts that do not have a `relax.BlockBuilder` available,
performing this normalization is not straightforward.

This commit updates the constructors for Relax operations within the
`tvm.relax.op.create` namespace to infer their `StructInfo` on
construction, if it is possible to do so.  This allows these
operations to be used inside `Function.bind_params`.
@Lunderberg Lunderberg force-pushed the relax_allow_op_create_expressions_in_function_bind_params branch from 35c0d1c to b40070d Compare September 16, 2024 13:12
@Lunderberg
Copy link
Contributor Author

Rebase onto main, since the CI failures were caused by #17371.

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.

1 participant