diff --git a/js/web/lib/onnxjs/backends/webgpu/ops/concat.ts b/js/web/lib/onnxjs/backends/webgpu/ops/concat.ts index 8c2d637aec995..d3ea71364ba42 100644 --- a/js/web/lib/onnxjs/backends/webgpu/ops/concat.ts +++ b/js/web/lib/onnxjs/backends/webgpu/ops/concat.ts @@ -130,7 +130,9 @@ const readBufferDataImpl = (indicesHelper: readonly IndicesHelper[], tensorRank: const codeLines: string[] = []; for (let i = 0; i < numberOfTensors; ++i) { const returnSnippet = `return input${i}[${indicesHelper[i].i2oExpression('indices', true)}];`; - if (i === 0) { + if (numberOfTensors === 1) { + codeLines.push(returnSnippet); + } else if (i === 0) { codeLines.push(`if (textureIndex == ${i}u) { ${returnSnippet} }`); } else if (i === numberOfTensors - 1) { codeLines.push(`else { ${returnSnippet} }`);