From 96a349b9874c6cdaac525ba062a0f4f90c9bc3ed Mon Sep 17 00:00:00 2001 From: skal Date: Tue, 10 Feb 2026 10:27:44 +0100 Subject: feat: Add coordinate-aware CNN layer 0 for position-dependent stylization - Implement CoordConv2d custom layer accepting (x,y) patch center - Split layer 0 weights: rgba_weights (9x mat4x4) + coord_weights (mat2x4) - Add *_with_coord() functions to 3x3/5x5/7x7 convolution shaders - Update training script to generate coordinate grid and export split weights - Regenerate placeholder weights with new format Size impact: +32B coord weights + ~100B shader code = +132B total All 36 tests passing (100%) handoff(Claude): CNN coordinate awareness implemented, ready for training Co-Authored-By: Claude Sonnet 4.5 --- workspaces/main/shaders/cnn/cnn_weights_generated.wgsl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'workspaces/main/shaders/cnn/cnn_weights_generated.wgsl') diff --git a/workspaces/main/shaders/cnn/cnn_weights_generated.wgsl b/workspaces/main/shaders/cnn/cnn_weights_generated.wgsl index 98c17ff..e0a7dc4 100644 --- a/workspaces/main/shaders/cnn/cnn_weights_generated.wgsl +++ b/workspaces/main/shaders/cnn/cnn_weights_generated.wgsl @@ -2,8 +2,8 @@ // DO NOT EDIT MANUALLY - regenerate with scripts/train_cnn.py // Placeholder identity-like weights for initial testing -// Layer 0: 3x3 convolution -const weights_layer0: array, 9> = array( +// Layer 0: 3x3 convolution with coordinate awareness +const rgba_weights_layer0: array, 9> = array( mat4x4(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), mat4x4(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), mat4x4(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), @@ -14,4 +14,10 @@ const weights_layer0: array, 9> = array( mat4x4(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), mat4x4(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) ); + +const coord_weights_layer0 = mat2x4( + 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0 +); + const bias_layer0 = vec4(0.0, 0.0, 0.0, 0.0); -- cgit v1.2.3