Skip to content

Commit 583f08b

Browse files
Copilotguschmue
andcommitted
Fix group attribute default at parse time instead of validation time
Co-authored-by: guschmue <22941064+guschmue@users.noreply.github.com>
1 parent a7b6b3a commit 583f08b

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

js/web/lib/wasm/jsep/webgpu/ops/conv-transpose.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export const parseConvTransposeAttributes = (attributes: Record<string, unknown>
132132
typeof attributes.autoPad == 'undefined' ? 0 : (attributes.autoPad as number)
133133
];
134134
const dilations = attributes.dilations as [number, number];
135-
const group = attributes.group as number;
135+
const group = (attributes.group as number) ?? 1; // default to 1 per ONNX spec
136136
const kernelShape = attributes.kernelShape as [number, number];
137137
const pads = attributes.pads as [number, number, number, number];
138138
const strides = attributes.strides as [number, number];
@@ -183,8 +183,7 @@ const validateInputs = (inputs: readonly TensorView[], attributes: ConvTranspose
183183
if (inputs[2].dims.length !== 1) {
184184
throw new Error('invalid bias: bias must be 1D tensor');
185185
}
186-
const group = attributes.group ?? 1; // default to 1 if not specified (per ONNX spec)
187-
const featureMaps = inputs[1].dims[1] * group;
186+
const featureMaps = inputs[1].dims[1] * attributes.group;
188187
if (inputs[2].dims[0] !== featureMaps) {
189188
throw new Error(`invalid bias: bias size (${inputs[2].dims[0]}) must be equal to output channels (${featureMaps})`);
190189
}

0 commit comments

Comments
 (0)