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

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


The following commit(s) were added to refs/heads/main by this push:
     new 82bc7b6  [FIX] Fix missing static registration for DLTensor* (#239)
82bc7b6 is described below

commit 82bc7b639530558e9f666043c7145696d6fa35ba
Author: Tianqi Chen <[email protected]>
AuthorDate: Fri Nov 7 20:17:41 2025 -0500

    [FIX] Fix missing static registration for DLTensor* (#239)
    
    This PR fixes the missing static registration for DLTensor*
    
    Co-authored-by: Chris Bate <[email protected]>
---
 src/ffi/object.cc          |  1 +
 tests/cpp/test_function.cc | 16 ++++++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/src/ffi/object.cc b/src/ffi/object.cc
index 4c04bf4..810d3b1 100644
--- a/src/ffi/object.cc
+++ b/src/ffi/object.cc
@@ -336,6 +336,7 @@ class TypeTable {
     ReserveBuiltinTypeIndex(StaticTypeKey::kTVMFFIBool, 
TypeIndex::kTVMFFIBool);
     ReserveBuiltinTypeIndex(StaticTypeKey::kTVMFFIRawStr, 
TypeIndex::kTVMFFIRawStr);
     ReserveBuiltinTypeIndex(StaticTypeKey::kTVMFFIOpaquePtr, 
TypeIndex::kTVMFFIOpaquePtr);
+    ReserveBuiltinTypeIndex(StaticTypeKey::kTVMFFIDLTensorPtr, 
TypeIndex::kTVMFFIDLTensorPtr);
     ReserveBuiltinTypeIndex(StaticTypeKey::kTVMFFIDataType, 
TypeIndex::kTVMFFIDataType);
     ReserveBuiltinTypeIndex(StaticTypeKey::kTVMFFIDevice, 
TypeIndex::kTVMFFIDevice);
     ReserveBuiltinTypeIndex(StaticTypeKey::kTVMFFIByteArrayPtr, 
TypeIndex::kTVMFFIByteArrayPtr);
diff --git a/tests/cpp/test_function.cc b/tests/cpp/test_function.cc
index b32b701..c274e51 100644
--- a/tests/cpp/test_function.cc
+++ b/tests/cpp/test_function.cc
@@ -108,6 +108,22 @@ TEST(Func, FromTyped) {
       },
       ::tvm::ffi::Error);
 
+  // convert with DLTensor* triggers error
+  EXPECT_THROW(
+      {
+        try {
+          DLTensor dltensor;
+          fadd1(&dltensor);
+        } catch (const Error& error) {
+          EXPECT_EQ(error.kind(), "TypeError");
+          EXPECT_EQ(error.message(),
+                    "Mismatched type on argument #0 when calling: `(0: int) -> 
int`. "
+                    "Expected `int` but got `DLTensor*`");
+          throw;
+        }
+      },
+      ::tvm::ffi::Error);
+
   // try decution
   Function fpass_and_return = Function::FromTyped(
       // NOLINTNEXTLINE(performance-unnecessary-value-param)

Reply via email to