The GitHub Actions job "mainline-only" on tvm-ffi.git/main has failed.
Run started by GitHub user tqchen (triggered by tqchen).

Head commit for run:
42d4be739fc452651b808f3cc6f2c87c17847b27 / Tianqi Chen 
<[email protected]>
[REFACTOR][EXTRA] Optimize StructuralMap engine (#741)

This PR improves the `StructuralMap` engine by bringing lambda callback
style to direct calling style. We also internally used the raw
`TVMFFIAny` ABI path so engine overhead is minimized in the default
path.

Main changes:

- **Direct calling style.** The callback chain was continuation-passing,
a lambda nested per link. The mutator now owns its callbacks and tests
them with a `(... || ...)` fold; selection, identity remap, descent, and
invocation are one straight-line function.
- **Raw `TVMFFIAny` on the ABI boundary.** Hooks are C-ABI function
pointers returning `TVMFFIAny`, a 16-byte POD that passes in registers,
while `Expected<Any>` is classified MEMORY and forces the result to the
stack. Descent through an unmatched node is that boundary, so it now
stays raw end to end. Hook bodies are unchanged:
`TVM_FFI_S_MUTATE_ASSIGN_OR_RETURN` still takes a typed `Expected<Any>`
and moves out only on return.
- **Split static and dynamic selection.** `StructuralMapMutatorObj`
(header) and `StructuralMapDynMutatorObj` (`.cc`) now share only the
identity remap. This also removes a hazard: the dynamic form kept its
selected `Function` in mutable state, where a post-order walk could
descend into a matching child and overwrite the parent's selection.
- **Error context is attached by the engine, not by hooks.** The engine
names a node where it dispatches into that node, giving one frame per
node instead of two on some paths. Both `MAYBE_EARLY_RETURN` macros lose
their node argument, and the visit engine no longer routes its own walk
through the hook-facing macro.
- **API.** Removes `TVM_FFI_S_MUTATE_ASSIGN_FROM`,
`SMutateResultUnchanged`, `AssignOrReturnHelper`, and
`MutateWithIdentityRemapExpected`. Adds
`TVM_FFI_UNSAFE_S_MUTATE_ASSIGN_OR_RETURN_SKIP_CHECK` for hooks that
have measured the type check to matter; it is UB on a wrong-typed result
and has no call sites here. Also fixes `AnyUnsafe::CheckAnyStrict`,
which was missing the `Any` special case both of its siblings had.
- **Behavior change.** When descent hands back a node whose type no
longer matches the link that selected it, the engine reports a
`TypeError` instead of passing the node through. Default mutation must
preserve a node's type, so this only fires when a hook has broken that
invariant. Match-before-descent ordering, identity-remap entry and exit,
and the pre-order in-place rules are unchanged.

Report URL: https://github.com/apache/tvm-ffi/actions/runs/33934177348

With regards,
GitHub Actions via GitBox


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to