From 523a9b69ac8709c0f385d74ff10b4452cbdd6d48 Mon Sep 17 00:00:00 2001 From: adrien Date: Mon, 18 May 2026 23:21:26 +0200 Subject: [PATCH] .Synthax --- README.md | 3 ++- examples/digit.zig | 12 +++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 210a0b0..d3ed885 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Minimal Zig WebGPU Compute Library -This is a minimal, self-contained Zig library designed to simplify running compute shaders using WebGPU. It abstracts away much of the boilerplate required for GPU device initialization, memory management, and pipeline execution. +This is a minimal, self-contained Zig library designed to simplify running compute shaders using WebGPU. +It abstracts away much of the boilerplate required for GPU device initialization, memory management, and pipeline execution. ## Core Modules diff --git a/examples/digit.zig b/examples/digit.zig index 2b9ac7e..20f35a6 100644 --- a/examples/digit.zig +++ b/examples/digit.zig @@ -27,7 +27,17 @@ pub fn main(init: std.process.Init) !void { const add_process = try GpuProcess.init(device, @embedFile("shaders/add.wgsl")); defer add_process.deinit(); - for (EPOCH) |epoch| {} + var train_dir = try std.Io.Dir.cwd().openDir(io, "mnist/train", .{}); + + var images: [BATCHSIZE * 28 * 28]f16 = undefined; + for (EPOCH) |epoch| { + // Load random images from train dir + train_dir.openDir(io, "0", .{}); + for (BATCHSIZE) |i| { + const file = try train_dir.openFile(io, "0.jpg", .{}); + images[28 * 28 * i .. 28 * 28 * (i + 1)] = file.read + } + } // 4. Setup CPU data const len: usize = 16;