onnxruntime
35714475 - [WebGPU] Prepack ConvTranspose1D/2D initializer weights (#33231)

Commit
5 days ago
[WebGPU] Prepack ConvTranspose1D/2D initializer weights (#33231) ### Description Prepack constant ConvTranspose1D and ConvTranspose2D weights during session initialization so repeated inference reuses the layout expected by the existing 2D shader instead of transposing the same weights on every run. - Save an owned copy of the original ONNX filter shape for validation and output-shape inference, removing inverse-permutation reconstruction for all packed layouts. Both 1D and 2D weights use HWIO; the saved shape preserves their original ranks. The 1D representation retains the synthetic height of one used by the 2D kernel. - Preserve per-run transposition for dynamic weights and when prepacking is explicitly disabled, and preserve the existing 3D prepacking path. - Correct two existing NHWC weight-vector accesses for grouped convolution with one output channel per group: their input-channel offsets must be expressed in vector units. The expanded tests reproduced incorrect results on the unmodified base, including dynamic weights. - Extend the existing WebGPU fixture with 176 parameterized tests covering both spatial ranks, layouts, FP32/FP16, groups/depthwise, scalar/vec2/vec4 and mixed widths, channel remainders, bias, stride/dilation/padding, initializer/dynamic weights, repeated runs, and prepack-count assertions. Retain all 176 existing ConvTranspose3D cases. Additional coverage checks genuine height-one 2D kernels and all 12 initializer/dynamic input-weight rank-mismatch combinations. ### Motivation and Context Follow-up to the non-blocking prepacking comment on #32688: https://github.com/microsoft/onnxruntime/pull/32688#discussion_r4155606475 ### Validation - Fresh Windows Release/D3D12 build of commit `96f564b873` with 12 parallel workers. - Final `onnxruntime_provider_test --gtest_filter="*ConvTranspose*"`: **430 passed, 4 expected CUDA/DML-only skips**, including all 176 new parameterized tests and all 176 existing 3D cases. CPU fallback is disabled for the WebGPU fixture. - All 17 focused shape-regression tests passed; the rank-mismatch test verifies rejection from the running WebGPU kernel and asserts prepack counts. - Before the implementation, 72 parameterized tests failed their missing-prepack-count assertion. The expanded grouped single-output-channel cases also exposed a numerical error in the original shader; the final run passes both initializer and dynamic variants. - C++ lintrunner and `git diff --check` passed. - Synthetic benchmark of the prepacking implementation at `edc3a6a0cc` on an NVIDIA GeForce RTX 5080: median warmed end-to-end Run speedups of **1.00x-1.18x** across 16 1D/2D, layout, dtype, and shape scenarios. One small FP16/NHWC case was effectively unchanged; the other 15 measured 1.06x-1.18x. Warm-context session initialization increased by about **0.06-0.14 ms**. - Benchmark uses the same initializer model with `session.disable_prepacking` toggled, verifies equal outputs and prepack counts, alternates ordering, and aggregates 25 samples per mode/scenario from five processes. Each sample averages 60 timed Run calls after 15 warmups, including host input/output transfers. These are single-operator measurements on one GPU, not a general model-speedup claim. The benchmark harness is a local artifact, not part of the source diff. - Browser/WASM, plugin builds, GPU capture mode, and full-model performance were not validated locally.
Author
Parents
Loading