Skip to content

[TIRX] Expose analyzer-aware Python stmt/expr functors#19598

Open
tlopex wants to merge 3 commits into
apache:mainfrom
tlopex:fix223
Open

[TIRX] Expose analyzer-aware Python stmt/expr functors#19598
tlopex wants to merge 3 commits into
apache:mainfrom
tlopex:fix223

Conversation

@tlopex
Copy link
Copy Markdown
Member

@tlopex tlopex commented May 25, 2026

This PR exposes C++-backed analyzer-aware stmt/expr functors to Python.

It adds PyStmtExprVisitorWithAnalyzer and PyStmtExprMutatorWithAnalyzer, allowing Python-side TIRX passes to access self.analyzer during traversal while preserving analyzer context across loops, blocks, branches, asserts, pure bindings, Select, and tirx.if_then_else.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces analyzer-aware versions of the Python StmtExprVisitor and StmtExprMutator within the tirx module. These new classes, PyStmtExprVisitorWithAnalyzer and PyStmtExprMutatorWithAnalyzer, integrate a C++-backed arith::Analyzer to automatically track arithmetic constraints from loops, branches, and assertions during IR traversal. Feedback points out a high-severity issue regarding the fragile reconstruction of the Python Analyzer object, which bypasses the constructor and may result in null C++ handles. Furthermore, an improvement was suggested in the C++ implementation to use std::make_shared for better memory management of constraint contexts.

Comment thread python/tvm/tirx/functor.py Outdated
Comment thread src/tirx/ir/py_functor.cc Outdated
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