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

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


The following commit(s) were added to refs/heads/main by this push:
     new df86f9879 [Rust] Update TVM FFI and rename rs_class to rs_object (#185)
df86f9879 is described below

commit df86f98793888a9f4f92fc0d138345f58258e64f
Author: Linzhang Li <[email protected]>
AuthorDate: Wed Nov 4 00:17:26 2026 -0500

    [Rust] Update TVM FFI and rename rs_class to rs_object (#185)
    
    ## Summary
    
    This PR updates the TVM FFI submodule to the latest apache/tvm-ffi main
    and follows its rename
    of the attribute macro that defines an object type in Rust, from
    `#[rs_class]` to
    `#[rs_object]`. The macro's arguments and behavior are unchanged.
    
    ### TVM FFI update
    
    `3rdparty/tvm-ffi` moves from `9c834da` to `afa8dce`, which adds:
    
    - apache/tvm-ffi#904: faster structural traversal checks and dispatch;
    - apache/tvm-ffi#908: `rs_class` renamed to `rs_object`.
    
    ### Rename
    
    Every use of `rs_class` now uses `rs_object`:
    
    - **Crate:** the crate docs in `rust/src/lib.rs` and the docs of
    `ir::register_type` in
      `rust/src/ir/type_def.rs`, including their examples;
    - **Examples:** `rust/examples/define_ir.rs` and the complex-number
    extension in
      `examples/extension/src/lib.rs`;
    - **Tests:** `rust/tests/ir/op_def.rs` and `rust/tests/ir/type.rs`;
    - **Docs:** `docs/advanced/defining_ir_extensions.rst`.
    
    The generated bindings do not change: `tvm-ffi-stubgen --check` passes.
    
    ## Testing
    
    Verified locally on Linux, with the `.venv` TVM FFI reinstalled from the
    new submodule commit:
    
    - `cargo test --manifest-path rust/Cargo.toml`, doc tests included: all
    pass.
    - `cargo doc --no-deps` with `RUSTDOCFLAGS="-D warnings"`: the links to
    `tvm_ffi::rs_object`
      resolve.
    - `tvm-ffi-stubgen rust/src --target rust --dlls
    build/lib/libtvm_tirx_compiler.so --check`.
    - `pytest tests/python/ir/test_op_rust.py`: 7 passed, including the
    extension example.
    - The Sphinx HTML build with `-W`, using CI's Sphinx 8.1.3 and docutils
    0.21.2.
    - `cargo fmt --check` for both crates and pre-commit on the changed
    files.
---
 3rdparty/tvm-ffi                         |  2 +-
 docs/advanced/defining_ir_extensions.rst |  2 +-
 examples/extension/src/lib.rs            |  4 ++--
 rust/examples/define_ir.rs               |  4 ++--
 rust/src/ir/type_def.rs                  | 12 ++++++------
 rust/src/lib.rs                          | 10 +++++-----
 rust/tests/ir/op_def.rs                  |  4 ++--
 rust/tests/ir/type.rs                    |  6 +++---
 8 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/3rdparty/tvm-ffi b/3rdparty/tvm-ffi
index 9c834dadb..afa8dce89 160000
--- a/3rdparty/tvm-ffi
+++ b/3rdparty/tvm-ffi
@@ -1 +1 @@
-Subproject commit 9c834dadb9d575be3818758f371d143720a1602a
+Subproject commit afa8dce89705e844457899b42e3d0f69da8c5c03
diff --git a/docs/advanced/defining_ir_extensions.rst 
b/docs/advanced/defining_ir_extensions.rst
index e58aa53fd..3f7991dbf 100644
--- a/docs/advanced/defining_ir_extensions.rst
+++ b/docs/advanced/defining_ir_extensions.rst
@@ -93,7 +93,7 @@ real and imaginary parts, as in ``TensorType``:
 In Rust, as in C++, the type is defined in two parts: ``ComplexTypeObj`` is the
 object that holds the fields, and ``ComplexType`` is a reference-counted
 reference to it, which IR nodes store and functions pass around.
-``base: TypeObj`` makes the object an IR type, and ``rs_class`` registers its
+``base: TypeObj`` makes the object an IR type, and ``rs_object`` registers its
 fields for reflection, through which Python and IR JSON loading construct the
 type as they construct a C++ one. ``def_object_ref!`` defines the reference.
 
diff --git a/examples/extension/src/lib.rs b/examples/extension/src/lib.rs
index d1438a486..94c5e8f3d 100644
--- a/examples/extension/src/lib.rs
+++ b/examples/extension/src/lib.rs
@@ -30,13 +30,13 @@ use tvm_tirx::ir::{
 use tvm_tirx::tirx::transform::FunctionPass;
 use tvm_tirx::tirx::Function;
 use tvm_tirx::tvm_ffi::{
-    self, def_object_ref, dispatch, rs_class, Any, AnyView, Error, 
ObjectRefCast, ObjectRefCore,
+    self, def_object_ref, dispatch, rs_object, Any, AnyView, Error, 
ObjectRefCast, ObjectRefCore,
     Result, Unchanged, WalkOrder,
 };
 
 // begin type
 /// A complex number whose real and imaginary parts share a scalar type.
-#[rs_class("my_ext.ComplexType", final)]
+#[rs_object("my_ext.ComplexType", final)]
 pub struct ComplexTypeObj {
     base: TypeObj,
     pub dtype: PrimType,
diff --git a/rust/examples/define_ir.rs b/rust/examples/define_ir.rs
index 604b31963..e77922e8d 100644
--- a/rust/examples/define_ir.rs
+++ b/rust/examples/define_ir.rs
@@ -34,7 +34,7 @@ use tvm_tirx::ir::{
     register_type, CallEffectKind, CallObj, DictAttrs, Expr, OpDef, PrimType, 
Type, TypeObj, Var,
     UNKNOWN_LOC,
 };
-use tvm_tirx::tvm_ffi::{self, def_object_ref, rs_class, Array, ObjectRefCast, 
Result};
+use tvm_tirx::tvm_ffi::{self, def_object_ref, rs_object, Array, ObjectRefCast, 
Result};
 
 fn first_arg_type(call: &CallObj) -> Result<Type> {
     Ok(call.args.get(0)?.ty.clone())
@@ -49,7 +49,7 @@ fn loop_index(call: &CallObj) -> Result<Array<Var>> {
 // A type, which Python constructs from its fields, `T.ExamplePair(T.int32, 
T.float32)`, as it
 // constructs a C++ type.
 /// The type of a pair of values.
-#[rs_class("tirx.ExamplePairType", final)]
+#[rs_object("tirx.ExamplePairType", final)]
 pub struct ExamplePairTypeObj {
     base: TypeObj,
     pub first: Type,
diff --git a/rust/src/ir/type_def.rs b/rust/src/ir/type_def.rs
index 295029f0d..7b7237a17 100644
--- a/rust/src/ir/type_def.rs
+++ b/rust/src/ir/type_def.rs
@@ -18,10 +18,10 @@
  */
 
 //! Registering IR types from Rust: [`register_type`], which a 
[`tvm_ffi::static_init_block!`]
-//! calls for an `rs_class` type, as C++ registers a type with 
`refl::ObjectDef` in a
+//! calls for an `rs_object` type, as C++ registers a type with 
`refl::ObjectDef` in a
 //! `TVM_FFI_STATIC_INIT_BLOCK`.
 //!
-//! `rs_class` registers the fields of a type and, as C++ `refl::ObjectDef` 
does, a creator of an
+//! `rs_object` registers the fields of a type and, as C++ `refl::ObjectDef` 
does, a creator of an
 //! object whose fields are undefined, which tvm-ffi fills through the 
reflection of the fields to
 //! construct the type from Python (the `__ffi_init__` it generates) and to 
read it from a JSON
 //! graph (`__ffi_new__`). [`register_type`] registers the type when its 
program or library loads
@@ -31,8 +31,8 @@ use tvm_ffi::{Function, ObjectCore, ObjectRefCore, Result, 
String};
 
 use super::support;
 
-/// Register the IR type of the reference `R`, an `rs_class` type, as C++ 
registers one with
-/// `refl::ObjectDef`: the type, with the `__ffi_new__` and `__ffi_init__` 
`rs_class` registers,
+/// Register the IR type of the reference `R`, an `rs_object` type, as C++ 
registers one with
+/// `refl::ObjectDef`: the type, with the `__ffi_new__` and `__ffi_init__` 
`rs_object` registers,
 /// then, when the receiver is installed, a request for its constructor in 
registered destinations
 /// (`ir.expose_type`); an absent receiver is a no-op, and an installed 
receiver's error is
 /// returned. With an explicitly declared `my_ext` type API destination, 
Python then constructs the
@@ -48,10 +48,10 @@ use super::support;
 ///
 /// ```no_run
 /// use tvm_tirx::ir::{register_type, Location, Type, TypeObj};
-/// use tvm_tirx::tvm_ffi::{self, def_object_ref, rs_class, ObjectRefCore};
+/// use tvm_tirx::tvm_ffi::{self, def_object_ref, rs_object, ObjectRefCore};
 ///
 /// /// The type of a pair of values, printed as `my_ext.Pair(first, second)`.
-/// #[rs_class("my_ext.PairType", final)]
+/// #[rs_object("my_ext.PairType", final)]
 /// pub struct PairTypeObj {
 ///     base: TypeObj,
 ///     pub first: Type,
diff --git a/rust/src/lib.rs b/rust/src/lib.rs
index c31d497cf..a4906863d 100644
--- a/rust/src/lib.rs
+++ b/rust/src/lib.rs
@@ -114,8 +114,8 @@
 //! use tvm_tirx::ir::{register_type, CallEffectKind, CallObj, Op, OpDef, 
Type};
 //! use tvm_tirx::tvm_ffi::{self, Result};
 //! # use tvm_tirx::ir::TypeObj;
-//! # use tvm_tirx::tvm_ffi::{def_object_ref, rs_class, ObjectRefCore};
-//! # #[rs_class("my_ext.PairType", final)]
+//! # use tvm_tirx::tvm_ffi::{def_object_ref, rs_object, ObjectRefCore};
+//! # #[rs_object("my_ext.PairType", final)]
 //! # pub struct PairTypeObj { base: TypeObj, pub first: Type, pub second: 
Type }
 //! # def_object_ref!(pub PairType, Type, PairTypeObj);
 //!
@@ -172,7 +172,7 @@
 //!
 //! # Defining a type in Rust
 //!
-//! [`tvm_ffi::rs_class`] defines a new IR type, a type of expressions as 
[`ir::PrimType`] and
+//! [`tvm_ffi::rs_object`] defines a new IR type, a type of expressions as 
[`ir::PrimType`] and
 //! [`ir::TupleType`] are, from its object struct, whose first field `base` is 
the [`ir::TypeObj`]
 //! it extends, which holds the location. It registers the type under 
`ir.Type` with the
 //! reflection of every other field, so that the C++ structural equality and 
hashing, deep copy,
@@ -182,10 +182,10 @@
 //!
 //! ```no_run
 //! use tvm_tirx::ir::{Location, PrimType, Type, TypeObj};
-//! use tvm_tirx::tvm_ffi::{self, def_object_ref, rs_class, ObjectRefCore};
+//! use tvm_tirx::tvm_ffi::{self, def_object_ref, rs_object, ObjectRefCore};
 //!
 //! /// The type of a pair of values.
-//! #[rs_class("my_ext.PairType", final)]
+//! #[rs_object("my_ext.PairType", final)]
 //! pub struct PairTypeObj {
 //!     base: TypeObj,
 //!     pub first: Type,
diff --git a/rust/tests/ir/op_def.rs b/rust/tests/ir/op_def.rs
index b112eedc7..7757f05ee 100644
--- a/rust/tests/ir/op_def.rs
+++ b/rust/tests/ir/op_def.rs
@@ -38,7 +38,7 @@ use tvm_tirx::tirx::{CallFFIKernelAttr, TensorVar};
 use tvm_tirx::tvm_ffi::static_init::{StaticInitBlock, STATIC_INIT_BLOCKS};
 use tvm_tirx::tvm_ffi::tvm_ffi_sys::TVMFFITypeIndex;
 use tvm_tirx::tvm_ffi::{
-    self, def_object_ref, rs_class, run_static_init_blocks, Any, AnyView, 
Array, Error, ErrorKind,
+    self, def_object_ref, rs_object, run_static_init_blocks, Any, AnyView, 
Array, Error, ErrorKind,
     Function, Map, ObjectCore, ObjectRefCast, ObjectRefCore, Result, String as 
FfiString,
     ATTRIBUTE_ERROR, INTERNAL_ERROR, TYPE_ERROR, VALUE_ERROR,
 };
@@ -414,7 +414,7 @@ fn accept(_call: &CallObj) -> Result<()> {
 }
 
 /// A type and a count, registered with the operators when the test binary 
loads.
-#[rs_class("rust_test.BlockType", final)]
+#[rs_object("rust_test.BlockType", final)]
 pub struct BlockTypeObj {
     base: TypeObj,
     pub elem: Type,
diff --git a/rust/tests/ir/type.rs b/rust/tests/ir/type.rs
index 9e0621511..5754dc922 100644
--- a/rust/tests/ir/type.rs
+++ b/rust/tests/ir/type.rs
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-//! Tests of `ir::type`, and of an `ir.Type` defined in Rust with `rs_class` 
over the generated
+//! Tests of `ir::type`, and of an `ir.Type` defined in Rust with `rs_object` 
over the generated
 //! `TypeObj`: seen through the FFI type table, the C++ engines (structural 
equality and hashing,
 //! deep copy, `repr`, TVMScript), the Rust engines and the IR that uses it.
 
@@ -27,7 +27,7 @@ use tvm_tirx::ir::{
     UNKNOWN_LOC, Location, dtype, Evaluate, FuncType, MissingType, NoneType, 
PrimType, PtrType,
     TensorRegionType, TupleType, Type, TypeObj, Var, VarObj,
 };
-use tvm_tirx::tvm_ffi::{def_object_ref, rs_class, structural_map};
+use tvm_tirx::tvm_ffi::{def_object_ref, rs_object, structural_map};
 use tvm_tirx::tvm_ffi::{
     Any, AnyView, Array, DLDataType, DLDataTypeExt, FieldGetter, ObjectCore, 
ObjectRefCore, Result,
     ShallowCopy, String as FfiString, WalkOrder,
@@ -116,7 +116,7 @@ fn types_agree_with_cpp() {
 }
 
 /// A pair of types with a tag, defined in Rust.
-#[rs_class("testing.rust.PairType", final)]
+#[rs_object("testing.rust.PairType", final)]
 pub struct PairTypeObj {
     base: TypeObj,
     /// The first element.

Reply via email to