Skip to content

perf(vision): fuse resize normalization and CHW packing - #46

Merged
rsasaki0109 merged 1 commit into
mainfrom
agent/fused-resize-chw
Jul 15, 2026
Merged

perf(vision): fuse resize normalization and CHW packing#46
rsasaki0109 merged 1 commit into
mainfrom
agent/fused-resize-chw

Conversation

@rsasaki0109

Copy link
Copy Markdown
Owner

Summary

  • add safe allocating and caller-owned APIs that fuse Q11 bilinear RGB resize, float normalization, and planar CHW packing
  • avoid the intermediate resized HWC image while preserving reusable plan semantics, strided input, metadata, and arbitrary scale/mean/std
  • expose resize_normalize_image_chw(..., out=...) in Python with synchronized stubs and tests
  • add native Criterion coverage, a paired OpenCV blobFromImage harness, README/roadmap/GitHub Pages updates, and a dated receipt
  • complete Epic 115C

Results

Against OpenCV 4.13 cv2.dnn.blobFromImage on the recorded 12-thread Windows host, SpatialRust allocated calls measured:

  • 1080p to 640x640: 1.617 ms vs 3.570 ms, 2.21x faster
  • 4K to 640x640: 2.117 ms vs 4.272 ms, 2.02x faster
  • 4K to 1280x720: 3.592 ms vs 8.359 ms, 2.33x faster

Caller-owned SpatialRust output is 3.02x-3.56x faster than OpenCV allocation. Native fused reuse improves over SpatialRust unfused reuse by 1.10x-1.15x.

Fused output is bit-exact with SpatialRust's unfused plan for arbitrary normalization parameters. Three hundred randomized OpenCV comparisons have maximum float error 0.003921628 (one uint8 level after 1/255 scaling).

Validation

  • cargo test -p spatialrust-vision --features full (124 unit, 13 property)
  • vision and Python clippy
  • Python binding pytest
  • release maturin build
  • paired OpenCV harness with 300 randomized cases
  • rustdoc, rustfmt, py_compile, and diff checks

@rsasaki0109
rsasaki0109 marked this pull request as ready for review July 15, 2026 23:08
@rsasaki0109
rsasaki0109 merged commit 1179f15 into main Jul 15, 2026
86 of 92 checks passed
@rsasaki0109
rsasaki0109 deleted the agent/fused-resize-chw branch July 15, 2026 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant