Skip to content

[FEAT][RUST]Add tvm_ffi::optional in Rust#630

Merged
tqchen merged 3 commits into
apache:mainfrom
Seven-Streams:main-dev/2026-06-17/rust_stubgen_optional
Jul 4, 2026
Merged

[FEAT][RUST]Add tvm_ffi::optional in Rust#630
tqchen merged 3 commits into
apache:mainfrom
Seven-Streams:main-dev/2026-06-17/rust_stubgen_optional

Conversation

@Seven-Streams

@Seven-Streams Seven-Streams commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

This PR supports ffi::optionalPod, ffi::optionalStr in Rust. It keeps the same memory layout as C++'s ffi::optional.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces Rust stub generation capabilities to tvm-ffi-stubgen, allowing the automatic creation of typed Rust bindings (including structs, builders, and methods) from C++ reflection metadata. It also adds a layout-mirror Optional type in Rust to support C++ ffi::Optional fields. The feedback highlights two key issues: first, the Optional type automatically infers as !Send and !Sync due to its UnsafeCell field, which should be fixed by manually implementing these traits when T is thread-safe; second, a potential ZeroDivisionError in the alignment calculation within the Python codegen should be prevented by ensuring the alignment value is at least 1.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread rust/tvm-ffi/src/optional.rs Outdated
Comment thread python/tvm_ffi/stub/rust_generator/codegen.py Outdated
@Seven-Streams Seven-Streams force-pushed the main-dev/2026-06-17/rust_stubgen_optional branch from 7092721 to 5b2ebc1 Compare June 18, 2026 18:11
@Seven-Streams Seven-Streams force-pushed the main-dev/2026-06-17/rust_stubgen_optional branch from 47230a0 to 8fb2a15 Compare July 1, 2026 14:54
@Seven-Streams Seven-Streams changed the title [RUST][STUBGEN]Add tvm_ffi::optional in Rust for stubgen [FEAT][RUST]Add tvm_ffi::optional in Rust Jul 1, 2026
Comment thread rust/tvm-ffi/src/option.rs
Comment thread rust/tvm-ffi/src/collections/optional.rs Outdated
@Seven-Streams Seven-Streams force-pushed the main-dev/2026-06-17/rust_stubgen_optional branch from 66d64af to d27ac98 Compare July 4, 2026 00:21
@Seven-Streams Seven-Streams force-pushed the main-dev/2026-06-17/rust_stubgen_optional branch 2 times, most recently from a82f443 to f56180f Compare July 4, 2026 00:39
Signed-off-by: yuchuan <yuchuan.7streams@gmail.com>
@Seven-Streams Seven-Streams force-pushed the main-dev/2026-06-17/rust_stubgen_optional branch from f56180f to cb5f5b0 Compare July 4, 2026 00:39
Comment thread include/tvm/ffi/optional.h Outdated
@Seven-Streams

Copy link
Copy Markdown
Contributor Author

@Seven-Streams Seven-Streams reopened this Jul 4, 2026
@tqchen tqchen merged commit 458aaf7 into apache:main Jul 4, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants