|
7 | 7 | <link href="https://www.w3.org/StyleSheets/TR/2021/W3C-ED" rel="stylesheet"> |
8 | 8 | <meta content="Bikeshed version 82ce88815, updated Thu Sep 7 16:33:55 2023 -0700" name="generator"> |
9 | 9 | <link href="https://www.w3.org/TR/webnn/" rel="canonical"> |
10 | | - <meta content="f133ff02d22389af2dc947154309fed244684327" name="document-revision"> |
| 10 | + <meta content="4eda710f32457b119a4fc74d5dd4016818079ec1" name="document-revision"> |
11 | 11 | <style> |
12 | 12 | /* Make <dl> blocks more distinct from their surroundings. */ |
13 | 13 | main dl:not(.switch) { |
@@ -8135,37 +8135,37 @@ <h2 class="heading settled" data-level="8" id="algorithms"><span class="secno">8 |
8135 | 8135 | <h3 class="heading settled" data-level="8.1" id="algorithms-broadcasting"><span class="secno">8.1. </span><span class="content">Broadcasting</span><a class="self-link" href="#algorithms-broadcasting"></a></h3> |
8136 | 8136 | <p>Broadcasting refers to how operations treat tensors with different shapes, and follow the precedent set by <a data-link-type="biblio" href="#biblio-numpy-broadcasting-rule" title="General Broadcasting Rules of NumPy">[numpy-broadcasting-rule]</a>.</p> |
8137 | 8137 | <details class="algorithm" data-algorithm="unidirectionally broadcasting the shapes" open> |
8138 | | - <summary> To <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="unidirectionally broadcasting the shapes" data-noexport id="unidirectionally-broadcasting-the-shapes">unidirectionally broadcast the shapes</dfn> <var>shapeA</var> and <var>shapeB</var>, perform the following steps. <var>shapeA</var> and <var>shapeB</var> are <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#list" id="ref-for-list⑤③">lists</a> of positive integers, representing the dimensions of tensors, and the steps return a new <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#list" id="ref-for-list⑤④">list</a> of positive integers, or failure. </summary> |
| 8138 | + <summary> To <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="unidirectionally broadcasting the shapes" data-noexport id="unidirectionally-broadcasting-the-shapes">unidirectionally broadcast the shapes</dfn> <var>shapeFrom</var> and <var>shapeTo</var>, perform the following steps. <var>shapeFrom</var> and <var>shapeTo</var> are <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#list" id="ref-for-list⑤③">lists</a> of positive integers, representing the dimensions of tensors, and the steps return a new <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#list" id="ref-for-list⑤④">list</a> of positive integers, or failure. </summary> |
8139 | 8139 | <ol> |
8140 | 8140 | <li data-md> |
8141 | | - <p>Let <var>sizeA</var> be <var>shapeA</var>’s <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#list-size" id="ref-for-list-size④⑥">size</a>.</p> |
| 8141 | + <p>Let <var>sizeFrom</var> be <var>shapeFrom</var>’s <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#list-size" id="ref-for-list-size④⑥">size</a>.</p> |
8142 | 8142 | <li data-md> |
8143 | | - <p>Let <var>sizeB</var> be <var>shapeB</var>’s <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#list-size" id="ref-for-list-size④⑦">size</a>.</p> |
| 8143 | + <p>Let <var>sizeTo</var> be <var>shapeTo</var>’s <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#list-size" id="ref-for-list-size④⑦">size</a>.</p> |
8144 | 8144 | <li data-md> |
8145 | | - <p>If <var>sizeB</var> > <var>sizeA</var>, then return failure.</p> |
| 8145 | + <p>If <var>sizeFrom</var> > <var>sizeTo</var>, then return failure.</p> |
8146 | 8146 | <li data-md> |
8147 | | - <p>Let <var>paddedB</var> be a <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#list-clone" id="ref-for-list-clone⑨">clone</a> of <var>shapeB</var>.</p> |
| 8147 | + <p>Let <var>paddedShapeFrom</var> be a <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#list-clone" id="ref-for-list-clone⑨">clone</a> of <var>shapeFrom</var>.</p> |
8148 | 8148 | <li data-md> |
8149 | | - <p>While <var>paddedB</var>’s <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#list-size" id="ref-for-list-size④⑧">size</a> is less than <var>sizeA</var>, <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#list-prepend" id="ref-for-list-prepend">prepend</a> 1 to <var>paddedB</var>.</p> |
| 8149 | + <p>While <var>paddedShapeFrom</var>’s <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#list-size" id="ref-for-list-size④⑧">size</a> is less than <var>sizeTo</var>, <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#list-prepend" id="ref-for-list-prepend">prepend</a> 1 to <var>paddedShapeFrom</var>.</p> |
8150 | 8150 | <li data-md> |
8151 | 8151 | <p>Let <var>outputShape</var> be a new <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#list" id="ref-for-list⑤⑤">list</a>.</p> |
8152 | 8152 | <li data-md> |
8153 | | - <p><a data-link-type="dfn" href="https://infra.spec.whatwg.org/#list-iterate" id="ref-for-list-iterate①⑤">For each</a> <var>index</var> in <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#the-range" id="ref-for-the-range①④">the range</a> 0 to <var>sizeA</var>, exclusive:</p> |
| 8153 | + <p><a data-link-type="dfn" href="https://infra.spec.whatwg.org/#list-iterate" id="ref-for-list-iterate①⑤">For each</a> <var>index</var> in <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#the-range" id="ref-for-the-range①④">the range</a> 0 to <var>sizeTo</var>, exclusive:</p> |
8154 | 8154 | <ol> |
8155 | 8155 | <li data-md> |
8156 | | - <p>Let <var>dimA</var> be <var>shapeA</var>[<var>index</var>].</p> |
| 8156 | + <p>Let <var>dimFrom</var> be <var>paddedShapeFrom</var>[<var>index</var>].</p> |
8157 | 8157 | <li data-md> |
8158 | | - <p>Let <var>dimB</var> be <var>paddedB</var>[<var>index</var>].</p> |
| 8158 | + <p>Let <var>dimTo</var> be <var>shapeTo</var>[<var>index</var>].</p> |
8159 | 8159 | <li data-md> |
8160 | | - <p>If <var>dimA</var> is not equal to <var>dimB</var> and <var>dimA</var> is not equal to 1, then return failure.</p> |
| 8160 | + <p>If <var>dimTo</var> is not equal to <var>dimFrom</var> and <var>dimFrom</var> is not equal to 1, then return failure.</p> |
8161 | 8161 | <li data-md> |
8162 | | - <p><a data-link-type="dfn" href="https://infra.spec.whatwg.org/#list-append" id="ref-for-list-append③">Append</a> <var>dimA</var> to <var>outputShape</var>.</p> |
| 8162 | + <p><a data-link-type="dfn" href="https://infra.spec.whatwg.org/#list-append" id="ref-for-list-append③">Append</a> <var>dimTo</var> to <var>outputShape</var>.</p> |
8163 | 8163 | </ol> |
8164 | 8164 | <li data-md> |
8165 | 8165 | <p>Return <var>outputShape</var>.</p> |
8166 | 8166 | </ol> |
8167 | 8167 | </details> |
8168 | | - <p class="algorithm" data-algorithm="unidirectionally broadcastable"> <var>shapeA</var> is <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="unidirectionally-broadcastable">unidirectionally broadcastable</dfn> to <var>shapeB</var> if <a data-link-type="dfn" href="#unidirectionally-broadcasting-the-shapes" id="ref-for-unidirectionally-broadcasting-the-shapes②">unidirectionally broadcasting the shapes</a> <var>shapeA</var> and <var>shapeB</var> does not result in failure. </p> |
| 8168 | + <p class="algorithm" data-algorithm="unidirectionally broadcastable"> <var>shapeFrom</var> is <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="unidirectionally-broadcastable">unidirectionally broadcastable</dfn> to <var>shapeTo</var> if <a data-link-type="dfn" href="#unidirectionally-broadcasting-the-shapes" id="ref-for-unidirectionally-broadcasting-the-shapes②">unidirectionally broadcasting the shapes</a> <var>shapeFrom</var> and <var>shapeTo</var> does not result in failure. </p> |
8169 | 8169 | <details class="algorithm" data-algorithm="bidirectionally broadcasting the shapes" open> |
8170 | 8170 | <summary> To <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="bidirectionally broadcasting the shapes" data-noexport id="bidirectionally-broadcasting-the-shapes">bidirectionally broadcast the shapes</dfn> <var>shapeA</var> and <var>shapeB</var>, perform the following steps. <var>shapeA</var> and <var>shapeB</var> are <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#list" id="ref-for-list⑤⑥">lists</a> of positive integers, representing the dimensions of tensors, and the steps return a new <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#list" id="ref-for-list⑤⑦">list</a> of positive integers, or failure. </summary> |
8171 | 8171 | <ol> |
|
0 commit comments