This is an automated email from the ASF dual-hosted git repository.

tqchen pushed a commit to branch tvmscript-ast-only-transpiler
in repository https://gitbox.apache.org/repos/asf/tvm.git

commit 6f6f1956a2a486e0df5006e3e328ee5ef4d876ac
Author: Tianqi Chen <[email protected]>
AuthorDate: Mon Sep 21 22:02:20 2026 +0000

    [TVMScript] Reuse Relax signature symbols for primitive declarations
---
 python/tvm/relax/script/builder/v2.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/python/tvm/relax/script/builder/v2.py 
b/python/tvm/relax/script/builder/v2.py
index 233bd64645..dfc0f31846 100644
--- a/python/tvm/relax/script/builder/v2.py
+++ b/python/tvm/relax/script/builder/v2.py
@@ -844,8 +844,9 @@ def bind_(
 
     Notes
     -----
-    Expression inputs emit in the active native function/block. TypeVarDecl 
updates the
-    nearest symbol frame. Existing native Emit rules fill MissingType on the 
original RHS
+    Anonymous primitive declarations and TypeVarDecl reuse the nearest symbol 
frame.
+    Named primitive variables and computed expressions emit fresh bindings in 
the active
+    native function/block. Existing native Emit rules fill MissingType on the 
original RHS
     before normalization and check concrete annotations. This operation adds 
no recursive
     annotation validation or propagation to tuple fields or call arguments.
 
@@ -855,6 +856,11 @@ def bind_(
     """
     _check_unterminated()
     name_span = _source_span(span if name_span is None else name_span)
+    # Shared dtype constructors return anonymous primitive Vars. Reuse the
+    # signature's canonical symbol for declarations, while named aliases and
+    # computed primitive expressions retain ordinary Relax binding semantics.
+    if ty is None and not frame_value and _ir.is_prim_var(value) and not 
value.name:
+        return _TypeVarFrame.current().resolve(name, value.ty, span=name_span)
     if isinstance(value, _TypeVarDecl):
         return _TypeVarFrame.current().resolve(name, value.ty, span=name_span)
     if frame_value:

Reply via email to