Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 3rdparty/tvm-ffi
Submodule tvm-ffi updated 89 files
+2 −2 .github/actions/build-wheel-for-publish/action.yml
+2 −2 .github/workflows/ci_mainline_only.yml
+4 −4 .github/workflows/ci_test.yml
+3 −3 .github/workflows/torch_c_dlpack.yml
+1 −0 .gitignore
+2 −2 CMakeLists.txt
+59 −0 KEYS
+2 −0 cmake/Utils/Library.cmake
+1 −1 docs/.rstcheck.cfg
+1 −1 docs/concepts/object_and_class.rst
+715 −0 docs/concepts/structural_eq_hash.rst
+7 −1 docs/conf.py
+467 −0 docs/guides/dataclass_reflection.rst
+1 −1 docs/guides/export_func_cls.rst
+2 −0 docs/index.rst
+2 −0 examples/python_packaging/python/my_ffi_extension/_ffi_api.py
+1 −1 examples/python_packaging/run_example.py
+51 −2 include/tvm/ffi/c_api.h
+2 −1 include/tvm/ffi/container/tensor.h
+14 −0 include/tvm/ffi/extra/cuda/cubin_launcher.h
+74 −0 include/tvm/ffi/extra/cuda/internal/unified_api.h
+113 −0 include/tvm/ffi/extra/dataclass.h
+33 −4 include/tvm/ffi/reflection/accessor.h
+64 −13 include/tvm/ffi/reflection/creator.h
+246 −0 include/tvm/ffi/reflection/init.h
+9 −7 include/tvm/ffi/reflection/overload.h
+240 −30 include/tvm/ffi/reflection/registry.h
+1 −0 pyproject.toml
+93 −66 python/tvm_ffi/__init__.py
+16 −0 python/tvm_ffi/_ffi_api.py
+0 −1 python/tvm_ffi/access_path.py
+0 −26 python/tvm_ffi/container.py
+40 −3 python/tvm_ffi/core.pyi
+39 −3 python/tvm_ffi/cython/base.pxi
+4 −0 python/tvm_ffi/cython/core.pyx
+5 −1 python/tvm_ffi/cython/device.pxi
+1 −0 python/tvm_ffi/cython/dtype.pxi
+4 −3 python/tvm_ffi/cython/error.pxi
+24 −24 python/tvm_ffi/cython/function.pxi
+322 −99 python/tvm_ffi/cython/object.pxi
+806 −0 python/tvm_ffi/cython/pyclass_type_converter.pxi
+2 −2 python/tvm_ffi/cython/string.pxi
+7 −5 python/tvm_ffi/cython/tensor.pxi
+20 −7 python/tvm_ffi/cython/tvm_ffi_python_helpers.h
+831 −16 python/tvm_ffi/cython/type_info.pxi
+3 −4 python/tvm_ffi/dataclasses/__init__.py
+0 −210 python/tvm_ffi/dataclasses/_utils.py
+65 −160 python/tvm_ffi/dataclasses/c_class.py
+183 −108 python/tvm_ffi/dataclasses/field.py
+550 −0 python/tvm_ffi/dataclasses/py_class.py
+7 −5 python/tvm_ffi/module.py
+285 −18 python/tvm_ffi/registry.py
+3 −0 python/tvm_ffi/structural.py
+3 −1 python/tvm_ffi/stub/codegen.py
+116 −3 python/tvm_ffi/stub/utils.py
+12 −0 python/tvm_ffi/testing/__init__.py
+326 −19 python/tvm_ffi/testing/testing.py
+9 −3 rust/tvm-ffi-sys/src/c_api.rs
+13 −8 rust/tvm-ffi/src/collections/tensor.rs
+6 −2 rust/tvm-ffi/src/device.rs
+6 −1 rust/tvm-ffi/src/function.rs
+7 −4 rust/tvm-ffi/tests/test_device.rs
+7 −3 rust/tvm-ffi/tests/test_function.rs
+2 −7 src/ffi/container.cc
+2,004 −0 src/ffi/extra/dataclass.cc
+0 −176 src/ffi/extra/deep_copy.cc
+5 −12 src/ffi/extra/reflection_extra.cc
+0 −401 src/ffi/extra/repr_print.cc
+7 −14 src/ffi/extra/serialization.cc
+14 −7 src/ffi/function.cc
+59 −3 src/ffi/object.cc
+12 −20 src/ffi/object_internal.h
+303 −43 src/ffi/testing/testing.cc
+183 −2 tests/cpp/test_reflection.cc
+6 −6 tests/cpp/testing_object.h
+87 −0 tests/python/test_cubin_launcher.py
+319 −0 tests/python/test_dataclass_c_class.py
+1,350 −0 tests/python/test_dataclass_compare.py
+507 −25 tests/python/test_dataclass_copy.py
+1,008 −0 tests/python/test_dataclass_hash.py
+890 −0 tests/python/test_dataclass_init.py
+4,563 −0 tests/python/test_dataclass_py_class.py
+156 −4 tests/python/test_dataclass_repr.py
+0 −151 tests/python/test_dataclasses_c_class.py
+210 −2 tests/python/test_object.py
+5 −5 tests/python/test_serialization.py
+47 −0 tests/python/test_structural.py
+361 −0 tests/python/test_structural_py_class.py
+4,679 −0 tests/python/test_type_converter.py
9 changes: 3 additions & 6 deletions include/tvm/ir/type.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,7 @@ class TupleTypeNode : public TypeNode {

static void RegisterReflection() {
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<TupleTypeNode>()
.def_ro("fields", &TupleTypeNode::fields)
.def_ro("span", &TupleTypeNode::span);
refl::ObjectDef<TupleTypeNode>().def_ro("fields", &TupleTypeNode::fields);
}
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.TupleType", TupleTypeNode, TypeNode);
};
Expand Down Expand Up @@ -260,8 +258,7 @@ class FuncTypeNode : public TypeNode {
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<FuncTypeNode>()
.def_ro("arg_types", &FuncTypeNode::arg_types)
.def_ro("ret_type", &FuncTypeNode::ret_type)
.def_ro("span", &FuncTypeNode::span);
.def_ro("ret_type", &FuncTypeNode::ret_type);
}
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.FuncType", FuncTypeNode, TypeNode);
};
Expand Down Expand Up @@ -292,7 +289,7 @@ class TensorMapTypeNode : public TypeNode {
public:
static void RegisterReflection() {
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<TensorMapTypeNode>().def_ro("span", &TensorMapTypeNode::span);
refl::ObjectDef<TensorMapTypeNode>();
}
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.TensorMapType", TensorMapTypeNode, TypeNode);
};
Expand Down
4 changes: 1 addition & 3 deletions include/tvm/script/ir_builder/relax/frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,7 @@ class FunctionFrameNode : public SeqExprFrameNode {
.def_ro("params", &FunctionFrameNode::params)
.def_ro("ret_struct_info", &FunctionFrameNode::ret_struct_info)
.def_ro("is_pure", &FunctionFrameNode::is_pure)
.def_ro("attrs", &FunctionFrameNode::attrs)
.def_ro("binding_blocks", &FunctionFrameNode::binding_blocks)
.def_ro("output", &FunctionFrameNode::output);
.def_ro("attrs", &FunctionFrameNode::attrs);
// `block_builder` is not registered as it's not visited.
}
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("script.ir_builder.relax.FunctionFrame", FunctionFrameNode,
Expand Down
13 changes: 12 additions & 1 deletion python/tvm/runtime/executable.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,18 @@ def __getitem__(self, name: str) -> PackedFunc:

def __call__(self, *args, **kwargs) -> Any:
"""Call the executable."""
return self.jit().main(*args, **kwargs)
mod = self.jit()
try:
func = mod.get_function(mod.entry_name)
except AttributeError:
# Fallback: get function names and try to find one that matches
get_func_names = mod.get_function("get_func_names")
func_names = get_func_names() if get_func_names else []
raise AttributeError(
f"Module(kind={mod.kind}) has no function '{mod.entry_name}'. "
f"Available: {list(func_names)}"
)
return func(*args, **kwargs)

def jit(
self,
Expand Down
8 changes: 1 addition & 7 deletions src/relax/ir/emit_te.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,7 @@ class RXPlaceholderOpNode : public te::PlaceholderOpNode {

static void RegisterReflection() {
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<RXPlaceholderOpNode>()
.def_ro("name", &RXPlaceholderOpNode::name)
.def_ro("tag", &RXPlaceholderOpNode::tag)
.def_ro("attrs", &RXPlaceholderOpNode::attrs)
.def_ro("value", &RXPlaceholderOpNode::value)
.def_ro("shape", &RXPlaceholderOpNode::shape)
.def_ro("dtype", &RXPlaceholderOpNode::dtype);
refl::ObjectDef<RXPlaceholderOpNode>().def_ro("value", &RXPlaceholderOpNode::value);
}

// FFI system configuration for structural equality and hashing
Expand Down
Loading