Skip to content

Commit

Permalink
introduce WebNNOptionsWithoutMLContext for better type inference
Browse files Browse the repository at this point in the history
  • Loading branch information
fs-eire committed May 27, 2024
1 parent 4d80355 commit 1062702
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions js/common/lib/inference-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,19 @@ export declare namespace InferenceSession {
*
* @see https://www.w3.org/TR/webnn/#dictdef-mlcontextoptions
*/
export interface WebNNContextOptions extends WebNNExecutionProviderName {
export interface WebNNContextOptions {
deviceType?: 'cpu'|'gpu'|'npu';
numThreads?: number;
powerPreference?: 'default'|'low-power'|'high-performance';
}

/**
* Represents a set of options for WebNN execution provider without MLContext.
*/
export interface WebNNOptionsWithoutMLContext extends WebNNExecutionProviderName, WebNNContextOptions {
context?: never;
}

/**
* Represents a set of options for WebNN execution provider with MLContext.
*
Expand Down Expand Up @@ -287,7 +294,7 @@ export declare namespace InferenceSession {
/**
* Options for WebNN execution provider.
*/
export type WebNNExecutionProviderOption = WebNNContextOptions|WebNNOptionsWithMLContext|WebNNOptionsWebGpu;
export type WebNNExecutionProviderOption = WebNNOptionsWithoutMLContext|WebNNOptionsWithMLContext|WebNNOptionsWebGpu;

// #endregion

Expand Down

0 comments on commit 1062702

Please sign in to comment.