You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: device-selection-explainer.md
+9-5Lines changed: 9 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -237,24 +237,28 @@ Based on the answer, the developer may choose an option other than WebNN. Beside
237
237
The following [proposal](https://github.com/webmachinelearning/webnn/issues/815#issuecomment-3198261369) gained support for a simple accelerator mapping solution (before using the previously discussed fine grained constraints):
238
238
- Expose a context property (or event) to tell whether CPU fallback is active (or likely active).
239
239
- Add a context creation option/hint (e.g. `accelerated: true`) for telling app preference for NPU and/or GPU accelerated ["massively parallel"](https://en.wikipedia.org/wiki/Massively_parallel) processing (MPP).
240
-
-**Note**. This context option makes sense when an error is returned when the implementation overrides the option. Otherwise, if instead of returning an error a silent fallback is implemented (which seems the more generic behaviour), then applications could query the following proposed property on the context (albeit after context creation). If implementations could detect a CPU fallback, then they could also return an error. Whether to expose an error in this case is to be discussed, as it would allow detecting lack of massively parallel acceleration _before_ creating a context.
240
+
Note that in [certain use cases](https://www.w3.org/2025/09/25-webmachinelearning-minutes.html)applications might prefer CPU inference, therefore specifying `accelerated: false` has legit use cases as well.
241
241
- Add a context property named `"accelerated"` with possible values: `false` (for likely no support for neither GPU nor NPU), and `true` (e.g. fully controlled by the underlying platform which makes a best effort for MPP, yet CPU fallback may occur).
242
+
- Add a context property named `"cpuFallbackActive"` that may be polled for detecting CPU fallbacks. In the future, depending on developer feedback, this may be turned into an event.
242
243
243
-
The following changes are proposed:
244
+
The following Web IDL changes are proposed:
244
245
245
246
```js
246
247
partial dictionary MLContextOptions {
247
248
boolean accelerated =true;
248
249
};
249
250
250
251
partial interface MLContext {
251
-
boolean cpuFallbackActive;
252
+
readonly attribute boolean accelerated;
253
+
readonly attribute boolean cpuFallbackActive;
252
254
};
253
255
```
254
256
255
257
The behavior of [createContext()](https://webmachinelearning.github.io/webnn/#dom-ml-createcontext) is proposed to follow this policy:
256
-
- return an error [in step 4](https://webmachinelearning.github.io/webnn/#create-a-context) if the context option `accelerated` has been set to `true`, but the platform cannot provide massive parallel processing at all,
257
-
- and set the `accelerated` property to `false` when the platform could in principle provide massive parallel processing which may or may not be available at the moment.
258
+
- Set the `accelerated` property to `false` when the platform could in principle provide massive parallel processing which may or may not be available at the moment. Applications may poll this property, together with `MLContext::cpuFallbackActive`.
259
+
260
+
In the future, more policy options could be considered, for instance:
261
+
- Return an error [in step 4](https://webmachinelearning.github.io/webnn/#create-a-context) if the context option `accelerated` has been set to `true`, but the platform cannot provide massive parallel processing at all.
0 commit comments