|
7 | 7 | <link href="https://www.w3.org/StyleSheets/TR/2021/W3C-ED" rel="stylesheet">
|
8 | 8 | <meta content="Bikeshed version c67c745b1, updated Fri Jan 17 14:27:28 2025 -0800" name="generator">
|
9 | 9 | <link href="https://www.w3.org/TR/webnn/" rel="canonical">
|
10 |
| - <meta content="5f85e73d3f25be21ae69bc6efc7b49db673ad066" name="revision"> |
| 10 | + <meta content="751ca310bcefc98876dc7780413286a553497908" name="revision"> |
11 | 11 | <meta content="dark light" name="color-scheme">
|
12 | 12 | <link href="https://www.w3.org/StyleSheets/TR/2021/dark.css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css">
|
13 | 13 | <style>
|
|
1018 | 1018 | <div class="head">
|
1019 | 1019 | <p data-fill-with="logo"><a class="logo" href="https://www.w3.org/"> <img alt="W3C" height="48" src="https://www.w3.org/StyleSheets/TR/2021/logos/W3C" width="72"> </a> </p>
|
1020 | 1020 | <h1 class="p-name no-ref" id="title">Web Neural Network API</h1>
|
1021 |
| - <p id="w3c-state"><a href="https://www.w3.org/standards/types/#ED">Editor’s Draft</a>, <time class="dt-updated" datetime="2025-01-23">23 January 2025</time></p> |
| 1021 | + <p id="w3c-state"><a href="https://www.w3.org/standards/types/#ED">Editor’s Draft</a>, <time class="dt-updated" datetime="2025-01-27">27 January 2025</time></p> |
1022 | 1022 | <details open>
|
1023 | 1023 | <summary>More details about this document</summary>
|
1024 | 1024 | <div data-fill-with="spec-metadata">
|
@@ -1070,7 +1070,6 @@ <h2 class="no-num no-toc no-ref heading settled" id="sotd"><span class="content"
|
1070 | 1070 | patent which the individual believes contains <a href="https://www.w3.org/policies/patent-policy/#def-essential">Essential
|
1071 | 1071 | Claim(s)</a> must disclose the information in accordance with <a href="https://www.w3.org/policies/patent-policy/#sec-Disclosure">section 6 of the <abbr title="World Wide Web Consortium">W3C</abbr> Patent Policy</a>. </p>
|
1072 | 1072 | <p> This document is governed by the <a href="https://www.w3.org/policies/process/20231103/" id="w3c_process_revision">03 November 2023 W3C Process Document</a>. </p>
|
1073 |
| - <p></p> |
1074 | 1073 | <p> Since the <a href="https://www.w3.org/TR/2023/CR-webnn-20230330/">initial Candidate Recommendation Snapshot</a> the Working Group has gathered further <a href="https://webmachinelearning.github.io/webnn-status/">implementation experience</a> and added new operations and data types needed for well-known <a href="https://github.com/webmachinelearning/webnn/issues/375">transformers to support generative AI use cases</a>. In addition, informed by this implementation experience, the group removed <code>MLCommandEncoder</code>, support for synchronous execution, and higher-level operations that can be expressed in terms of lower-level primitives in a performant manner. The group has also updated the specification to use modern authoring conventions to improve interoperability and precision of normative definitions.
|
1075 | 1074 | The group is developing a new feature, a <a href="https://github.com/webmachinelearning/webnn/issues/482">backend-agnostic storage type</a>, to improve performance and interoperability between the WebNN, WebGPU APIs and purpose-built hardware for ML and expects to republish this document as a Candidate Recommendation Snapshot when ready for implementation.
|
1076 | 1075 | This document is maintained and
|
@@ -1682,9 +1681,13 @@ <h4 class="heading settled" data-level="7.2.2" id="api-ml-createcontext"><span c
|
1682 | 1681 | <li data-md>
|
1683 | 1682 | <p>Set <var>context</var>.<code class="idl"><a data-link-type="idl" href="#dom-mlcontext-lost-slot" id="ref-for-dom-mlcontext-lost-slot">[[lost]]</a></code> to <a data-link-type="dfn" href="https://webidl.spec.whatwg.org/#a-new-promise" id="ref-for-a-new-promise">a new promise</a>.</p>
|
1684 | 1683 | <li data-md>
|
1685 |
| - <p>If <var>options</var>["<code class="idl"><a data-link-type="idl" href="#dom-mlcontextoptions-devicetype" id="ref-for-dom-mlcontextoptions-devicetype①">deviceType</a></code>"] <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#map-exists" id="ref-for-map-exists">exists</a>, then set <var>context</var>.<code class="idl"><a data-link-type="idl" href="#dom-mlcontext-devicetype-slot" id="ref-for-dom-mlcontext-devicetype-slot①">[[deviceType]]</a></code> to <var>options</var>["<code class="idl"><a data-link-type="idl" href="#dom-mlcontextoptions-devicetype" id="ref-for-dom-mlcontextoptions-devicetype②">deviceType</a></code>"]. Otherwise, set <var>context</var>.<code class="idl"><a data-link-type="idl" href="#dom-mlcontext-devicetype-slot" id="ref-for-dom-mlcontext-devicetype-slot②">[[deviceType]]</a></code> to <code class="idl"><a data-link-type="idl" href="#dom-mldevicetype-cpu" id="ref-for-dom-mldevicetype-cpu②">"cpu"</a></code>.</p> |
| 1684 | + <p>If <var>options</var>["<code class="idl"><a data-link-type="idl" href="#dom-mlcontextoptions-devicetype" id="ref-for-dom-mlcontextoptions-devicetype①">deviceType</a></code>"] <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#map-exists" id="ref-for-map-exists">exists</a>, then set <var>context</var>.<code class="idl"><a data-link-type="idl" href="#dom-mlcontext-devicetype-slot" id="ref-for-dom-mlcontext-devicetype-slot①">[[deviceType]]</a></code> to <var>options</var>["<code class="idl"><a data-link-type="idl" href="#dom-mlcontextoptions-devicetype" id="ref-for-dom-mlcontextoptions-devicetype②">deviceType</a></code>"].</p> |
1686 | 1685 | <li data-md>
|
1687 |
| - <p>If <var>options</var>["<code class="idl"><a data-link-type="idl" href="#dom-mlcontextoptions-powerpreference" id="ref-for-dom-mlcontextoptions-powerpreference①">powerPreference</a></code>"] <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#map-exists" id="ref-for-map-exists①">exists</a>, then set <var>context</var>.<code class="idl"><a data-link-type="idl" href="#dom-mlcontext-powerpreference-slot" id="ref-for-dom-mlcontext-powerpreference-slot①">[[powerPreference]]</a></code> to <var>options</var>["<code class="idl"><a data-link-type="idl" href="#dom-mlcontextoptions-powerpreference" id="ref-for-dom-mlcontextoptions-powerpreference②">powerPreference</a></code>"]. Otherwise, set <var>context</var>.<code class="idl"><a data-link-type="idl" href="#dom-mlcontext-powerpreference-slot" id="ref-for-dom-mlcontext-powerpreference-slot②">[[powerPreference]]</a></code> to <code class="idl"><a data-link-type="idl" href="#dom-mlpowerpreference-default" id="ref-for-dom-mlpowerpreference-default②">"default"</a></code>.</p> |
| 1686 | + <p>Otherwise, set <var>context</var>.<code class="idl"><a data-link-type="idl" href="#dom-mlcontext-devicetype-slot" id="ref-for-dom-mlcontext-devicetype-slot②">[[deviceType]]</a></code> to <code class="idl"><a data-link-type="idl" href="#dom-mldevicetype-cpu" id="ref-for-dom-mldevicetype-cpu②">"cpu"</a></code>.</p> |
| 1687 | + <li data-md> |
| 1688 | + <p>If <var>options</var>["<code class="idl"><a data-link-type="idl" href="#dom-mlcontextoptions-powerpreference" id="ref-for-dom-mlcontextoptions-powerpreference①">powerPreference</a></code>"] <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#map-exists" id="ref-for-map-exists①">exists</a>, then set <var>context</var>.<code class="idl"><a data-link-type="idl" href="#dom-mlcontext-powerpreference-slot" id="ref-for-dom-mlcontext-powerpreference-slot①">[[powerPreference]]</a></code> to <var>options</var>["<code class="idl"><a data-link-type="idl" href="#dom-mlcontextoptions-powerpreference" id="ref-for-dom-mlcontextoptions-powerpreference②">powerPreference</a></code>"].</p> |
| 1689 | + <li data-md> |
| 1690 | + <p>Otherwise, set <var>context</var>.<code class="idl"><a data-link-type="idl" href="#dom-mlcontext-powerpreference-slot" id="ref-for-dom-mlcontext-powerpreference-slot②">[[powerPreference]]</a></code> to <code class="idl"><a data-link-type="idl" href="#dom-mlpowerpreference-default" id="ref-for-dom-mlpowerpreference-default②">"default"</a></code>.</p> |
1688 | 1691 | </ol>
|
1689 | 1692 | <li data-md>
|
1690 | 1693 | <p>If the user agent cannot support <var>context</var>.<code class="idl"><a data-link-type="idl" href="#dom-mlcontext-contexttype-slot" id="ref-for-dom-mlcontext-contexttype-slot②">[[contextType]]</a></code>, <var>context</var>.<code class="idl"><a data-link-type="idl" href="#dom-mlcontext-devicetype-slot" id="ref-for-dom-mlcontext-devicetype-slot③">[[deviceType]]</a></code> and <var>context</var>.<code class="idl"><a data-link-type="idl" href="#dom-mlcontext-powerpreference-slot" id="ref-for-dom-mlcontext-powerpreference-slot③">[[powerPreference]]</a></code>, return failure.</p>
|
@@ -8362,9 +8365,9 @@ <h4 class="heading settled" data-level="7.9.32" id="api-mlgraphbuilder-pool2d"><
|
8362 | 8365 | <li data-md>
|
8363 | 8366 | <p>If <var>input</var>’s <a data-link-type="dfn" href="#mloperand-rank" id="ref-for-mloperand-rank⑤④">rank</a> is not 4, then <a data-link-type="dfn" href="https://webidl.spec.whatwg.org/#dfn-throw" id="ref-for-dfn-throw②⑧③">throw</a> a <code class="idl"><a data-link-type="idl" href="https://webidl.spec.whatwg.org/#exceptiondef-typeerror" id="ref-for-exceptiondef-typeerror②⓪④">TypeError</a></code>.</p>
|
8364 | 8367 | <li data-md>
|
8365 |
| - <p>If <var>options</var>.<code class="idl"><a data-link-type="idl" href="#dom-mlpool2doptions-windowdimensions" id="ref-for-dom-mlpool2doptions-windowdimensions①">windowDimensions</a></code> <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#map-exists" id="ref-for-map-exists⑧⑤">exists</a> and its <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#list-size" id="ref-for-list-size③⓪">size</a> is not 2, then <a data-link-type="dfn" href="https://webidl.spec.whatwg.org/#dfn-throw" id="ref-for-dfn-throw②⑧④">throw</a> a <code class="idl"><a data-link-type="idl" href="https://webidl.spec.whatwg.org/#exceptiondef-typeerror" id="ref-for-exceptiondef-typeerror②⓪⑤">TypeError</a></code>.</p> |
| 8368 | + <p>If <var>options</var>.<code class="idl"><a data-link-type="idl" href="#dom-mlpool2doptions-windowdimensions" id="ref-for-dom-mlpool2doptions-windowdimensions①">windowDimensions</a></code> does not <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#map-exists" id="ref-for-map-exists⑧⑤">exist</a>, set <var>options</var>.<code class="idl"><a data-link-type="idl" href="#dom-mlpool2doptions-windowdimensions" id="ref-for-dom-mlpool2doptions-windowdimensions②">windowDimensions</a></code> to the height and width dimensions of the shape of <var>input</var>.</p> |
8366 | 8369 | <li data-md>
|
8367 |
| - <p>Otherwise, set <var>options</var>.<code class="idl"><a data-link-type="idl" href="#dom-mlpool2doptions-windowdimensions" id="ref-for-dom-mlpool2doptions-windowdimensions②">windowDimensions</a></code> to the height and width dimensions of the shape of <var>input</var>.</p> |
| 8370 | + <p>If <var>options</var>.<code class="idl"><a data-link-type="idl" href="#dom-mlpool2doptions-windowdimensions" id="ref-for-dom-mlpool2doptions-windowdimensions③">windowDimensions</a></code>’s <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#list-size" id="ref-for-list-size③⓪">size</a> is not 2, then <a data-link-type="dfn" href="https://webidl.spec.whatwg.org/#dfn-throw" id="ref-for-dfn-throw②⑧④">throw</a> a <code class="idl"><a data-link-type="idl" href="https://webidl.spec.whatwg.org/#exceptiondef-typeerror" id="ref-for-exceptiondef-typeerror②⓪⑤">TypeError</a></code>.</p> |
8368 | 8371 | <li data-md>
|
8369 | 8372 | <p>If <var>options</var>.<code class="idl"><a data-link-type="idl" href="#dom-mlpool2doptions-outputsizes" id="ref-for-dom-mlpool2doptions-outputsizes①">outputSizes</a></code> <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#map-exists" id="ref-for-map-exists⑧⑥">exists</a>, or if <var>options</var>.<code class="idl"><a data-link-type="idl" href="#dom-mlpool2doptions-padding" id="ref-for-dom-mlpool2doptions-padding①">padding</a></code> does not <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#map-exists" id="ref-for-map-exists⑧⑦">exist</a>, set <var>options</var>.<code class="idl"><a data-link-type="idl" href="#dom-mlpool2doptions-padding" id="ref-for-dom-mlpool2doptions-padding②">padding</a></code> to the <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#list" id="ref-for-list③⑤">list</a> « 0, 0, 0, 0 ».</p>
|
8370 | 8373 | <li data-md>
|
@@ -8392,7 +8395,7 @@ <h4 class="heading settled" data-level="7.9.32" id="api-mlgraphbuilder-pool2d"><
|
8392 | 8395 | <li data-md>
|
8393 | 8396 | <p>Let <var>desc</var> be a copy of <var>input</var>.<code class="idl"><a data-link-type="idl" href="#dom-mloperand-descriptor-slot" id="ref-for-dom-mloperand-descriptor-slot⑨">[[descriptor]]</a></code>.</p>
|
8394 | 8397 | <li data-md>
|
8395 |
| - <p>Let <var>outputShape</var> be the result of <a data-link-type="dfn" href="#mlgraphbuilder-calculate-pool2d-output-sizes" id="ref-for-mlgraphbuilder-calculate-pool2d-output-sizes">calculating pool2d output sizes</a> given <var>options</var>.<code class="idl"><a data-link-type="idl" href="#dom-mlpool2doptions-layout" id="ref-for-dom-mlpool2doptions-layout①">layout</a></code>, <var>input</var>’s <a data-link-type="dfn" href="#mloperand-shape" id="ref-for-mloperand-shape⑦⑨">shape</a>, <var>options</var>.<code class="idl"><a data-link-type="idl" href="#dom-mlpool2doptions-roundingtype" id="ref-for-dom-mlpool2doptions-roundingtype②">roundingType</a></code>, <var>options</var>.<code class="idl"><a data-link-type="idl" href="#dom-mlpool2doptions-windowdimensions" id="ref-for-dom-mlpool2doptions-windowdimensions③">windowDimensions</a></code>, <var>options</var>.<code class="idl"><a data-link-type="idl" href="#dom-mlpool2doptions-padding" id="ref-for-dom-mlpool2doptions-padding④">padding</a></code>, <var>options</var>.<code class="idl"><a data-link-type="idl" href="#dom-mlpool2doptions-strides" id="ref-for-dom-mlpool2doptions-strides⑥">strides</a></code>, <var>options</var>.<code class="idl"><a data-link-type="idl" href="#dom-mlpool2doptions-dilations" id="ref-for-dom-mlpool2doptions-dilations⑤">dilations</a></code>, and <var>options</var>.<code class="idl"><a data-link-type="idl" href="#dom-mlpool2doptions-outputsizes" id="ref-for-dom-mlpool2doptions-outputsizes③">outputSizes</a></code> (if it <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#map-exists" id="ref-for-map-exists⑨①">exists</a>).</p> |
| 8398 | + <p>Let <var>outputShape</var> be the result of <a data-link-type="dfn" href="#mlgraphbuilder-calculate-pool2d-output-sizes" id="ref-for-mlgraphbuilder-calculate-pool2d-output-sizes">calculating pool2d output sizes</a> given <var>options</var>.<code class="idl"><a data-link-type="idl" href="#dom-mlpool2doptions-layout" id="ref-for-dom-mlpool2doptions-layout①">layout</a></code>, <var>input</var>’s <a data-link-type="dfn" href="#mloperand-shape" id="ref-for-mloperand-shape⑦⑨">shape</a>, <var>options</var>.<code class="idl"><a data-link-type="idl" href="#dom-mlpool2doptions-roundingtype" id="ref-for-dom-mlpool2doptions-roundingtype②">roundingType</a></code>, <var>options</var>.<code class="idl"><a data-link-type="idl" href="#dom-mlpool2doptions-windowdimensions" id="ref-for-dom-mlpool2doptions-windowdimensions④">windowDimensions</a></code>, <var>options</var>.<code class="idl"><a data-link-type="idl" href="#dom-mlpool2doptions-padding" id="ref-for-dom-mlpool2doptions-padding④">padding</a></code>, <var>options</var>.<code class="idl"><a data-link-type="idl" href="#dom-mlpool2doptions-strides" id="ref-for-dom-mlpool2doptions-strides⑥">strides</a></code>, <var>options</var>.<code class="idl"><a data-link-type="idl" href="#dom-mlpool2doptions-dilations" id="ref-for-dom-mlpool2doptions-dilations⑤">dilations</a></code>, and <var>options</var>.<code class="idl"><a data-link-type="idl" href="#dom-mlpool2doptions-outputsizes" id="ref-for-dom-mlpool2doptions-outputsizes③">outputSizes</a></code> (if it <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#map-exists" id="ref-for-map-exists⑨①">exists</a>).</p> |
8396 | 8399 | <li data-md>
|
8397 | 8400 | <p>If any <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#list-item" id="ref-for-list-item⑧">item</a> in <var>outputShape</var> is not a <a data-link-type="dfn" href="#valid-dimension" id="ref-for-valid-dimension①③">valid dimension</a>, then <a data-link-type="dfn" href="https://webidl.spec.whatwg.org/#dfn-throw" id="ref-for-dfn-throw②⑨②">throw</a> a <code class="idl"><a data-link-type="idl" href="https://webidl.spec.whatwg.org/#exceptiondef-typeerror" id="ref-for-exceptiondef-typeerror②①③">TypeError</a></code>.</p>
|
8398 | 8401 | <li data-md>
|
@@ -13607,7 +13610,7 @@ <h2 class="no-num no-ref heading settled" id="issues-index"><span class="content
|
13607 | 13610 | "dom-mlpool2doptions-padding": {"dfnID":"dom-mlpool2doptions-padding","dfnText":"padding","external":false,"refSections":[{"refs":[{"id":"ref-for-dom-mlpool2doptions-padding"},{"id":"ref-for-dom-mlpool2doptions-padding\u2460"},{"id":"ref-for-dom-mlpool2doptions-padding\u2461"},{"id":"ref-for-dom-mlpool2doptions-padding\u2462"},{"id":"ref-for-dom-mlpool2doptions-padding\u2463"}],"title":"7.9.32. Pooling operations"}],"url":"#dom-mlpool2doptions-padding"},
|
13608 | 13611 | "dom-mlpool2doptions-roundingtype": {"dfnID":"dom-mlpool2doptions-roundingtype","dfnText":"roundingType","external":false,"refSections":[{"refs":[{"id":"ref-for-dom-mlpool2doptions-roundingtype"},{"id":"ref-for-dom-mlpool2doptions-roundingtype\u2460"},{"id":"ref-for-dom-mlpool2doptions-roundingtype\u2461"}],"title":"7.9.32. Pooling operations"}],"url":"#dom-mlpool2doptions-roundingtype"},
|
13609 | 13612 | "dom-mlpool2doptions-strides": {"dfnID":"dom-mlpool2doptions-strides","dfnText":"strides","external":false,"refSections":[{"refs":[{"id":"ref-for-dom-mlpool2doptions-strides"},{"id":"ref-for-dom-mlpool2doptions-strides\u2460"},{"id":"ref-for-dom-mlpool2doptions-strides\u2461"},{"id":"ref-for-dom-mlpool2doptions-strides\u2462"},{"id":"ref-for-dom-mlpool2doptions-strides\u2463"},{"id":"ref-for-dom-mlpool2doptions-strides\u2464"},{"id":"ref-for-dom-mlpool2doptions-strides\u2465"}],"title":"7.9.32. Pooling operations"}],"url":"#dom-mlpool2doptions-strides"},
|
13610 |
| -"dom-mlpool2doptions-windowdimensions": {"dfnID":"dom-mlpool2doptions-windowdimensions","dfnText":"windowDimensions","external":false,"refSections":[{"refs":[{"id":"ref-for-dom-mlpool2doptions-windowdimensions"},{"id":"ref-for-dom-mlpool2doptions-windowdimensions\u2460"},{"id":"ref-for-dom-mlpool2doptions-windowdimensions\u2461"},{"id":"ref-for-dom-mlpool2doptions-windowdimensions\u2462"}],"title":"7.9.32. Pooling operations"}],"url":"#dom-mlpool2doptions-windowdimensions"}, |
| 13613 | +"dom-mlpool2doptions-windowdimensions": {"dfnID":"dom-mlpool2doptions-windowdimensions","dfnText":"windowDimensions","external":false,"refSections":[{"refs":[{"id":"ref-for-dom-mlpool2doptions-windowdimensions"},{"id":"ref-for-dom-mlpool2doptions-windowdimensions\u2460"},{"id":"ref-for-dom-mlpool2doptions-windowdimensions\u2461"},{"id":"ref-for-dom-mlpool2doptions-windowdimensions\u2462"},{"id":"ref-for-dom-mlpool2doptions-windowdimensions\u2463"}],"title":"7.9.32. Pooling operations"}],"url":"#dom-mlpool2doptions-windowdimensions"}, |
13611 | 13614 | "dom-mlpowerpreference-default": {"dfnID":"dom-mlpowerpreference-default","dfnText":"default","external":false,"refSections":[{"refs":[{"id":"ref-for-dom-mlpowerpreference-default"}],"title":"7.2. ML interface"},{"refs":[{"id":"ref-for-dom-mlpowerpreference-default\u2460"},{"id":"ref-for-dom-mlpowerpreference-default\u2461"}],"title":"7.2.2. createContext()"}],"url":"#dom-mlpowerpreference-default"},
|
13612 | 13615 | "dom-mlpowerpreference-high-performance": {"dfnID":"dom-mlpowerpreference-high-performance","dfnText":"high-performance","external":false,"refSections":[{"refs":[{"id":"ref-for-dom-mlpowerpreference-high-performance"}],"title":"7.2. ML interface"}],"url":"#dom-mlpowerpreference-high-performance"},
|
13613 | 13616 | "dom-mlpowerpreference-low-power": {"dfnID":"dom-mlpowerpreference-low-power","dfnText":"low-power","external":false,"refSections":[{"refs":[{"id":"ref-for-dom-mlpowerpreference-low-power"}],"title":"7.2. ML interface"}],"url":"#dom-mlpowerpreference-low-power"},
|
|
0 commit comments