Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 2 additions & 16 deletions tfjs-backend-webgpu/src/backend_webgpu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -726,14 +726,7 @@ export class WebGPUBackend extends KernelBackend {
program = new Conv2DMMProgram(convInfo, workPerThread);
}

const pad = convInfo.padInfo.type === 'VALID' ?
[0, 0] :
convInfo.padInfo.type === 'SAME' ?
[
-Math.floor((convInfo.filterShape[0] - 1) / 2),
-Math.floor((convInfo.filterShape[1] - 1) / 2)
] :
[convInfo.padInfo.top, convInfo.padInfo.left];
const pad = [convInfo.padInfo.top, convInfo.padInfo.left];

const dimensions = [
convInfo.filterHeight, convInfo.filterWidth, ...pad,
Expand Down Expand Up @@ -799,14 +792,7 @@ export class WebGPUBackend extends KernelBackend {
hasPreluActivationWeights);
}

const pad = convInfo.padInfo.type === 'VALID' ?
[0, 0] :
convInfo.padInfo.type === 'SAME' ?
[
-Math.floor((convInfo.filterShape[0] - 1) / 2),
-Math.floor((convInfo.filterShape[1] - 1) / 2)
] :
[convInfo.padInfo.top, convInfo.padInfo.left];
const pad = [convInfo.padInfo.top, convInfo.padInfo.left];

const dimensions = [
convInfo.filterHeight, convInfo.filterWidth, ...pad,
Expand Down
4 changes: 2 additions & 2 deletions tfjs-backend-webgpu/src/kernels/conv2d_mm_webgpu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ export class Conv2DMMProgram implements WebGPUProgram {

ivec4 coord = ivec4(
batch,
pad[0] + outRow * stride[0] + dilation[0] * WRow,
pad[1] + outCol * stride[1] + dilation[1] * WCol,
outRow * stride[0] + dilation[0] * WRow - pad[0],
outCol * stride[1] + dilation[1] * WCol - pad[1],
c % xShape[3]);
return ${sampleA};
}
Expand Down