diff --git a/js/web/lib/wasm/jsep/webgpu/ops/3rd-party/conv2d_mm_webgpu.ts b/js/web/lib/wasm/jsep/webgpu/ops/3rd-party/conv2d_mm_webgpu.ts index c21eee78286b3..bfed99cc4f51d 100644 --- a/js/web/lib/wasm/jsep/webgpu/ops/3rd-party/conv2d_mm_webgpu.ts +++ b/js/web/lib/wasm/jsep/webgpu/ops/3rd-party/conv2d_mm_webgpu.ts @@ -48,7 +48,7 @@ const conv2dCommonSnippet = ( innerElementSizeX = 4, innerElementSizeW = 4, innerElementSize = 4, - dataType = 'f32' + dataType = 'f32', ): string => { const getXSnippet = (innerElementSize: number) => { switch (innerElementSize) { @@ -133,10 +133,10 @@ const conv2dCommonSnippet = ( } return ${typeSnippet(innerElementSizeX, dataType)}(0.0);` : fitInner && fitBOuter - ? ` + ? ` let col = colIn * ${innerElementSizeX}; ${readXSnippet}` - : ` + : ` let col = colIn * ${innerElementSizeX}; if (row < uniforms.dim_inner && col < uniforms.dim_b_outer) { ${readXSnippet} @@ -182,7 +182,7 @@ export const createConv2DMatMulProgramInfo = ( dimInner: number, hasBias: boolean, sequentialAccessByThreads: boolean, - squeezeOutputShapeFunction?: (shape: readonly number[]) => number[] + squeezeOutputShapeFunction?: (shape: readonly number[]) => number[], ): ProgramInfo => { const isChannelsLast = attributes.format === 'NHWC'; const inChannels = isChannelsLast ? inputs[0].dims[3] : inputs[0].dims[1]; @@ -258,7 +258,7 @@ export const createConv2DMatMulProgramInfo = ( 'x', inputs[0].dataType, inputs[0].dims.length, - innerElementSize === 3 ? 1 : innerElementSize + innerElementSize === 3 ? 1 : innerElementSize, ); const w = inputVariable('w', inputs[1].dataType, inputs[1].dims.length, components); const inputVariables = [x, w]; @@ -289,7 +289,7 @@ export const createConv2DMatMulProgramInfo = ( elementsSize[0], elementsSize[1], elementsSize[2], - t + t, )} ${conv2dCommonSnippet( isChannelsLast, @@ -301,7 +301,7 @@ export const createConv2DMatMulProgramInfo = ( elementsSize[0], elementsSize[1], elementsSize[2], - t + t, )} ${ isVec4 @@ -315,7 +315,7 @@ export const createConv2DMatMulProgramInfo = ( tileInner, false, undefined, - sequentialAccessByThreads + sequentialAccessByThreads, ) }`; }; diff --git a/js/web/lib/wasm/jsep/webgpu/ops/3rd-party/matmul_packed_webgpu.ts b/js/web/lib/wasm/jsep/webgpu/ops/3rd-party/matmul_packed_webgpu.ts index 7a0c8ce6b1a2f..f0287529ca08b 100644 --- a/js/web/lib/wasm/jsep/webgpu/ops/3rd-party/matmul_packed_webgpu.ts +++ b/js/web/lib/wasm/jsep/webgpu/ops/3rd-party/matmul_packed_webgpu.ts @@ -92,7 +92,7 @@ export const makeMatMulPackedVec4Source = ( transposeA = false, tileInner = 32, splitK = false, - splitedDimInner = 32 + splitedDimInner = 32, ): string => { const tileAOuter = workgroupSize[1] * workPerThread[1]; const tileBOuter = workgroupSize[0] * workPerThread[0]; @@ -212,7 +212,7 @@ export const makeMatMulPackedSource = ( tileInner = 32, splitK = false, splitedDimInner = 32, - sequentialAccessByThreads = false + sequentialAccessByThreads = false, ): string => { const tileAOuter = workPerThread[1] * workgroupSize[1]; const tileBOuter = workPerThread[0] * workgroupSize[0]; @@ -223,7 +223,7 @@ export const makeMatMulPackedSource = ( !(tileAHight % workgroupSize[1] === 0 && tileAWidth % workgroupSize[0] === 0 && tileInner % workgroupSize[1] === 0) ) { throw new Error( - `tileAHight ${tileAHight} must be divisible by workgroupSize[1]${workgroupSize[1]}, tileAWidth ${tileAWidth} must be divisible by workgroupSize[0]${workgroupSize[0]}, tileInner ${tileInner} must be divisible by workgroupSize[1]${workgroupSize[1]}` + `tileAHight ${tileAHight} must be divisible by workgroupSize[1]${workgroupSize[1]}, tileAWidth ${tileAWidth} must be divisible by workgroupSize[0]${workgroupSize[0]}, tileInner ${tileInner} must be divisible by workgroupSize[1]${workgroupSize[1]}`, ); } const rowPerThreadA = tileAHight / workgroupSize[1]; @@ -374,7 +374,7 @@ const matMulReadWriteFnSource = ( applyActivation: string, variables: IndicesHelper[], batchShapes: Array, - isChannelsLast = false + isChannelsLast = false, ): string => { const [batchAShape, batchBShape, batchShape] = batchShapes; const [batchVariable, aVariable, bVariable, outputVariable] = variables; @@ -411,9 +411,9 @@ const matMulReadWriteFnSource = ( }; const source = ` fn mm_readA(batch: i32, row: i32, colIn: i32, batchIndices: ${batchVariable.type.indices}) -> ${typeSnippet( - component, - dataType - )} { + component, + dataType, + )} { var value = ${typeSnippet(component, dataType)}(0.0); let col = colIn * ${component}; if(row < uniforms.dim_a_outer && col < uniforms.dim_inner) @@ -425,9 +425,9 @@ const matMulReadWriteFnSource = ( } fn mm_readB(batch: i32, row: i32, colIn: i32, batchIndices: ${batchVariable.type.indices}) -> ${typeSnippet( - component, - dataType - )} { + component, + dataType, + )} { var value = ${typeSnippet(component, dataType)}(0.0); let col = colIn * ${component}; if(row < uniforms.dim_inner && col < uniforms.dim_b_outer) @@ -462,7 +462,7 @@ export const createMatmulProgramInfo = ( outputShape: readonly number[], reshapedOutputShape?: readonly number[], isChannelsLast = false /* only used for conv2dByMatMul*/, - squeezeOutputShapeFunction?: (shape: readonly number[]) => number[] + squeezeOutputShapeFunction?: (shape: readonly number[]) => number[], ): ProgramInfo => { const aShape = inputs[0].dims; const bShape = inputs[1].dims; @@ -533,7 +533,7 @@ export const createMatmulProgramInfo = ( applyActivation, [batchDims, A, B, output], [outerDimsA, outerDimsB, outerDims], - isChannelsLast + isChannelsLast, ); return ` ${shaderHelper diff --git a/js/web/lib/wasm/jsep/webgpu/ops/conv-grouped.ts b/js/web/lib/wasm/jsep/webgpu/ops/conv-grouped.ts index 17fbf71760ad6..1ad4149b01e08 100644 --- a/js/web/lib/wasm/jsep/webgpu/ops/conv-grouped.ts +++ b/js/web/lib/wasm/jsep/webgpu/ops/conv-grouped.ts @@ -25,7 +25,7 @@ import { appendActivationUniforms, appendActivationUniformsData, getActivationSn export const createGroupedConvProgramInfo = ( inputs: readonly TensorView[], attributes: ConvAttributes, - squeezeOutputShapeFunction?: (shape: readonly number[]) => number[] + squeezeOutputShapeFunction?: (shape: readonly number[]) => number[], ): ProgramInfo => { const hasBias = inputs.length > 2; const processBias = hasBias ? 'value += b[output_channel];' : ''; @@ -40,7 +40,7 @@ export const createGroupedConvProgramInfo = ( attributes.dilations, attributes.pads, attributes.strides, - isChannelLast + isChannelLast, ); const outputSize = ShapeUtil.size(outputShape); @@ -145,7 +145,7 @@ export const createGroupedConvVectorizeProgramInfo = ( inputs: readonly TensorView[], attributes: ConvAttributes, outputShape: readonly number[], - squeezeOutputShapeFunction?: (shape: readonly number[]) => number[] + squeezeOutputShapeFunction?: (shape: readonly number[]) => number[], ): ProgramInfo => { const hasBias = inputs.length > 2; const components = getMaxComponents(outputShape[3]); diff --git a/js/web/lib/wasm/jsep/webgpu/ops/conv.ts b/js/web/lib/wasm/jsep/webgpu/ops/conv.ts index 5e8f6e245c93a..e64d253620186 100644 --- a/js/web/lib/wasm/jsep/webgpu/ops/conv.ts +++ b/js/web/lib/wasm/jsep/webgpu/ops/conv.ts @@ -20,7 +20,7 @@ export const calculateOutputShape = ( dilations: readonly number[], adjustPads: readonly number[], strides: readonly number[], - isChannelLast: boolean + isChannelLast: boolean, ): number[] => { const batchSize = inputShape[0]; const inputSpatialShape = inputShape.slice(isChannelLast ? 1 : 2, isChannelLast ? 3 : 4); @@ -30,7 +30,7 @@ export const calculateOutputShape = ( const dilatedKernelShape = kernelSpatialShape.map((v, i) => v + (v - 1) * (dilations[i] - 1)); const inputSpatialShapeWithPad = inputSpatialShape.map((v, i) => v + adjustPads[i] + adjustPads[i + spatialRank]); const outputShape = inputSpatialShapeWithPad.map((v, i) => - Math.floor((v - dilatedKernelShape[i] + strides[i]) / strides[i]) + Math.floor((v - dilatedKernelShape[i] + strides[i]) / strides[i]), ); outputShape.splice(0, 0, batchSize); outputShape.splice(isChannelLast ? 3 : 1, 0, outChannels); @@ -117,7 +117,7 @@ const getAdjustedConvAttributes = (attributes: T, inpu kernelShape, pads, attributes.format === 'NHWC', - attributes.autoPad + attributes.autoPad, ); // always return a new object so does not modify the original attributes @@ -156,7 +156,7 @@ const conv2d = ( context: ComputeContext, inputs: readonly TensorView[], attributes: ConvAttributes, - squeezeOutputShapeFunction?: (shape: readonly number[]) => number[] + squeezeOutputShapeFunction?: (shape: readonly number[]) => number[], ): void => { // check attributes @@ -181,7 +181,7 @@ const conv2d = ( attributes.dilations, attributes.pads, attributes.strides, - isChannelsLast + isChannelsLast, ); const transposedWeight = (context.kernelCustomData.wT as TensorView | undefined) ?? @@ -198,7 +198,7 @@ const conv2d = ( } context.compute( createGroupedConvVectorizeProgramInfo(convInputs, attributes, outputShape, squeezeOutputShapeFunction), - { inputs: convInputs } + { inputs: convInputs }, ); } else { context.compute(createGroupedConvProgramInfo(inputs, attributes, squeezeOutputShapeFunction)); @@ -219,7 +219,7 @@ const conv2d = ( attributes.dilations, attributes.pads, attributes.strides, - isChannelsLast + isChannelsLast, ); const outHeight = outputShape[isChannelsLast ? 1 : 2]; const outWidth = outputShape[isChannelsLast ? 2 : 3]; @@ -289,9 +289,9 @@ const conv2d = ( outputShape, matmulOutputShape, isChannelsLast, - squeezeOutputShapeFunction + squeezeOutputShapeFunction, ), - { inputs: matmulInputs } + { inputs: matmulInputs }, ); } else { context.compute( @@ -301,9 +301,9 @@ const conv2d = ( outputShape, matmulOutputShape, isChannelsLast, - squeezeOutputShapeFunction + squeezeOutputShapeFunction, ), - { inputs: matmulInputs } + { inputs: matmulInputs }, ); } return; @@ -344,9 +344,9 @@ const conv2d = ( dimInner, hasBias, sequentialAccessByThreads, - squeezeOutputShapeFunction + squeezeOutputShapeFunction, ), - { inputs: convInputs } + { inputs: convInputs }, ); }; @@ -359,7 +359,7 @@ const conv1d = (context: ComputeContext, attributes: ConvAttributes): void => { ? // [N, W, C] -> [N, H=1, W, C] [context.inputs[0].dims[0], 1, context.inputs[0].dims[1], context.inputs[0].dims[2]] : // [N, C, W] -> [N, C, H=1, W] - [context.inputs[0].dims[0], context.inputs[0].dims[1], 1, context.inputs[0].dims[2]] + [context.inputs[0].dims[0], context.inputs[0].dims[1], 1, context.inputs[0].dims[2]], ), //[FILTER_OUT_CHANNEL, FILTER_IN_CHANNEL, kW] -> [FILTER_OUT_CHANNEL, FILTER_IN_CHANNEL, kH=1, kW] context.inputs[1].reshape([context.inputs[1].dims[0], context.inputs[1].dims[1], 1, context.inputs[1].dims[2]]), @@ -373,10 +373,10 @@ const conv1d = (context: ComputeContext, attributes: ConvAttributes): void => { const kernelShape = [1].concat(attributes.kernelShape); const adjustedAttributes = getAdjustedConvAttributes( { ...attributes, pads, strides, dilations, kernelShape }, - inputs + inputs, ); conv2d(context, inputs, adjustedAttributes, (outputShape) => - isChannelLast ? [outputShape[0], outputShape[2], outputShape[3]] : [outputShape[0], outputShape[1], outputShape[3]] + isChannelLast ? [outputShape[0], outputShape[2], outputShape[3]] : [outputShape[0], outputShape[1], outputShape[3]], ); }; @@ -391,7 +391,7 @@ const conv3d = (context: ComputeContext, inputs: readonly TensorView[], attribut attributes.dilations as number | [number, number, number], pads as string | number[], false, - format + format, ); context.compute( createConv3DNaiveProgramInfo( @@ -400,8 +400,8 @@ const conv3d = (context: ComputeContext, inputs: readonly TensorView[], attribut convInfo.outShape, [convInfo.filterDepth, convInfo.filterHeight, convInfo.filterWidth], [convInfo.padInfo.front, convInfo.padInfo.top, convInfo.padInfo.left], - format - ) + format, + ), ); };