-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Fix WebGPU ConvTranspose bias validation in TypeScript and C++ implementations #27213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: guschmue <22941064+guschmue@users.noreply.github.com>
…ndant check Co-authored-by: guschmue <22941064+guschmue@users.noreply.github.com>
Co-authored-by: guschmue <22941064+guschmue@users.noreply.github.com>
guschmue
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you also need to make the change in onnxruntime/core/providers/webgpu/nn/conv_transpose.cc
Co-authored-by: guschmue <22941064+guschmue@users.noreply.github.com>
Added bias validation to the C++ implementation in commit 0d53e11. The validation checks that bias is 1D and has size equal to output channels (group * filter_shape[1]), matching the logic in the TypeScript implementation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can commit the suggested changes from lintrunner.
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
guschmue
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lint is failing:
Error: Following source files are not formatted: (did you run "npm run format"?)
js/web/lib/wasm/jsep/webgpu/ops/conv-transpose.ts
Co-authored-by: guschmue <22941064+guschmue@users.noreply.github.com>
Fixed formatting by running prettier in commit 7c55b81. The file now passes linting checks. |
|
/azp run Linux QNN CI Pipeline,Win_TRT_Minimal_CUDA_Test_CI,Windows ARM64 QNN CI Pipeline,Windows GPU Doc Gen CI Pipeline |
|
Azure Pipelines successfully started running 4 pipeline(s). |
| throw new Error('invalid bias'); | ||
| if (inputs.length === 3) { | ||
| if (inputs[2].dims.length !== 1) { | ||
| throw new Error('invalid bias: bias must be 1D tensor'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| const auto* bias = has_bias ? context.Input<Tensor>(2) : nullptr; | ||
| // Validate bias shape if provided | ||
| if (has_bias) { | ||
| const auto& bias_shape = bias->Shape(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot - Ditto as above
hariharans29
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description
WebGPU EP's ConvTranspose operator failed to properly validate bias tensor shape in both TypeScript and C++ implementations. Undefined
groupattribute caused NaN in validation checks, allowing invalid bias tensors to pass.TypeScript Changes (
js/web/lib/wasm/jsep/webgpu/ops/conv-transpose.ts):Parse time default: Set
groupto 1 when undefined (line 135 inparseConvTransposeAttributes)Enhanced bias validation (lines 182-192 in
validateInputs):weight.dims[1] * groupC++ Changes (
onnxruntime/core/providers/webgpu/nn/conv_transpose.cc):ComputeInternal):num_output_channels = group * filter_shape[1])Code Formatting:
Motivation and Context
Addresses issue where tests with intentionally invalid bias shapes were incorrectly passing in the WebGPU EP. The fix ensures:
groupattribute in TypeScriptNote: The C++ implementation already handles
groupattribute defaulting to 1 in the ConvAttributes base class, so only bias validation needed to be added.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.