feat(cython): expose additional C API symbols in base.pxi#502
Conversation
Sync the Cython declarations in `base.pxi` with the current C API header so that Python-side type registration and error handling can call these symbols directly through Cython rather than via ctypes. Changes: - Add type-registration functions: TVMFFITypeGetOrAllocIndex, TVMFFITypeRegisterField, TVMFFITypeRegisterMetadata, TVMFFITypeRegisterAttr, TVMFFIErrorSetRaisedFromCStr - Add missing field-flag constants: SEqHashIgnore, SEqHashDef, ReprOff, CompareOff, HashOff - Add TVMFFISEqHashKind enum for structural equality/hash kinds - Fix TVMFFITypeMetadata.total_size type (int64_t -> int32_t) and add structural_eq_hash_kind field to match the C struct layout - Add cause_chain and extra_context fields to the error info struct
Summary of ChangesHello, 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 enhances the Cython FFI bindings by exposing critical C API symbols and constants, ensuring better alignment between the Python and C interfaces. These changes facilitate more robust Python-side type registration, error handling, and structural equality hashing by providing direct access to underlying C functionalities and correcting struct definitions. Highlights
🧠 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. Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request updates the Cython definitions in python/tvm_ffi/cython/base.pxi to expose additional C API symbols. The changes include adding new fields to TVMFFIErrorCell, new constants to TVMFFIFieldFlagBitMask, defining the TVMFFISEqHashKind enum, and updating TVMFFITypeMetadata to match the C struct layout. Additionally, several new function declarations from the FFI C API are added. The changes align the Cython definitions with the C header files and appear correct.
Summary
TVMFFITypeGetOrAllocIndex,TVMFFITypeRegisterField,TVMFFITypeRegisterMetadata,TVMFFITypeRegisterAttr,TVMFFIErrorSetRaisedFromCStr) so Python-side type registration can call these symbols directly through CythonSEqHashIgnore,SEqHashDef,ReprOff,CompareOff,HashOff) and theTVMFFISEqHashKindenumTVMFFITypeMetadata.total_sizetype (int64_t->int32_t) and addstructural_eq_hash_kindfield to match the C struct layoutcause_chainandextra_contextfields to the error info structTest plan
uv pip install --force-reinstall --verbose -e .🤖 Generated with Claude Code