[compiler] carry Python containers through dynamic if/for/while/ifexp#874
Draft
xudoyuan wants to merge 3 commits into
Draft
[compiler] carry Python containers through dynamic if/for/while/ifexp#874xudoyuan wants to merge 3 commits into
xudoyuan wants to merge 3 commits into
Conversation
Dynamic scf.if / scf.for / scf.while / ifexp previously required every carried variable to be a single ir.Value, so a reassigned list/tuple/dict local raised "state variable '...' is list, not an MLIR Value". Route the four dispatchers through an explode/assemble step that reuses the existing DSL<->ir.Value protocol (protocol.extract/construct): each carried value (possibly a nested container) is exploded to per-element iter_args/ results and assembled back from the pre-region value used as the structural template on exit. Scalars stay the degenerate single-slot case so existing behaviour is unchanged; a branch/body that changes a container's shape or an element's dtype now fails with a clear error. Adds MLIR-level unit tests and device system tests for list/tuple/dict/nested carry across if/for/while/ifexp. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The device/launch test belongs with the other end-to-end tests under tests/system (renamed to the *_e2e.py convention); the MLIR-level unit test stays under tests/unit. Aligns the header with the existing e2e tests (direct torch import + skip). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Rename the test class to *E2E, reword the module docstring, and use the direct `import torch` + skip style shared by the other tests/system e2e files. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Dynamic scf.if / scf.for / scf.while / ifexp previously required every carried variable to be a single ir.Value, so a reassigned list/tuple/dict local raised "state variable '...' is list, not an MLIR Value".
Route the four dispatchers through an explode/assemble step that reuses the existing DSL<->ir.Value protocol (protocol.extract/construct): each carried value (possibly a nested container) is exploded to per-element iter_args/ results and assembled back from the pre-region value used as the structural template on exit. Scalars stay the degenerate single-slot case so existing behaviour is unchanged; a branch/body that changes a container's shape or an element's dtype now fails with a clear error.
Adds MLIR-level unit tests and device system tests for list/tuple/dict/nested carry across if/for/while/ifexp.
Motivation
Technical Details
Test Plan
Test Result
Submission Checklist