You are viewing a plain text version of this content. The canonical link for it is here.
Posted to discuss-archive@tvm.apache.org by GitBox <gi...@apache.org> on 2026/02/28 01:24:22 UTC
[GH] (tvm-ffi/2026-02-27/auto-init-python): Workflow run "CI" failed!
The GitHub Actions job "CI" on tvm-ffi.git/2026-02-27/auto-init-python has failed.
Run started by GitHub user junrushao (triggered by junrushao).
Head commit for run:
8ca0552fd6fd87c9e9989d02a6fd15b179d16988 / Junru Shao <ju...@nvidia.com>
feat(python): wire C++ auto-generated __ffi_init__ to Python __init__
Architecture:
- TypeField dataclass extended with c_init, c_kw_only, c_has_default
flags decoded from the C++ TVMFFIFieldFlagBitMask bitmask
(kTVMFFIFieldFlagBitMaskInitOff, kTVMFFIFieldFlagBitMaskKwOnly).
- New _make_init() builds a Python __init__ that translates *args/**kwargs
into the KWARGS sentinel protocol expected by C++ auto-generated
__ffi_init__, enabling transparent Pythonic construction of C++ objects.
- New _make_init_signature() walks the parent TypeInfo chain to collect
inherited fields, respects init/kw_only/has_default traits, and emits a
valid inspect.Signature with required-before-optional ordering.
- _install_init() replaces the old inline __init__ assignment with a
three-way dispatch: auto-init (KWARGS-aware), plain __ffi_init__, or a
guard TypeError for uninitializable types. Moves type_info attachment
before _add_class_attrs so the info is available during init installation.
- KWARGS sentinel object exposed from C++ via ffi.GetKwargsObject and
stored as core.KWARGS module-level constant.
Public Interfaces:
- TypeField gains c_init, c_kw_only, c_has_default bool attrs (default
True, False, False) — purely additive, no breaking change to TypeField.
- core.KWARGS: new module-level Object sentinel.
- _install_init() accepts enabled kwarg; register_object always passes
enabled=True. @c_class can pass enabled=False for init=False classes.
- Ruff D107 (undocumented-public-init) suppressed project-wide since
auto-generated __init__ methods carry no docstring.
- tvm_ffi.testing exports 7 new test classes (_TestCxxAutoInit*,
_TestCxxNoAutoInit).
UI/UX:
- Users can now construct C++ reflected objects with natural Python syntax
(positional, keyword, mixed) instead of raw __ffi_init__ calls.
Behavioral Changes:
- Objects with auto_init metadata get a kwargs-aware __init__ with proper
inspect.Signature; previously they received a raw __ffi_init__ wrapper.
- Objects without __ffi_init__ now raise TypeError with actionable guidance
instead of a generic RuntimeError.
- _add_class_attrs reorder: __tvm_ffi_type_info__ set before method
installation so _install_init can read it.
Docs:
- TYPE_CHECKING stubs added for all new test classes documenting expected
constructor signatures.
- No user-facing docs updated; follow-up needed for the c_class/reflection
usage guide.
Tests:
- Executed: N/A (cherry-pick from tested branch)
- 895-line test_dataclass_init.py covering metadata, signature layout,
construction (positional/kw/mixed/inherited), error paths, low-level
KWARGS protocol, copy/deepcopy/replace, reinit, isinstance, isolation,
and error message field naming after stable_partition reordering.
Untested Edge Cases:
- Thread safety of concurrent __ffi_init__ calls on the same object.
- Objects with >64 fields (bitmask width assumption).
Report URL: https://github.com/apache/tvm-ffi/actions/runs/22510116824
With regards,
GitHub Actions via GitBox
---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org