Skip to content

Commit 8f6f536

Browse files
Use broadcasting definition in expand(), rather than bespoke steps
This matches the Chromium implementation.
1 parent 3d363f6 commit 8f6f536

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

index.bs

+5-10
Original file line numberDiff line numberDiff line change
@@ -2861,17 +2861,12 @@ partial interface MLGraphBuilder {
28612861
<div class="note">
28622862
The permissions and context validity have been checked by [[#api-mlgraphbuilder-constructor]] steps.
28632863
</div>
2864-
1. If any of the following steps fail, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
2865-
1. Let |inputDesc| be |input|.{{MLOperand/[[descriptor]]}}.
2866-
1. If the sequence length of |newShape| is not equal to the [=rank=] of |inputDesc|, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
2867-
1. Let |outputDesc| be a copy of |inputDesc|.
2868-
1. [=list/For each=] |index| in [=the range=] 0 to the [=rank=] of |input|, exclusive:
2869-
Issue: Can this be replaced with [=unidirectionally broadcasting the shapes=] |inputDesc| and |newShape|.
2870-
1. Let |size| be the |input|.{{MLOperand/shape()}}[|index|].
2871-
1. If |size| is not equal to 1 and not equal to |newShape|[index], then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
2872-
1. If |size| is equal to 1, then let |outputDesc|.{{MLOperandDescriptor/dimensions}}[|index|] be |newShape|[|index|].
2864+
1. Let |descriptor| be a new {{MLOperandDescriptor}}.
2865+
1. Set |descriptor|.{{MLOperandDescriptor/dataType}} to |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dataType}}.
2866+
1. Set |descriptor|.{{MLOperandDescriptor/dimensions}} to the result of [=unidirectionally broadcasting the shapes=] |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dimensions}} and |newShape|.
2867+
1. If that returns failure, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
28732868
1. If any of the following sub-steps fail, [=exception/throw=] an "{{OperationError}}" {{DOMException}}.
2874-
1. Let |output| be the result of [=creating an MLOperand=] given [=this=] and |outputDesc|.
2869+
1. Let |output| be the result of [=creating an MLOperand=] given [=this=] and |descriptor|.
28752870
1. Make a request to the underlying platform to:
28762871
1. Create [=platform operator=] |expandImpl| for this method, given |input| and |newShape|.
28772872
1. Set |output|.{{MLOperand/[[operator]]}} to |expandImpl|.

0 commit comments

Comments
 (0)