Skip to main content

tiled_scatter

Function tiled_scatter 

Source
pub fn tiled_scatter(
    grid: &Grid,
    mask: &[u8],
    cfg: &TileConfig,
    run_tile: impl Fn(&Tile) -> Result<Vec<f64>, OnnxError> + Sync,
    progress: impl FnMut(usize, usize),
) -> Result<Vec<f64>, OnnxError>
Expand description

Shared overlap-tiling driver. Enumerates the core-aligned tiles that actually touch mask (all-background tiles are skipped → work is restricted to the mask bounding box for free), runs each through run_tile, and scatters the results back into a full-volume buffer (masked). Handles the empty-tile skip, parallel batching, and progress reporting so each model only supplies its own per-patch logic.

run_tile(&tile) must return the tile’s post-processed core block — row-major oi,oj,ok, length cx·cy·cz — and be pure + Sync (it may run on many threads at once, each holding one patch’s activations in the shared wasm heap). progress(done, total) is called from the driver thread only (the JS callback isn’t Sync).