Repository navigation
[FEAT][RUST] Define IR types in Rust - #27
Merged
tqchen merged 1 commit intoOct 23, 2026
Merged
Conversation
Seven-Streams
marked this pull request as ready for review
October 22, 2026 16:36
Seven-Streams
marked this pull request as draft
October 22, 2026 18:15
Seven-Streams
force-pushed
the
main-dev/2026-10-21/rust-node-types
branch
from
October 23, 2026 00:10
349c17b to
f958f39
Compare
Seven-Streams
marked this pull request as ready for review
October 23, 2026 00:11
Seven-Streams
marked this pull request as draft
October 23, 2026 00:12
Seven-Streams
force-pushed
the
main-dev/2026-10-21/rust-node-types
branch
from
October 23, 2026 00:19
f958f39 to
54eade2
Compare
Seven-Streams
marked this pull request as ready for review
October 23, 2026 00:19
tqchen
approved these changes
Oct 23, 2026
Seven-Streams
force-pushed
the
main-dev/2026-10-21/rust-node-types
branch
from
October 23, 2026 01:17
54eade2 to
786f7f4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Rust could build the IR types C++ defines, but not define a new type of expressions, as
PrimTypeandTupleTypeare: a Rust type could not extendir.Typewith fields that C++ andPython see.
This bumps
3rdparty/tvm-ffito 8fd9303, the head of apache/tvm-ffi main, which has the mergedapache/tvm-ffi#869 on top of apache/tvm-ffi#870. Its
#[rs_class]defines an object type fromits object struct, whose first field
baseis the parent's object, and registers the reflectionof every other field;
def_object_ref!defines the reference to it. This PR also regenerates thebindings with that stubgen:
<Name>Obj::newand implementsShallowCopy, whichrs_classneeds of the parent. This coversir.Type,ir.Expr,ir.Stmt,ir.Attrsand seven more types.newtakes a scalar field as its own type and any other asimpl Into<T>, asthe
newof anrs_classobject does. The hand-written callers drop the.into()theyapplied to an argument, which the new parameter types make ambiguous.
custom-new, the generated allocator isfrom_fieldsinstead offrom_complete_fields([STUBGEN] Rename the custom-new allocator to from_fields tvm-ffi#870), and the hand-written constructors call it by thatname.
A Rust type can then extend
ir.Type:The C++ structural equality and hashing, deep copy,
repr, the TVMScript printer and Python seeits fields as they see a C++ type's.
tests/ir/type.rschecks this end to end:ir.Typeas aTreeNode, with each field's offset and flags;loc;seq_hash_ignorefield;reprand TVMScript print it;Varinside anEvaluate;converts through
Anyand the type hierarchy.