[js/webgpu] Fix f16 errors for ConvTranspose2D (#18986)

### Description
<!-- Describe your changes. -->



### Motivation and Context
<!-- - Why is this change required? What problem does it solve?
- If it fixes an open issue, please link to the issue here. -->
This commit is contained in:
xhcao 2024-01-05 00:06:01 +08:00 committed by GitHub
parent 4e2d88b75f
commit 867b9d8f04
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -157,7 +157,7 @@ const createConvTranspose2DOpProgramShaderSource =
}
for (var i: u32 = 0; i < ${workPerThread}; i = i + 1) {
let value = dotProd[i] + ${hasBias ? 'bias[c+i]' : '0.0'};
let value = dotProd[i] + ${hasBias ? 'bias[c+i]' : `vec4<${dataType}>(0.0)`};
${output.set('batch', 'r', 'c + i', 'd1', 'value')};
}
}`;
@ -174,7 +174,7 @@ const createConvTranspose2DOpProgramShaderSource =
let wOutChannel = d1 - groupId * ${outputChannelsPerGroup};
// Convolve dy(?, ?, d2) with w(:, :, d1, d2) to compute dx(xR, xC, d1).
// ? = to be determined. : = across all values in that axis.
var dotProd = 0.0;
var dotProd = ${dataType}(0.0);
for (var wR: u32 = 0; wR < effectiveFilterDims.x; wR = wR + 1) {
if (wR % dilations.x != 0) {
continue;
@ -209,7 +209,7 @@ const createConvTranspose2DOpProgramShaderSource =
}
}
}
let value = dotProd + ${hasBias ? 'bias[d1]' : '0.0'};
let value = dotProd + ${hasBias ? 'bias[d1]' : `${dataType}(0.0)`};
${output.setByOffset('global_idx', 'value')};
`;