diff --git a/js/web/lib/wasm/jsep/webgpu/ops/common.ts b/js/web/lib/wasm/jsep/webgpu/ops/common.ts index e21cb5c33f781..643744108c0f4 100644 --- a/js/web/lib/wasm/jsep/webgpu/ops/common.ts +++ b/js/web/lib/wasm/jsep/webgpu/ops/common.ts @@ -336,8 +336,11 @@ export const getElementAt = (name: string, index: number|string, length: number, type?: UniformDataElementType): string => { if (name.startsWith('uniforms.') && length > 4) { if (typeof (index) === 'string') { - return `${name}[(${index}) / 4][(${index}) % 4]`; - + if (type === 'f16') { + return `${name}[(${index}) / 8][(${index}) % 8 / 4][(${index}) % 8 % 4]`; + } else { + return `${name}[(${index}) / 4][(${index}) % 4]`; + } } else { if (type === 'f16') { return `${name}[${Math.floor(index / 8)}][${Math.floor(index % 8 / 4)}][${index % 8 % 4}]`;