From 58b74e481b47131c6633eef6b651d77bd12e3724 Mon Sep 17 00:00:00 2001 From: tqchen Date: Tue, 15 Jul 2025 16:58:42 -0400 Subject: [PATCH] [FFI] Log and throw in function dup registration This PR changes the function global dup registration to log and throw so we have clear error message about the function duplication. --- ffi/src/ffi/function.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ffi/src/ffi/function.cc b/ffi/src/ffi/function.cc index 3db651fe11fd..a2d3fb9db353 100644 --- a/ffi/src/ffi/function.cc +++ b/ffi/src/ffi/function.cc @@ -92,7 +92,10 @@ class GlobalFunctionTable { String name(method_info->name.data, method_info->name.size); if (table_.count(name)) { if (!can_override) { - TVM_FFI_THROW(RuntimeError) << "Global Function `" << name << "` is already registered"; + TVM_FFI_LOG_AND_THROW(RuntimeError) + << "Global Function `" << name << "` is already registered, possible causes:\n" + << "- Two GlobalDef().def registrations for the same function \n" + << "Please remove the duplicate registration."; } } table_.Set(name, ObjectRef(make_object(method_info)));