feat: Add C++ and WASI WebGPU#33
Open
cdmurph32 wants to merge 23 commits intoadobe:mainfrom
Open
Conversation
MLAS wasn't using SIMD. the configuration in cma/onnxruntime_mlas.cmake was only checking for emscripten
Two bugs in trustmark_wasm_image.cpp:
1. BGR conversion was wrong — stb_image loads as RGB; the model was trained
on PIL RGB images. The rgbToBgr call swapped R↔B channels feeding
incorrect data to the model. Removed entirely.
2. Output was wrong — encoder returns a raw stego tensor, not the final
watermarked image. Correct pipeline (matching Python and native C++):
residual = clamp(stego, -1, 1) - input_normalized
residual *= WM_STRENGTH (1.25 for P variant)
residual = clamp(residual, -0.2, 0.2)
final = clamp(input_normalized + residual, -1, 1)
output_uint8 = (final + 1) * 0.5 * 255
Also simplify imageToTensor/tensorToImage helpers and make USE_WEBGPU
conditional (env var) instead of always-on.
Fixes several incorrect/stale details: - Graphtime repo: cdmurph32/graphtime (not bytecodealliance/wasi-gfx) - Build script: build_wasi.sh (not build_wasi_minimal_with_config.sh) - Build output: build_wasi/ (not build_wasi_minimal_config/) - WebGPU: now fully working (f16 fix applied to wasi-gfx-runtime) - Remove stale BGR conversion step from example output - Fix --dir syntax examples to match what actually works - Add key repositories table and fixes-applied section
trustmark_wasm_image.cpp: - WM_STRENGTH: 1.25 -> 0.95*1.25=1.1875 (matches Rust CLI strength=0.95) - Add optional argv[3] bits_arg for custom 100-bit BCH watermark string - DEFAULT_BITS: BCH-Bch5 encoded test watermark verified to roundtrip WASM_BUILD.md: - Decoder: use decoder_P.with_runtime_opt.ort for WebGPU (plain .ort triggers InsertedPrecisionFreeCast nodes that corrupt decoder input) - Encoder: use encoder_P.with_runtime_opt.ort for 0 bit-flip roundtrip - Add wasm-tools component new step (required after build_wasi.sh) - Update decoder example output (now shows correct decoded bits) - Fix build flags: -Donnxruntime_EXTENDED_MINIMAL_BUILD=ON and -Donnxruntime_WGSL_TEMPLATE=static required
I need to put back the onnxruntime submodule which I removed to same harddrive space.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Related Issue
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist: