tqchen opened a new pull request, #598: URL: https://github.com/apache/tvm-ffi/pull/598
## Summary Register a custom `__ffi_repr__` for `ffi::reflection::AccessPath` and `AccessStep` so their formatted output is a concise, human-readable path expression: ``` <root>.config.layers[0][<missing:"weights">] ``` Per-step rendering: - root: `<root>` - attr: `.name` - array item: `[index]` - map item: `[<repr(key)>]` (string keys quoted) - missing attr: `[<missing:"name">]` - missing array: `[<missing:index>]` - missing map: `[<missing:<repr(key)>>]` The formatter delegates key quoting to the existing `EscapedStringPy` path via `fn_repr(step->key)`, so non-string map keys are also handled robustly. ## Files - `src/ffi/extra/reflection_extra.cc` — extend the existing `TVM_FFI_STATIC_INIT_BLOCK` with two new `TypeAttrDef` `__ffi_repr__` registrations for `AccessStepObj` and `AccessPathObj`. - `tests/cpp/extra/test_access_path_repr.cc` — new file, one TEST covering all six step kinds plus root in a single path. ## Test plan - [x] `cmake . -B build_test -DTVM_FFI_BUILD_TESTS=ON -DTVM_FFI_USE_EXTRA_CXX_API=ON -DCMAKE_BUILD_TYPE=Debug && cmake --build build_test --target tvm_ffi_tests` clean. - [x] `tvm_ffi_tests --gtest_filter='AccessPathRepr.*'` passes. - [x] Broader test suite passes (381 tests, no regressions). - [x] `pre-commit run --all-files` clean (all hooks pass; `ty` failure on `._version` is a pre-existing issue on upstream main, not introduced by this change). ## Out of scope Downstream consumers that carry their own `AccessPath`/`AccessStep` repr registrations should remove them after a submodule bump to avoid double-registration. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
