Skip to content

Commit

Permalink
use ?: instead of Object.seal
Browse files Browse the repository at this point in the history
  • Loading branch information
qjia7 committed Nov 21, 2023
1 parent 23b6cb8 commit 74783b0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions js/web/lib/wasm/jsep/webgpu/ops/batch-norm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ const validateInputs = (inputs: readonly TensorView[], attributes: BatchNormAttr
};

if (inputs[0].dims.length > 1) {
const shape = Object.seal<Record<typeof attributes.format, number[]>>({
NHWC: inputs[0].dims.slice(-1),
NCHW: inputs[0].dims.slice(1, attributes.spatial ? 2 : undefined),
})[attributes.format];
const shape = attributes.format === 'NHWC' ?
(attributes.spatial ? inputs[0].dims.slice(-1) :
inputs[0].dims.slice(-1).concat(inputs[0].dims.slice(1, inputs[0].dims.length - 1))) :
inputs[0].dims.slice(1, attributes.spatial ? 2 : undefined);
checkShapeEqual(inputs[1].dims, shape, 'Invalid input scale');
checkShapeEqual(inputs[2].dims, shape, 'Invalid input B');
checkShapeEqual(inputs[3].dims, shape, 'Invalid input mean');
Expand Down

0 comments on commit 74783b0

Please sign in to comment.