Skip to content

[Relax] Fix nested AllocateWorkspace global calls - #20641

Open
tandede wants to merge 1 commit into
apache:mainfrom
tandede:fix/allocate-workspace-nested-global-var
Open

tandede wants to merge 1 commit into
apache:mainfrom
tandede:fix/allocate-workspace-nested-global-var

Conversation

@tandede

@tandede tandede commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #20614.

AllocateWorkspace previously revisited functions from the original module after replacing workspace-using globals. A generated workspace caller could therefore retain a call to a removed GlobalVar when codegen and composite functions were nested.

This change revisits functions from the updated builder module and reuses the generated workspace parameter while rewriting those functions. It also adds a regression test covering nested codegen and composite functions.

Tests run locally:

  • cmake --build build-issue20614 --parallel 8
  • pytest -q tests/python/relax/test_transform_allocate_workspace.py
  • pre-commit run --files src/relax/transform/allocate_workspace.cc tests/python/relax/test_transform_allocate_workspace.py

AllocateWorkspace previously revisited functions from the original module after replacing workspace-using globals. Nested generated functions could therefore retain calls to removed GlobalVars.

Revisit functions from the builder context and reuse the generated workspace parameter when rewriting them. Add a regression test for nested codegen and composite functions.
@tandede
tandede force-pushed the fix/allocate-workspace-nested-global-var branch from 19ba404 to 5807330 Compare October 13, 2026 03:08

This branch has not been deployed

No deployments
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.

[Bug] AllocateWorkspace leaves dangling GlobalVar references in nested workspace-using functions

1 participant