Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[js/webgpu] Enable GroupedConvVectorize path #19791

Merged
merged 6 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Exclude opt just for non-ampere gpus
  • Loading branch information
gyagp committed Mar 7, 2024
commit 411851e3afae47ca6653aaef21a5ab098616a923
19 changes: 18 additions & 1 deletion js/web/lib/wasm/jsep/backend-webgpu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,34 @@ const getProgramInfoUniqueKey =
return key;
};


/**
* this class is designed for info and related helper functions of the GPU adapter in use
*/
export class AdapterInfo {
fs-eire marked this conversation as resolved.
Show resolved Hide resolved
private architecture: string;
private vendor: string;

constructor(adapterInfo: GPUAdapterInfo) {
if (adapterInfo) {
this.architecture = adapterInfo.architecture;
this.vendor = adapterInfo.vendor;
}
}

// vendor could be intel, nvidia, amd, etc.
// architecture could be ampere, gen12-lp, etc.
isArchitecture(architecture: string): boolean {
if (typeof this.architecture === 'undefined') {
return false;
}
fs-eire marked this conversation as resolved.
Show resolved Hide resolved
return this.architecture === architecture;
}

// vendor could be amd, intel, nvidia, etc.
isVendor(vendor: string): boolean {
if (typeof this.vendor === 'undefined') {
return false;
}
return this.vendor === vendor;
}
}
Expand Down
6 changes: 3 additions & 3 deletions js/web/lib/wasm/jsep/webgpu/ops/conv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ const conv2d = (context: ComputeContext, inputs: readonly TensorView[], attribut
// const hasPreluActivationWeights = false; /* TODO: add support for prelu activation weights */
const isChannelsLast = attributes.format === 'NHWC';
if (attributes.group !== 1) {
// One CI bot with NVIDIA GPU fails with below 2 cases, but we couldn't repro them with any other GPUs, including NVIDIA ones.
// One CI with NVIDIA GPU (ampere architecutre) fails with below 2 cases, but we couldn't repro them with any other GPUs, including NVIDIA ones.
// [webgpu]Conv - conv - vectorize group - B
// [webgpu]Conv - conv - vectorize group - D
// Disable vectorize on NVIDIA to make bots happy. BTW, no obvious perf gain with vectorize is seen on NVIDIA GPUs.
const enableGroupedConvVectorize = context.adapterInfo.isVendor('nvidia') ? false : true;
// Disable vectorize on NVIDIA ampere to make bots happy. BTW, no obvious perf gain with vectorize is seen on NVIDIA GPUs.
const enableGroupedConvVectorize = context.adapterInfo.isArchitecture('ampere') ? false : true;
gyagp marked this conversation as resolved.
Show resolved Hide resolved
if (enableGroupedConvVectorize && isChannelsLast && inputs[1].dims[0] === attributes.group &&
inputs[1].dims[1] === 1 && attributes.dilations[0] === 1 && attributes.dilations[1] === 1) {
const outputShape = calculateOutputShape(
Expand Down