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

tqchen pushed a commit to branch tqchen/printer-refinement
in repository https://gitbox.apache.org/repos/asf/tvm.git

commit 0dbebccb24a4105a8c324905d8ded6de65116b91
Author: Tianqi Chen <[email protected]>
AuthorDate: Thu Oct 1 17:44:06 2026 +0000

    [REFACTOR][TIRx] Configure scalar buffer variable syntax in its owning 
printer
---
 python/tvm/runtime/script_printer.py | 4 ++++
 src/tirx/script/printer/buffer.cc    | 4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/python/tvm/runtime/script_printer.py 
b/python/tvm/runtime/script_printer.py
index 9a3e25d0d7..4fe8739dd8 100644
--- a/python/tvm/runtime/script_printer.py
+++ b/python/tvm/runtime/script_printer.py
@@ -35,6 +35,10 @@ class PrinterConfig(Object):
     The ``int_dtype`` and ``float_dtype`` arguments populate the string-valued
     ``ir.int_dtype`` and ``ir.float_dtype`` entries in ``extra_config``.
     Explicit entries in ``extra_config`` override those arguments.
+
+    ``tirx.scalar_buffer_as_mutable_var`` in ``extra_config`` defaults to true.
+    It prints eligible local scalar buffers as typed mutable variables. Set it
+    to false to retain explicit buffer allocations and indexed loads/stores.
     """
 
     binding_names: Sequence[str]
diff --git a/src/tirx/script/printer/buffer.cc 
b/src/tirx/script/printer/buffer.cc
index 3852af4dfd..576613788c 100644
--- a/src/tirx/script/printer/buffer.cc
+++ b/src/tirx/script/printer/buffer.cc
@@ -132,8 +132,8 @@ ffi::Optional<ExprDoc> 
BufferOperationDocTranslate(DocTranslatorObj* d, ffi::Any
   }
   IdDoc lhs = VarDoc(d, var);
   AssignDoc allocation(lhs, rhs, std::nullopt);
-  if (is_alloc && SyntaxSugar(d) && annotations.empty() && scope->value == 
"local" &&
-      buffer.value()->IsScalar(true)) {
+  if (is_alloc && d->GetExtraConfig<bool>("tirx.scalar_buffer_as_mutable_var", 
true) &&
+      annotations.empty() && scope->value == "local" && 
buffer.value()->IsScalar(true)) {
     auto scalars = d->GetOrCreateExtraState<ffi::Dict<IdDoc, 
bool>>("tirx.buffer_as_mutable_var");
     scalars.Set(d->VarGetOrAllocId(var, true), true);
 

Reply via email to