summaryrefslogtreecommitdiff
path: root/doc/CNN_TEST_TOOL.md
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-14 00:00:26 +0100
committerskal <pascal.massimino@gmail.com>2026-02-14 00:00:26 +0100
commit71ff356ef03b5d07bcd7a36b79cf95df1206717b (patch)
tree7a4adf5972e850dc8b300355923c0ae2a59686d0 /doc/CNN_TEST_TOOL.md
parent0570941761936d74b573801c45385f4baaa6399c (diff)
cnn_test: --weights now overrides layer config from .bin file
When using --weights option: - Layer count and kernel sizes loaded from binary header - Warnings shown if --layers or --cnn-version specified - Help text clarifies precedence order - Binary weights always take precedence over CLI args Updated documentation: - doc/CNN_TEST_TOOL.md: Usage examples with --weights - doc/HOWTO.md: Runtime weight loading example handoff(Claude): cnn_test --weights config override
Diffstat (limited to 'doc/CNN_TEST_TOOL.md')
-rw-r--r--doc/CNN_TEST_TOOL.md19
1 files changed, 16 insertions, 3 deletions
diff --git a/doc/CNN_TEST_TOOL.md b/doc/CNN_TEST_TOOL.md
index 82d5799..4307894 100644
--- a/doc/CNN_TEST_TOOL.md
+++ b/doc/CNN_TEST_TOOL.md
@@ -41,10 +41,11 @@ Standalone tool for validating trained CNN shaders with GPU-to-CPU readback. Sup
cnn_test input.png output.png [OPTIONS]
OPTIONS:
- --cnn-version N CNN version: 1 (default) or 2
+ --cnn-version N CNN version: 1 (default) or 2 (ignored with --weights)
+ --weights PATH Load weights from .bin (forces CNN v2, overrides layer config)
--blend F Final blend amount (0.0-1.0, default: 1.0)
--format ppm|png Output format (default: png)
- --layers N Number of CNN layers (1-10, v1 only, default: 3)
+ --layers N Number of CNN layers (1-10, v1 only, default: 3, ignored with --weights)
--save-intermediates DIR Save intermediate layers to directory
--debug-hex Print first 8 pixels as hex (debug)
--help Show usage
@@ -55,9 +56,12 @@ OPTIONS:
# CNN v1 (render pipeline, 3 layers)
./build/cnn_test input.png output.png --cnn-version 1
-# CNN v2 (compute, storage buffer, dynamic layers)
+# CNN v2 (compute, storage buffer, uses asset system weights)
./build/cnn_test input.png output.png --cnn-version 2
+# CNN v2 with runtime weight loading (loads layer config from .bin)
+./build/cnn_test input.png output.png --weights checkpoints/checkpoint_epoch_100.pth.bin
+
# 50% blend with original (v2)
./build/cnn_test input.png output.png --cnn-version 2 --blend 0.5
@@ -65,6 +69,8 @@ OPTIONS:
./build/cnn_test input.png output.png --cnn-version 2 --debug-hex
```
+**Important:** When using `--weights`, the layer count and kernel sizes are read from the binary file header, overriding any `--layers` or `--cnn-version` arguments.
+
---
## Implementation Details
@@ -119,6 +125,13 @@ std::vector<uint8_t> OffscreenRenderTarget::read_pixels() {
**Binary format:** Header (20B) + layer info (20B×N) + f16 weights
+**Weight Loading:**
+- **Without `--weights`:** Loads from asset system (`ASSET_WEIGHTS_CNN_V2`)
+- **With `--weights PATH`:** Loads from external `.bin` file (e.g., checkpoint exports)
+ - Layer count and kernel sizes parsed from binary header
+ - Overrides any `--layers` or `--cnn-version` arguments
+ - Enables runtime testing of training checkpoints without rebuild
+
---
## Build Integration