[Relax][Frontend] Add ParameterList and ParameterDict containers#19495
Merged
tlopex merged 2 commits intoapache:mainfrom May 2, 2026
Merged
[Relax][Frontend] Add ParameterList and ParameterDict containers#19495tlopex merged 2 commits intoapache:mainfrom
tlopex merged 2 commits intoapache:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces ParameterDict and ParameterList containers to the Relax frontend's nn module, allowing for structured management of parameters. It includes updates to the Mutator for proper traversal and naming of parameters within these containers, along with comprehensive unit tests. Feedback focuses on adding explicit runtime type validation for keys and values in these containers to ensure consistency with the provided tests and improving naming consistency within the visitor logic.
Add first-class nn.ParameterList and nn.ParameterDict containers for Relax frontend parameters. The new containers validate explicit nn.Parameter values, participate in parameter/state traversal, export stable dot-separated names, and are handled by nn.Mutator traversal. Add tests for public exports, list/dict behavior, nested traversal, state_dict/load_state_dict, dtype conversion, export parameter names, and mutator naming.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
c1ab8de to
ee3e9ea
Compare
tlopex
approved these changes
May 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds first-class
nn.ParameterListandnn.ParameterDictcontainers to the Relax frontend.These containers provide PyTorch-like list/dict registration for raw
nn.Parameterobjects while preserving Relax frontend semantics: values must be explicitnn.Parameterinstances, with no automatic tensor-to-parameter conversion.Changes
nn.ParameterListandnn.ParameterDictexports.params.0,params.1params.foo,params.barnamed_parameters()parameters()state_dict()load_state_dict()to(dtype=...)export_tvm()nn.Mutator