Skip to content

Commit b39e144

Browse files
authored
[web/webgpu] add validationMode to webgpu EP specific options. (#26581)
### Description add `validationMode` to webgpu EP specific options. - web: add implementation to pass the option - node: already supported
1 parent 3f4ab76 commit b39e144

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

js/common/lib/inference-session.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,20 @@ export declare namespace InferenceSession {
258258
*/
259259
forceCpuNodeNames?: readonly string[];
260260

261+
/**
262+
* Specify the validation mode for WebGPU execution provider.
263+
* - 'disabled': Disable all validation.
264+
* When used in Node.js, disable validation may cause process crash if WebGPU errors occur. Be cautious when using
265+
* this mode.
266+
* When used in web, this mode is equivalent to 'wgpuOnly'.
267+
* - 'wgpuOnly': Perform WebGPU internal validation only.
268+
* - 'basic': Perform basic validation including WebGPU internal validation. This is the default mode.
269+
* - 'full': Perform full validation. This mode may have performance impact. Use it for debugging purpose.
270+
*
271+
* @default 'basic'
272+
*/
273+
validationMode?: 'disabled' | 'wgpuOnly' | 'basic' | 'full';
274+
261275
/**
262276
* Specify an optional WebGPU device to be used by the WebGPU execution provider.
263277
*/

js/web/lib/wasm/session-options.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ const setExecutionProviders = async (
129129

130130
appendEpOption(epOptions, 'forceCpuNodeNames', names.join('\n'), allocs);
131131
}
132+
133+
// set validation mode
134+
if (webgpuOptions.validationMode) {
135+
appendEpOption(epOptions, 'validationMode', webgpuOptions.validationMode, allocs);
136+
}
132137
}
133138

134139
const info = getInstance().webgpuRegisterDevice!(customDevice);

0 commit comments

Comments
 (0)