feat: add ffi.GetInvalidObject global function for MISSING singleton#447
feat: add ffi.GetInvalidObject global function for MISSING singleton#447tqchen merged 1 commit intoapache:mainfrom
ffi.GetInvalidObject global function for MISSING singleton#447Conversation
Summary of ChangesHello @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 refactors the handling of "missing" or "invalid" object states by introducing a dedicated C API for a global singleton. This change generalizes the pattern previously specific to map operations, providing a more direct and consistent way to access this sentinel value across the FFI boundary. It simplifies Python-side integration by exposing a 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 introduces a new C API TVMFFIAnyGetInvalidObject to provide a global singleton for the invalid/missing object, generalizing a pattern that was previously specific to Map FFI functions. The changes are well-structured, spanning the C++ implementation, C API headers, Cython bindings, and Python-level usage. The old FFI function MapGetMissingObject is correctly removed, and usages are updated to the new MISSING global from tvm_ffi.core. The addition of both C++ and Python unit tests ensures the new functionality is correct and robust. Overall, this is a solid improvement that enhances the FFI's consistency and usability. I have a couple of minor suggestions to improve code style in the new C++ test.
fe3f68c to
3b4cbef
Compare
TVMFFIAnyGetInvalidObject C API for global invalid object singleton3b4cbef to
9afb0a2
Compare
C++ changes: - Register `ffi.GetInvalidObject` global function in container.cc - Remove `ffi.MapGetMissingObject` in favor of the new name Python changes: - Initialize `MISSING` in core.pyx via `_get_global_func` after `Function` is registered - Re-export `MISSING` in container.py from core - Add `MISSING: Object` to core.pyi type stub - Update _ffi_api.py stubs and __all__ Tests: - Add `test_missing_object` verifying singleton identity across imports and Map.get() integration
9afb0a2 to
7ed6fef
Compare
ffi.GetInvalidObject global function for MISSING singleton
C++ changes:
ffi.GetInvalidObjectglobal function in container.ccffi.MapGetMissingObjectin favor of the new namePython changes:
MISSINGin core.pyx via_get_global_funcafterFunctionis registeredMISSINGin container.py from coreMISSING: Objectto core.pyi type stubTests:
test_missing_objectverifying singleton identity across imports and Map.get() integration