Skip to content

Commit

Permalink
[WebNN EP] Remove the numThreads option
Browse files Browse the repository at this point in the history
  • Loading branch information
Honry committed Oct 16, 2024
1 parent 2b8fc55 commit fd6c2fa
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 9 deletions.
1 change: 0 additions & 1 deletion js/web/lib/wasm/jsep/webnn/webnn.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ type MLPowerPreference = 'default'|'high-performance'|'low-power';
interface MLContextOptions {
deviceType?: MLDeviceType;
powerPreference?: MLPowerPreference;
numThreads?: number;
}
interface ML {
createContext(options?: MLContextOptions): Promise<MLContext>;
Expand Down
3 changes: 1 addition & 2 deletions js/web/lib/wasm/wasm-core-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,14 +297,13 @@ export const createSession = async (
const context = (webnnOptions as InferenceSession.WebNNOptionsWithMLContext)?.context;
const gpuDevice = (webnnOptions as InferenceSession.WebNNOptionsWebGpu)?.gpuDevice;
const deviceType = (webnnOptions as InferenceSession.WebNNContextOptions)?.deviceType;
const numThreads = (webnnOptions as InferenceSession.WebNNContextOptions)?.numThreads;
const powerPreference = (webnnOptions as InferenceSession.WebNNContextOptions)?.powerPreference;
if (context) {
wasm.currentContext = context as MLContext;
} else if (gpuDevice) {
wasm.currentContext = await navigator.ml.createContext(gpuDevice);
} else {
wasm.currentContext = await navigator.ml.createContext({ deviceType, numThreads, powerPreference });
wasm.currentContext = await navigator.ml.createContext({ deviceType, powerPreference });
}
} else {
wasm.currentContext = await navigator.ml.createContext();
Expand Down
7 changes: 1 addition & 6 deletions js/web/test/test-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,14 +291,9 @@ export class ModelTestContext {
if (['ml-tensor', 'ml-location'].includes(modelTest.ioBinding)) {
const webnnOptions = executionProviderConfig as ort.InferenceSession.WebNNExecutionProviderOption;
const deviceType = (webnnOptions as ort.InferenceSession.WebNNContextOptions)?.deviceType;
const numThreads = (webnnOptions as ort.InferenceSession.WebNNContextOptions)?.numThreads;
const powerPreference = (webnnOptions as ort.InferenceSession.WebNNContextOptions)?.powerPreference;

mlContext = await navigator.ml.createContext({
deviceType,
numThreads,
powerPreference,
});
mlContext = await navigator.ml.createContext({ deviceType, powerPreference });
(executionProviderConfig as ort.InferenceSession.WebNNExecutionProviderOption).context = mlContext;
if (!deviceType) {
(executionProviderConfig as ort.InferenceSession.WebNNContextOptions).deviceType = deviceType;
Expand Down

0 comments on commit fd6c2fa

Please sign in to comment.