diff --git a/js/web/lib/wasm/jsep/webgpu/ops/conv-transpose.ts b/js/web/lib/wasm/jsep/webgpu/ops/conv-transpose.ts index 18bf30a325d83..994aeb83a0ed5 100644 --- a/js/web/lib/wasm/jsep/webgpu/ops/conv-transpose.ts +++ b/js/web/lib/wasm/jsep/webgpu/ops/conv-transpose.ts @@ -132,7 +132,7 @@ export const parseConvTransposeAttributes = (attributes: Record typeof attributes.autoPad == 'undefined' ? 0 : (attributes.autoPad as number) ]; const dilations = attributes.dilations as [number, number]; - const group = attributes.group as number; + const group = (attributes.group as number) ?? 1; // default to 1 per ONNX spec const kernelShape = attributes.kernelShape as [number, number]; const pads = attributes.pads as [number, number, number, number]; const strides = attributes.strides as [number, number]; diff --git a/onnxruntime/core/providers/webgpu/nn/conv_transpose.cc b/onnxruntime/core/providers/webgpu/nn/conv_transpose.cc index 84a0afd873d23..c3842a5c875e3 100644 --- a/onnxruntime/core/providers/webgpu/nn/conv_transpose.cc +++ b/onnxruntime/core/providers/webgpu/nn/conv_transpose.cc @@ -57,6 +57,11 @@ Status ConvTranspose::ComputeInternal(ComputeContext& context) bool has_bias = context.InputCount() > 2; const auto* bias = has_bias ? context.Input(2) : nullptr; + // Validate bias shape if provided + if (has_bias && (bias->Shape().NumDimensions() != 1 || bias->Shape()[0] != num_output_channels)) { + return ORT_MAKE_STATUS(ONNXRUNTIME, INVALID_ARGUMENT, "invalid bias"); + } + if (input_shape.NumDimensions() == 3 && filter_shape.NumDimensions() == 3) { // ConvTranspose1D TensorShapeVector input_shape_vector = input_shape.AsShapeVector();