This is an automated email from the ASF dual-hosted git repository.

tqchen pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm-ffi.git


The following commit(s) were added to refs/heads/main by this push:
     new c8e513d5 [Fix][Rust] Map children of inline pre-order replacements 
(#784)
c8e513d5 is described below

commit c8e513d5525189bcf06afdc30aac33e862b9e5fd
Author: Shushi Hong <[email protected]>
AuthorDate: Sun Sep 13 22:31:03 2026 -0400

    [Fix][Rust] Map children of inline pre-order replacements (#784)
    
    When a pre-order callback replaces an inline value with an object, map
    the replacement children through the existing default-root path. Keep
    inline results and post-order replacements on the direct return path.
---
 rust/tvm-ffi/src/extra/structural_mutate.rs | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/rust/tvm-ffi/src/extra/structural_mutate.rs 
b/rust/tvm-ffi/src/extra/structural_mutate.rs
index effebda0..1d630e63 100644
--- a/rust/tvm-ffi/src/extra/structural_mutate.rs
+++ b/rust/tvm-ffi/src/extra/structural_mutate.rs
@@ -1434,7 +1434,15 @@ impl<D: MapDispatch> NativeMapper<D> {
         if is_plain_inline(raw.type_index) {
             let value = MapValue::from_raw(raw);
             return match self.dispatch.dispatch_map(&value, def_region_kind) {
-                Some(result) => result,
+                Some(result) => {
+                    let mapped = result?;
+                    // A pre-order callback may replace an inline leaf with a 
subtree.
+                    if self.order == WalkOrder::PreOrder && 
!is_plain_inline(mapped.type_index()) {
+                        self.map_default_root(&mapped, def_region_kind, 
Permit::MaybeInPlace)
+                    } else {
+                        Ok(mapped)
+                    }
+                }
                 // SAFETY: `is_plain_inline` excludes every borrowed
                 // representation that needs normalization.  These values own
                 // no external resource, so their owning form is the same

Reply via email to