Modern Apps git

← Modern-Apps.git

ml: full-window conv (mbf 7x7 GDC) as ConvPoint, mbf 32 -> 24 ms on Pixel

Commit
d563dbe349835baa2326f71545c110bf093e44e3
Author
vayun-mathur <[email protected]>
When
2026-10-26 00:38 UTC (1 month ago)
Parents
260cd31

Diff

library/ml/src/main/rust/src/nets/mod_part9.rs
diff --git a/library/ml/src/main/rust/src/nets/mod_part9.rs b/library/ml/src/main/rust/src/nets/mod_part9.rsindex 625c1effeb..0830c776be 100644--- a/library/ml/src/main/rust/src/nets/mod_part9.rs+++ b/library/ml/src/main/rust/src/nets/mod_part9.rs@@ -175,7 +175,18 @@ impl<'a> Builder<'a> {                     && pad == &(0, 0)                     && si.h == so.h                     && si.w == so.w;-                if tiled {+                // A kernel covering the whole unpadded input (mbf's 7x7 GDC) is one dot product+                // per channel over the flattened input: a 1x1 over `c * h * w` channels.+                let full_window = !*transpose+                    && *group == 1+                    && kernel == &(si.h, si.w)+                    && dilation == &(1, 1)+                    && pad == &(0, 0)+                    && so.h == 1+                    && so.w == 1;+                if tiled || full_window {+                    let (in_c, in_h, in_w) =+                        if full_window { (si.len(), 1, 1) } else { (si.c, si.h, si.w) };                     let positions = so.h * so.w;                     let tiles =                         so.c.div_ceil(CONV_POINT_TILE) * positions.div_ceil(CONV_POINT_TILE);@@ -187,9 +198,9 @@ impl<'a> Builder<'a> {                             weight: *weight,                             bias: *bias,                             act_weight: *act_weight,-                            in_c: si.c,-                            in_h: si.h,-                            in_w: si.w,+                            in_c,+                            in_h,+                            in_w,                             out_c: so.c,                             out_h: so.h,                             out_w: so.w,
library/ml/src/main/rust/src/vulkan/parity_part6.rs
diff --git a/library/ml/src/main/rust/src/vulkan/parity_part6.rs b/library/ml/src/main/rust/src/vulkan/parity_part6.rsindex 9e39106686..c1ebdfdbd6 100644--- a/library/ml/src/main/rust/src/vulkan/parity_part6.rs+++ b/library/ml/src/main/rust/src/vulkan/parity_part6.rs@@ -564,4 +564,23 @@ fn int8_gemms_either_side_of_the_split_threshold_agree_with_the_reference() {         let what = format!("an int8 gemm {out_channels}x{width} at in1 = {split}");         compare(&what, plan, weights.data().to_vec(), &[&input]);     }+}++/// A kernel covering its whole input (mbf's 7x7 GDC) lowers to `conv_point.comp` over the+/// flattened input; a non-square 5x7 window and 20 output channels keep it ragged.+#[test]+#[ignore = "needs a Vulkan device"]+fn a_full_window_conv_agrees_with_the_reference() {+    let input = spread(24 * 5 * 7, 2.0);+    let source = Invented::new(2);+    let plan = build(&source, &[Shape::new(24, 5, 7)], |b, ids| {+        b.spatial_tiling();+        b.conv(ids[0], 0, 20, (5, 7), (1, 1), (1, 1), (0, 0, 0, 0), 1, Act::Relu)+    });+    assert!(plan.ops.iter().any(|op| matches!(+        op,+        crate::nets::Op::Dispatch { kind: crate::nets::Kind::ConvPoint, push, .. }+            if push.in_c == 24 * 5 * 7+    )));+    compare("a full-window conv", plan, source.into_data(), &[&input]); }\ No newline at end of file