Skip to content

Conversation

@junrushao
Copy link
Member

No description provided.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @junrushao, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the project's documentation by introducing a detailed and structured overview of the TVM-FFI Application Binary Interface. The new documentation clarifies the fundamental design principles, data structures, and interaction patterns of the ABI, supported by concrete C code examples. This addition aims to provide developers with a clearer understanding of how to work with TVM-FFI at a low level, improving the accessibility and maintainability of the system.

Highlights

  • New ABI Overview Documentation: A new reStructuredText document (docs/concepts/abi_overview.rst) has been added, providing a comprehensive overview of the TVM-FFI ABI. This document details core principles, data types like Any, Object, Tensor, Function, Exception, Module, and String/Byte types, and their usage patterns.
  • Accompanying C Code Examples: A new C example file (examples/abi_overview/example_code.c) has been introduced to provide practical, low-level demonstrations for the ABI concepts explained in the new documentation.
  • Documentation Structure Refinement: The existing docs/index.rst has been updated to include the new ABI overview, and docs/concepts/any.rst and docs/concepts/object_and_class.rst have been modified to add internal cross-reference labels, improving navigability and consistency.
  • Migration of Legacy ABI Doc: The previous Markdown-based ABI overview (docs/concepts/abi_overview.md) has been renamed to docs/concepts/abi_overview_legacy.rst, indicating a shift towards reStructuredText for core documentation.
  • C API Header Annotations: The include/tvm/ffi/c_api.h file now includes // [TAG.begin] and // [TAG.end] comments around key ABI structure and enum definitions, facilitating automatic inclusion of code snippets in the new documentation.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @junrushao, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the TVM-FFI documentation by introducing a new, comprehensive overview of its Application Binary Interface (ABI). The new document, written in reStructuredText and supported by concrete C code examples, aims to clarify the fundamental principles, data structures, and interaction patterns of the FFI system. This change improves the accessibility and understanding of TVM-FFI's low-level mechanisms for developers, ensuring a more robust and maintainable codebase.

Highlights

  • New ABI Overview Documentation: A comprehensive reStructuredText document, docs/concepts/abi_overview.rst, has been added. This document provides a detailed overview of the TVM-FFI Application Binary Interface (ABI), covering its core principles, data types (Any, Object, Tensor, Function, Exception, Module, String, and Byte), and usage patterns with low-level C code examples.
  • Accompanying C Code Examples: A new C example file, examples/abi_overview/example_code.c, has been introduced. This file contains practical code snippets that are directly referenced within the abi_overview.rst document, illustrating how to interact with the TVM-FFI ABI concepts in C.
  • Documentation Structure and Cross-Referencing Improvements: The main documentation index (docs/index.rst) has been updated to include the new ABI overview. Additionally, existing documentation files (docs/concepts/any.rst, docs/concepts/object_and_class.rst) have been modified to add specific cross-reference targets, enhancing navigation and linking within the documentation set.
  • C API Header Annotations: The include/tvm/ffi/c_api.h file has been augmented with // [TAG.begin] and // [TAG.end] markers around key C ABI struct and enum definitions. These annotations are crucial for documentation generation tools, allowing specific code sections to be directly embedded and referenced in the new ABI overview.
  • Legacy Document Handling: The previous ABI overview document, docs/concepts/abi_overview.md, has been renamed to docs/concepts/abi_overview_legacy.rst. This indicates a transition to a new, more detailed, and structured ABI documentation approach.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

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

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 comprehensive documentation for the TVM-FFI ABI, complete with low-level C code examples. The changes are well-organized, adding a new overview page, example code, and updating existing documentation and header files to support the new content. My review has identified a critical bug in an example C function and a few minor areas for improvement in the documentation for clarity and completeness.

Copy link
Contributor

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

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 a comprehensive ABI overview document, which is a great addition. I've found a few areas in the new documentation that could be improved for clarity and correctness, including a grammatical error, a 'TBA' placeholder, and a minor wording issue. More importantly, I've identified a bug in one of the C code examples where a function incorrectly handles type casting, which could lead to incorrect behavior. My review includes suggestions to fix these issues.

@junrushao junrushao force-pushed the 2026-01-10/abi-overview-revamp branch from eb6b498 to ee05592 Compare January 12, 2026 08:09
@junrushao junrushao marked this pull request as ready for review January 12, 2026 08:10
@junrushao junrushao force-pushed the 2026-01-10/abi-overview-revamp branch 3 times, most recently from 3c8aa93 to 23351c1 Compare January 12, 2026 08:14
@junrushao
Copy link
Member Author

/gemini review

Copy link
Contributor

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

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 is a significant and valuable documentation refactoring. It introduces a new, comprehensive document, abi_overview.rst, to serve as a central reference for the TVM FFI C ABI. Consequently, other related documents have been streamlined by removing duplicated C-level details and adding links to this new central page. This change greatly improves the structure and maintainability of the documentation. The new document is well-written and effectively uses literalinclude to embed code snippets from a dedicated example file, which is an excellent practice. My review includes a couple of suggestions to further enhance the clarity of the new abi_overview.rst document. Overall, this is a high-quality contribution.

@junrushao junrushao requested a review from tqchen January 12, 2026 08:37
@junrushao junrushao force-pushed the 2026-01-10/abi-overview-revamp branch 4 times, most recently from 74acc9b to a50c8db Compare January 12, 2026 22:44
@junrushao
Copy link
Member Author

/gemini Review

Copy link
Contributor

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

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 is a significant and valuable documentation refactoring. It centralizes the TVM FFI ABI low-level details into a new abi_overview.rst document, which improves maintainability and clarity. The old markdown version is removed, and other documentation files are updated to link to the new central document, removing duplicated content. A new C file with code examples is also added to support the new documentation.

The changes are well-executed. I have a couple of suggestions to improve the new code examples in abi_overview.rst by adding explicit notes about resource management. This will help prevent potential resource leaks for users who copy-paste the examples.

@junrushao junrushao force-pushed the 2026-01-10/abi-overview-revamp branch 2 times, most recently from e449e34 to 0d62310 Compare January 12, 2026 22:54
@junrushao junrushao requested a review from tqchen January 12, 2026 22:55
@junrushao junrushao force-pushed the 2026-01-10/abi-overview-revamp branch from 0d62310 to 60259e2 Compare January 13, 2026 05:21
@tqchen
Copy link
Member

tqchen commented Jan 13, 2026

some followup notes

- ``result`` (``TVMFFIAny*``): Owning :cpp:class:`~tvm::ffi::Any` output value
- Return value: ``0`` for success; ``-1`` or ``-2`` for errors (see :ref:`sec:exception`)

See :ref:`sec:function-calling-convention` for more details.
Copy link
Member

Choose a reason for hiding this comment

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

need note


Before calling the function, caller must set `result->type_index` to be kTVMFFINone, or any type index that do not corresponds to an on-heap object.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's covered in another doc: https://tvm.apache.org/ffi/concepts/func_module.html#tvm-ffi-c-abi. but happy to emphasize it

@junrushao junrushao force-pushed the 2026-01-10/abi-overview-revamp branch from 60259e2 to e38261d Compare January 13, 2026 19:01
@junrushao junrushao merged commit c78e8b4 into apache:main Jan 13, 2026
12 of 13 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.

2 participants