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

tlopex pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git


The following commit(s) were added to refs/heads/main by this push:
     new 0d9d178342 [MISC] Fix duplicate `PresburgerSetNode` registration when 
`USE_MLIR=ON` and MLIR >= 15.0 (#18555)
0d9d178342 is described below

commit 0d9d1783423f7d03831bdad7de4211380f894ba8
Author: Masahiro Hiramori <[email protected]>
AuthorDate: Sun Dec 7 03:32:08 2025 +0900

    [MISC] Fix duplicate `PresburgerSetNode` registration when `USE_MLIR=ON` 
and MLIR >= 15.0 (#18555)
    
    Fix a runtime error that occurs when TVM built with `USE_MLIR=ON` and
    MLIR >= 15.0, as shown below.
    
    ```
    Traceback (most recent call last):
      File "<unknown>", line 0, in tvm::arith::__TVMFFIStaticInitFunc2()
      File "<unknown>", line 0, in 
tvm::ffi::reflection::ObjectDef<tvm::arith::PresburgerSetNode>::ObjectDef<>()
      File "<unknown>", line 0, in void 
tvm::ffi::reflection::ObjectDef<tvm::arith::PresburgerSetNode>::RegisterExtraInfo<>()
      File "build/src/ffi/object.cc", line 500, in TVMFFITypeRegisterMetadata
      File "src/ffi/object.cc", line 240, in void 
tvm::ffi::TypeTable::RegisterTypeMetadata(int32_t, const TVMFFITypeMetadata *)
    RuntimeError: Overriding arith.PresburgerSet, possible causes:
    - two ObjectDef<T>() calls for the same T
    - when we forget to assign _type_key to ObjectRef<Y> that inherits from T
    - another type with the same key is already registered
    Cross check the reflection registration.
    libc++abi: terminating due to uncaught exception of type tvm::ffi::Error
    ```
---
 src/arith/presburger_set.cc | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/arith/presburger_set.cc b/src/arith/presburger_set.cc
index a91b4e2117..f697612596 100644
--- a/src/arith/presburger_set.cc
+++ b/src/arith/presburger_set.cc
@@ -43,8 +43,7 @@
 namespace tvm {
 namespace arith {
 
-#ifdef TVM_MLIR_VERSION
-#if TVM_MLIR_VERSION >= 150
+#if defined(TVM_MLIR_VERSION) && TVM_MLIR_VERSION >= 150
 
 TVM_FFI_STATIC_INIT_BLOCK() { PresburgerSetNode::RegisterReflection(); }
 using namespace tir;
@@ -270,8 +269,7 @@ TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable)
       p->stream << "}";
     });
 
-#endif  // TVM_MLIR_VERSION >= 150
-#endif  // TVM_MLIR_VERSION
+#else  // defined(TVM_MLIR_VERSION) && TVM_MLIR_VERSION >= 150
 
 PresburgerSet MakePresburgerSet(const PrimExpr& constraint) { return 
PresburgerSet(constraint); }
 
@@ -281,5 +279,7 @@ TVM_FFI_STATIC_INIT_BLOCK() {
   refl::GlobalDef().def("arith.PresburgerSet", MakePresburgerSet);
 }
 
+#endif  // defined(TVM_MLIR_VERSION) && TVM_MLIR_VERSION >= 150
+
 }  // namespace arith
 }  // namespace tvm

Reply via email to