You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by ju...@apache.org on 2026/01/12 18:08:36 UTC

(tvm-ffi) branch revert-395-2026-01-09/py-func-enhance created (now 15431dd)

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

junrushao pushed a change to branch revert-395-2026-01-09/py-func-enhance
in repository https://gitbox.apache.org/repos/asf/tvm-ffi.git


      at 15431dd  Revert "feat: Add `tvm_ffi.Function.__init__` (#395)"

This branch includes the following new commits:

     new 15431dd  Revert "feat: Add `tvm_ffi.Function.__init__` (#395)"

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(tvm-ffi) 01/01: Revert "feat: Add `tvm_ffi.Function.__init__` (#395)"

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

junrushao pushed a commit to branch revert-395-2026-01-09/py-func-enhance
in repository https://gitbox.apache.org/repos/asf/tvm-ffi.git

commit 15431dddfe5ad8d2dd5df3b242b80e0bd92648cb
Author: Junru Shao <ju...@gmail.com>
AuthorDate: Mon Jan 12 10:08:32 2026 -0800

    Revert "feat: Add `tvm_ffi.Function.__init__` (#395)"
    
    This reverts commit 8786670af20e9005ec1dd50d7872ee9e2b8b89cd.
---
 include/tvm/ffi/base_details.h     | 16 ++++------------
 python/tvm_ffi/core.pyi            |  1 -
 python/tvm_ffi/cython/function.pxi | 21 ---------------------
 tests/python/test_function.py      |  9 ---------
 4 files changed, 4 insertions(+), 43 deletions(-)

diff --git a/include/tvm/ffi/base_details.h b/include/tvm/ffi/base_details.h
index a00d4a4..7224ac1 100644
--- a/include/tvm/ffi/base_details.h
+++ b/include/tvm/ffi/base_details.h
@@ -86,7 +86,6 @@
 #else
 #define TVM_FFI_FUNC_SIG __func__
 #endif
-/// \endcond
 
 #if defined(__GNUC__)
 // gcc and clang and attribute constructor
@@ -115,22 +114,14 @@
     return 0;                                          \
   }();                                                 \
   static void FnName()
-/// \endcond
-/*!
- * \brief Macro that defines a block that will be called during static initialization.
- *
- * \code{.cpp}
- * TVM_FFI_STATIC_INIT_BLOCK() {
- *   RegisterFunctions();
- * }
- * \endcode
- */
+
 #define TVM_FFI_STATIC_INIT_BLOCK()                                                       \
   TVM_FFI_STATIC_INIT_BLOCK_DEF_(TVM_FFI_STR_CONCAT(__TVMFFIStaticInitFunc, __COUNTER__), \
                                  TVM_FFI_STR_CONCAT(__TVMFFIStaticInitReg, __COUNTER__))
+/// \endcond
 #endif
 
-/*!
+/*
  * \brief Define the default copy/move constructor and assign operator
  * \param TypeName The class typename.
  */
@@ -322,4 +313,5 @@ using TypeSchema = TypeSchemaImpl<std::remove_const_t<std::remove_reference_t<T>
 }  // namespace details
 }  // namespace ffi
 }  // namespace tvm
+/// \endcond
 #endif  // TVM_FFI_BASE_DETAILS_H_
diff --git a/python/tvm_ffi/core.pyi b/python/tvm_ffi/core.pyi
index 1c3a3da..2cee79c 100644
--- a/python/tvm_ffi/core.pyi
+++ b/python/tvm_ffi/core.pyi
@@ -184,7 +184,6 @@ class DLTensorTestWrapper:
 def _dltensor_test_wrapper_c_dlpack_from_pyobject_as_intptr() -> int: ...
 
 class Function(Object):
-    def __init__(self, func: Callable[..., Any]) -> None: ...
     @property
     def release_gil(self) -> bool: ...
     @release_gil.setter
diff --git a/python/tvm_ffi/cython/function.pxi b/python/tvm_ffi/cython/function.pxi
index 67429ea..01a3366 100644
--- a/python/tvm_ffi/cython/function.pxi
+++ b/python/tvm_ffi/cython/function.pxi
@@ -889,27 +889,6 @@ cdef class Function(Object):
     def __cinit__(self) -> None:
         self.c_release_gil = _RELEASE_GIL_BY_DEFAULT
 
-    def __init__(self, func: Callable[..., Any]) -> None:
-        """Initialize a Function from a Python callable.
-
-        This constructor allows creating a `tvm_ffi.Function` directly
-        from a Python function or another `tvm_ffi.Function` instance.
-
-        Parameters
-        ----------
-        func : Callable[..., Any]
-            The Python callable to wrap.
-        """
-        cdef TVMFFIObjectHandle chandle = NULL
-        if not callable(func):
-            raise TypeError(f"func must be callable, got {type(func)}")
-        if isinstance(func, Function):
-            chandle = (<Object>func).chandle
-            TVMFFIObjectIncRef(chandle)
-        else:
-            _convert_to_ffi_func_handle(func, &chandle)
-        self.chandle = chandle
-
     property release_gil:
         """Whether calls release the Python GIL while executing."""
 
diff --git a/tests/python/test_function.py b/tests/python/test_function.py
index 34d3bdc..8a494fb 100644
--- a/tests/python/test_function.py
+++ b/tests/python/test_function.py
@@ -153,15 +153,6 @@ def test_pyfunc_convert() -> None:
     assert fapply(add, 1, 3.3) == 4.3
 
 
-def test_pyfunc_init() -> None:
-    def add(a: int, b: int) -> int:
-        return a + b
-
-    fadd = tvm_ffi.Function(add)
-    assert isinstance(fadd, tvm_ffi.Function)
-    assert fadd(1, 2) == 3
-
-
 def test_global_func() -> None:
     @tvm_ffi.register_global_func("mytest.echo")
     def echo(x: Any) -> Any: