Skip to content

Add resident GPU Canny edge extraction - #180

Merged
rsasaki0109 merged 1 commit into
mainfrom
codex/gpu-canny
Oct 13, 2026
Merged

rsasaki0109 merged 1 commit into
mainfrom
codex/gpu-canny

Conversation

@rsasaki0109

Copy link
Copy Markdown
Owner

CPU Canny required returning resident image data to the host before gradient, suppression and weak/strong edge connectivity.

Add canny_gpu and its optional profiled variant under gpu-image. Signed integer Sobel gradients support 3/5/7 apertures; exact threshold conversion, L1/squared-L2 comparisons, aperture-7 ties-to-even scaling and directional NMS ties match CPU semantics. Weak candidates form complete eight-neighbor components using monotone atomic union/path halving. Each weak component is flagged when it touches a strong pixel; strong pixels survive directly. This preserves full hysteresis without a propagation cutoff or host convergence/readback.

Five/six passes share one submission and return an owned binary GpuImage with preserved dimensions/metadata. Input remains borrowed; grayscale conversion and blur remain explicit caller stages. Source/output/runtime ownership, private submitted scratch, buffer/binding/workgroup and profiler checks are validated before resource/cache allocation. Uniform controls are 96 bytes; no image/label readback, repeated image upload, CPU fallback or automatic placement occurs. Receipt documentation clarifies per-stage destination footprints versus repeated atomic byte traffic.

Validation:

  • 864 exact CPU conditions / 367,056 edge bytes across apertures, norms, threshold boundaries/reversal/extremes, strips and four profiles.
  • 24 owned f64-gradient/NMS/BFS snapshots, including forced grid strides; 18 graph masks with complete roots/flags/output checks, long 1025x1025 weak snakes, far strong seed and a broken path.
  • All 326,401 possible signed aperture-7 raw derivative values match independent binary64 ties-to-even rounding.
  • Invalid limits/runtime/options/profiler allocation guards, strided ROI metadata, four concurrent retained results, dirty scratch, timestamp receipts and Gaussian/Canny/AI resident chaining.
  • GPU image regression: 85 passed / 14 intentionally ignored measurement fixtures. Facade smoke, Clippy all features/targets, formatting, feature-free GPU and GPU-image WASM checks passed; final weak-only connectivity also passed all six Canny tests.
  • Two isolated release surveys: 12 cases, four stages, three warmups and 20 rotating paired rounds, all output-byte exact. Completed upload/filter/readback calls for apertures 5/7 are 4.98-7.55x current CPU API speed at 1080p and 6.60-13.55x at 4K. Aperture-3 completed calls are slower on GPU, and resident gains are not universal. The CPU 5/7 into path still allocates inspectable intermediates; large GPU memory/time spikes and all adverse samples are documented.

Private scratch is 28N+8 bytes (3) or 36N (5/7), with a largest 16*N binding. Memory/device limits remain explicit; no production dependency, core model, CPU algorithm or unsafe boundary changes. Existing Vision-chain defaults remain.

Evidence: C:/Users/rsasa/Workspace/SpatialRust/notes/2026-10-13_gpu_canny.md. Architecture, ROADMAP and CHANGELOG describe the final weak-component algorithm, output/transfer contract and measured tradeoffs. Follows merged PR #179.

@rsasaki0109
rsasaki0109 merged commit af2320f into main Oct 13, 2026
125 checks passed
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