You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by tq...@apache.org on 2026/09/23 05:32:14 UTC
(tvm) 07/09: Keep normalized call arguments on the standard AST traversal
This is an automated email from the ASF dual-hosted git repository.
tqchen pushed a commit to branch script/canonical-parser-df
in repository https://gitbox.apache.org/repos/asf/tvm.git
commit 66f9c6f8ba52a4d05c13aae8e9be45da35d95109
Author: Tianqi Chen <tq...@users.noreply.github.com>
AuthorDate: Wed Sep 23 04:24:57 2026 +0000
Keep normalized call arguments on the standard AST traversal
---
python/tvm/script/parser/transpile.py | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/python/tvm/script/parser/transpile.py b/python/tvm/script/parser/transpile.py
index 0153c8f1e1..e3b0aaec4c 100644
--- a/python/tvm/script/parser/transpile.py
+++ b/python/tvm/script/parser/transpile.py
@@ -242,6 +242,10 @@ class IRBuilderTranspiler(ast.NodeTransformer):
)
def visit_Attribute(self, node):
+ # A normalized protocol callee is already builder syntax, with no source
+ # child expressions to transform or locations to invent.
+ if getattr(node, "_tvm_intrinsic", False):
+ return node
# Source: Module.f; Builder: f (the same reserved native GlobalVar).
if (
isinstance(node.value, ast.Name)
@@ -360,15 +364,13 @@ class IRBuilderTranspiler(ast.NodeTransformer):
and self._module_owner(node.func.value)
and node.func.attr in self.module_functions
)
- # Generated callees are already builder syntax. Only their original
- # arguments need the main visitor; do not give injected names fake spans.
+ # Normalized callees are already builder syntax. Mark only that
+ # attribute so generic_visit still handles every original argument once.
if callee is not None:
node.func = callee
- elif not generated:
- node.func = self.visit(node.func)
- node.args = [self.visit(value) for value in node.args]
- for keyword in node.keywords:
- keyword.value = self.visit(keyword.value)
+ if callee is not None or generated:
+ node.func._tvm_intrinsic = True
+ node = self.generic_visit(node)
# Source: declared_global(x, y)
# Builder: X.call_global_var_(declared_global, [x, y])
if global_call and not self.host_expression: