From 1b63ff71cbefa4765d2c59154c81eb1ab77a4d7e Mon Sep 17 00:00:00 2001 From: Joshua Bell Date: Mon, 5 Feb 2024 09:32:40 -0800 Subject: [PATCH] Use broadcasting definition in expand(), rather than bespoke steps This matches the Chromium implementation. --- index.bs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/index.bs b/index.bs index f9a4e08e..408b2bff 100644 --- a/index.bs +++ b/index.bs @@ -2842,17 +2842,12 @@ partial interface MLGraphBuilder {
The permissions and context validity have been checked by [[#api-mlgraphbuilder-constructor]] steps.
- 1. If any of the following steps fail, then [=exception/throw=] a "{{DataError}}" {{DOMException}}. - 1. Let |inputDesc| be |input|.{{MLOperand/[[descriptor]]}}. - 1. If the sequence length of |newShape| is not equal to the [=rank=] of |inputDesc|, then [=exception/throw=] a "{{DataError}}" {{DOMException}}. - 1. Let |outputDesc| be a copy of |inputDesc|. - 1. [=list/For each=] |index| in [=the range=] 0 to the [=rank=] of |input|, exclusive: - Issue: Can this be replaced with [=unidirectionally broadcasting the shapes=] |inputDesc| and |newShape|. - 1. Let |size| be the |input|.{{MLOperand/shape()}}[|index|]. - 1. If |size| is not equal to 1 and not equal to |newShape|[index], then [=exception/throw=] a "{{DataError}}" {{DOMException}}. - 1. If |size| is equal to 1, then let |outputDesc|.{{MLOperandDescriptor/dimensions}}[|index|] be |newShape|[|index|]. + 1. Let |descriptor| be a new {{MLOperandDescriptor}}. + 1. Set |descriptor|.{{MLOperandDescriptor/dataType}} to |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dataType}}. + 1. Set |descriptor|.{{MLOperandDescriptor/dimensions}} to the result of [=unidirectionally broadcasting the shapes=] |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dimensions}} and |newShape|. + 1. If that returns failure, then [=exception/throw=] a "{{DataError}}" {{DOMException}}. 1. If any of the following sub-steps fail, [=exception/throw=] an "{{OperationError}}" {{DOMException}}. - 1. Let |output| be the result of [=creating an MLOperand=] given [=this=] and |outputDesc|. + 1. Let |output| be the result of [=creating an MLOperand=] given [=this=] and |descriptor|. 1. Make a request to the underlying platform to: 1. Create [=platform operator=] |expandImpl| for this method, given |input| and |newShape|. 1. Set |output|.{{MLOperand/[[operator]]}} to |expandImpl|.