From ae171b939f2f8d5616f9b375ff75763a215b122d Mon Sep 17 00:00:00 2001 From: Dwayne Robinson Date: Thu, 2 Nov 2023 06:47:11 -0700 Subject: [PATCH 01/10] Fix dimensions for 0D scalars --- index.bs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/index.bs b/index.bs index 35ee539c..a811e819 100644 --- a/index.bs +++ b/index.bs @@ -996,7 +996,6 @@ The {{MLOperand}} objects are created by the methods of {{MLGraphBuilder}}, inte To check dimensions given |dimensions| and |type|, run the following steps:
- 1. If the [=list/size=] of |dimensions| is 0, return false. 1. If the [=list/size=] of |dimensions| is too large to be supported by the implementation, return false. 1. If any element of |dimensions| is not a positive number, or it is too large to be supported by the implementation given |type|, return false. 1. Return true. @@ -1611,7 +1610,7 @@ Create a named {{MLOperand}} based on a descriptor, that can be used as an input
1. If |name| is empty, then [=exception/throw=] a {{TypeError}}. 1. [=Assert=]: the type of |descriptor| is {{MLOperandDescriptor}}. - 1. [=Assert=]: If |descriptor|.{{MLOperandDescriptor/dimensions}} does not [=map/exist=], then |descriptor| defines a scalar input. + 1. [=Assert=]: If |descriptor|.{{MLOperandDescriptor/dimensions}} does not [=map/exist=], then |descriptor| defines a scalar input, equivalent to zero dimensions. 1. If |descriptor|.{{MLOperandDescriptor/dimensions}} [=map/exists=]: 1. If the [=check dimensions=] steps given |descriptor|.{{MLOperandDescriptor/dataType}} and |descriptor|.{{MLOperandDescriptor/dimensions}} return false, then [=exception/throw=] a "{{DataError}}" {{DOMException}}. 1. If the [=byte length=] of |descriptor| is not supported by the underlying platform, then [=exception/throw=] a "{{DataError}}" {{DOMException}}. @@ -4863,9 +4862,9 @@ partial interface MLGraphBuilder {
1. [=Assert=]: the type of |input| is {{MLOperand}}. 1. Let |outputShape| be an empty array of {{unsigned long}}. - 1. If |newShape| is a scalar [=number=], set |outputShape| to `« 1 »`. + 1. If |newShape| is a scalar [=number=], set |outputShape| to `«»`. 1. Otherwise, if |newShape| is an array of {{unsigned long}}: - 1. If the [=list/size=] of |newShape| is 0, set |outputShape| to `« 1 »` (reshaping to scalar). + 1. If the [=list/size=] of |newShape| is 0, set |outputShape| to `«»` (reshaping to scalar). 1. If |newShape| contains more than one `null` value, then [=exception/throw=] a "{{DataError}}" {{DOMException}}. 1. If any value in |newShape| is 0, then [=exception/throw=] a "{{DataError}}" {{DOMException}}. 1. Let |inputElementCount| be the product of all elements in |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dimensions}}. From a029873dae1638fd052e43e8cdb062d5a69cf8e0 Mon Sep 17 00:00:00 2001 From: Dwayne Robinson Date: Mon, 6 Nov 2023 19:54:05 -0800 Subject: [PATCH 02/10] Code review comments --- index.bs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/index.bs b/index.bs index a811e819..713a4fc6 100644 --- a/index.bs +++ b/index.bs @@ -1610,7 +1610,7 @@ Create a named {{MLOperand}} based on a descriptor, that can be used as an input
1. If |name| is empty, then [=exception/throw=] a {{TypeError}}. 1. [=Assert=]: the type of |descriptor| is {{MLOperandDescriptor}}. - 1. [=Assert=]: If |descriptor|.{{MLOperandDescriptor/dimensions}} does not [=map/exist=], then |descriptor| defines a scalar input, equivalent to zero dimensions. + 1. [=Assert=]: If |descriptor|.{{MLOperandDescriptor/dimensions}} does not [=map/exist=], then |descriptor| defines a scalar input, and |descriptor|.{{MLOperandDescriptor/dimensions}} is set to an empty array of {{unsigned long long}}. 1. If |descriptor|.{{MLOperandDescriptor/dimensions}} [=map/exists=]: 1. If the [=check dimensions=] steps given |descriptor|.{{MLOperandDescriptor/dataType}} and |descriptor|.{{MLOperandDescriptor/dimensions}} return false, then [=exception/throw=] a "{{DataError}}" {{DOMException}}. 1. If the [=byte length=] of |descriptor| is not supported by the underlying platform, then [=exception/throw=] a "{{DataError}}" {{DOMException}}. @@ -4861,16 +4861,15 @@ partial interface MLGraphBuilder {
1. [=Assert=]: the type of |input| is {{MLOperand}}. + 1. [=Assert=]: the type of |newShape| is an array of {{unsigned long long}}. 1. Let |outputShape| be an empty array of {{unsigned long}}. - 1. If |newShape| is a scalar [=number=], set |outputShape| to `«»`. - 1. Otherwise, if |newShape| is an array of {{unsigned long}}: - 1. If the [=list/size=] of |newShape| is 0, set |outputShape| to `«»` (reshaping to scalar). - 1. If |newShape| contains more than one `null` value, then [=exception/throw=] a "{{DataError}}" {{DOMException}}. - 1. If any value in |newShape| is 0, then [=exception/throw=] a "{{DataError}}" {{DOMException}}. - 1. Let |inputElementCount| be the product of all elements in |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dimensions}}. - 1. If |newShape| contains a `null` value, set that value to |inputElementCount| divided by the product of all other values in |newShape|. - 1. If that value is too large for {{unsigned long}}, then [=exception/throw=] a "{{DataError}}" {{DOMException}}. - 1. If product of all values in |newShape| is not equal to |inputElementCount|, then [=exception/throw=] a "{{DataError}}" {{DOMException}}. + 1. If the [=list/size=] of |newShape| is 0, set |outputShape| to `«»` (reshaping to scalar). + 1. If |newShape| contains more than one `null` value, then [=exception/throw=] a "{{DataError}}" {{DOMException}}. + 1. If any value in |newShape| is 0, then [=exception/throw=] a "{{DataError}}" {{DOMException}}. + 1. Let |inputElementCount| be the product of all elements in |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dimensions}}. + 1. If |newShape| contains a `null` value, set that value to |inputElementCount| divided by the product of all other values in |newShape|. + 1. If that value is too large for {{unsigned long}}, then [=exception/throw=] a "{{DataError}}" {{DOMException}}. + 1. If product of all values in |newShape| is not equal to |inputElementCount|, then [=exception/throw=] a "{{DataError}}" {{DOMException}}. 1. Let |desc| be a copy of |input|.{{MLOperand/[[descriptor]]}}. 1. Set |desc|.{{MLOperandDescriptor/dimensions}} to |newShape|. 1. If any of the following sub-steps fail, [=exception/throw=] an "{{OperationError}}" {{DOMException}}. From ad31618232b89344b86252c945814a2027ab3f82 Mon Sep 17 00:00:00 2001 From: Dwayne Robinson Date: Thu, 8 Feb 2024 16:36:43 -0800 Subject: [PATCH 03/10] reshape CR feedback --- index.bs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/index.bs b/index.bs index 713a4fc6..aa9dc41e 100644 --- a/index.bs +++ b/index.bs @@ -1609,11 +1609,9 @@ Create a named {{MLOperand}} based on a descriptor, that can be used as an input The permissions and context validity have been checked by [[#api-mlgraphbuilder-constructor]] steps.
1. If |name| is empty, then [=exception/throw=] a {{TypeError}}. - 1. [=Assert=]: the type of |descriptor| is {{MLOperandDescriptor}}. - 1. [=Assert=]: If |descriptor|.{{MLOperandDescriptor/dimensions}} does not [=map/exist=], then |descriptor| defines a scalar input, and |descriptor|.{{MLOperandDescriptor/dimensions}} is set to an empty array of {{unsigned long long}}. - 1. If |descriptor|.{{MLOperandDescriptor/dimensions}} [=map/exists=]: - 1. If the [=check dimensions=] steps given |descriptor|.{{MLOperandDescriptor/dataType}} and |descriptor|.{{MLOperandDescriptor/dimensions}} return false, then [=exception/throw=] a "{{DataError}}" {{DOMException}}. - 1. If the [=byte length=] of |descriptor| is not supported by the underlying platform, then [=exception/throw=] a "{{DataError}}" {{DOMException}}. + 1. If |descriptor|.{{MLOperandDescriptor/dimensions}} does not [=map/exist=], then set |descriptor|.{{MLOperandDescriptor/dimensions}} is set to an empty list, indicating a scalar input. + 1. If the [=check dimensions=] steps given |descriptor|.{{MLOperandDescriptor/dataType}} and |descriptor|.{{MLOperandDescriptor/dimensions}} return false, then [=exception/throw=] a "{{DataError}}" {{DOMException}}. + 1. If the [=byte length=] of |descriptor| is not supported by the underlying platform, then [=exception/throw=] a "{{DataError}}" {{DOMException}}. 1. If any of the following sub-steps fail, [=exception/throw=] an "{{OperationError}}" {{DOMException}}. 1. Let |operand| be the result of creating an MLOperand given [=this=] and |descriptor|. 1. Set |operand|.{{MLOperand/[[name]]}} to |name|. @@ -1671,7 +1669,7 @@ Build a composed graph up to a given output operand into a computational graph, 1. [=map/For each=] |operand| in |outputs|: 1. If validating MLOperand given |operand| and [=this=] returns false, then [=exception/throw=] a {{TypeError}}. 1. If |operand| was created as an input by the underlying platform: - 1. If |operand|.{{MLOperand/[[name]]}}] is not unique for |graphImpl|, then [=exception/throw=] a {{TypeError}}. + 1. If |operand|.{{MLOperand/[[name]]}} is not unique for |graphImpl|, then [=exception/throw=] a {{TypeError}}. 1. Add |operand|.{{MLOperand/[[descriptor]]}} to |graph|.{{MLGraph/[[inputDescriptors]]}}[|operand|.{{MLOperand/[[name]]}}]. 1. If |operand| was created as a constant by the underlying platform: 1. Implementations MAY preprocess and optimize the tensor data of |operand| for the underlying platform. From 8532820c84ea55b2334475ad2b63cde13627bcfa Mon Sep 17 00:00:00 2001 From: Dwayne Robinson Date: Thu, 8 Feb 2024 18:21:14 -0800 Subject: [PATCH 04/10] More CR feedback --- index.bs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/index.bs b/index.bs index 7ec0b5c3..5f492473 100644 --- a/index.bs +++ b/index.bs @@ -1815,10 +1815,7 @@ Data truncation will occur when the specified value exceeds the range of the spe 1. Let |descriptor| be a new {{MLOperandDescriptor}}. 1. Set |descriptor|.{{MLOperandDescriptor/dataType}} to |type|. - 1. Set |descriptor|.{{MLOperandDescriptor/dimensions}} to `undefined`. -
- In the case of a scalar constant, |descriptor|.{{MLOperandDescriptor/dimensions}} is ignored. -
+ 1. Set |descriptor|.{{MLOperandDescriptor/dimensions}} to the empty [=/list=] « ». 1. If any of the following sub-steps fail, [=exception/throw=] an "{{OperationError}}" {{DOMException}}. 1. Let |operand| be the result of [=creating an MLOperand=] given [=this=] and |descriptor|. 1. Make a request to the underlying platform to: @@ -3997,6 +3994,7 @@ partial interface MLGraphBuilder {
The shape of |input|, |weight| or |recurrentWeight| could be also checked here.
+ 1. Require the shape of each tensor to match its expected rank, or else [=exception/throw=] a "{{DataError}}" {{DOMException}}: the rank of input, weight, recurrentWeight, initialHiddenState, and initialCellState is 3; and the rank of bias, recurrentBias, and peepholeWeight is 2. 1. If |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dimensions}}[0] is not equal to |steps|, then [=exception/throw=] a "{{DataError}}" {{DOMException}}. 1. Let |batchSize| be |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dimensions}}[1]. 1. If |options|.{{MLLstmOptions/bias}} [=map/exists=]: @@ -5986,7 +5984,7 @@ The {{MLOperand}} objects are created by the methods of {{MLGraphBuilder}}, inte
1. If |builder| is not equal to |operand|.{{MLOperand/[[builder]]}}, return false. 1. Let |desc| be |operand|.{{MLOperand/[[descriptor]]}}. - 1. If |desc|.{{MLOperandDescriptor/dimensions}} [=map/exists=] and [=checking dimensions=] given |desc|.{{MLOperandDescriptor/dimensions}} and |desc|.{{MLOperandDescriptor/dataType}} returns false, then return false. + 1. If [=checking dimensions=] given |desc|.{{MLOperandDescriptor/dimensions}} and |desc|.{{MLOperandDescriptor/dataType}} returns false, then return false. 1. Return true.
@@ -6058,7 +6056,7 @@ dictionary MLOperandDescriptor { required MLOperandDataType dataType; // The dimensions field is only required for tensor operands. - sequence dimensions; + sequence dimensions = []; }; From 9432814122282ec7287ca537d6de3d4135b399a7 Mon Sep 17 00:00:00 2001 From: Dwayne Robinson Date: Thu, 8 Feb 2024 18:28:41 -0800 Subject: [PATCH 05/10] Minor cleanup --- index.bs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.bs b/index.bs index 5f492473..fd8a1892 100644 --- a/index.bs +++ b/index.bs @@ -3994,7 +3994,7 @@ partial interface MLGraphBuilder {
The shape of |input|, |weight| or |recurrentWeight| could be also checked here.
- 1. Require the shape of each tensor to match its expected rank, or else [=exception/throw=] a "{{DataError}}" {{DOMException}}: the rank of input, weight, recurrentWeight, initialHiddenState, and initialCellState is 3; and the rank of bias, recurrentBias, and peepholeWeight is 2. + 1. Require the shape of each tensor to match its expected rank, or else [=exception/throw=] a "{{DataError}}" {{DOMException}}: the rank of |input|, |weight|, |recurrentWeight|, |initialHiddenState|, and |initialCellState| is 3; and the rank of |bias|, |recurrentBias|, and |peepholeWeight| is 2. 1. If |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dimensions}}[0] is not equal to |steps|, then [=exception/throw=] a "{{DataError}}" {{DOMException}}. 1. Let |batchSize| be |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dimensions}}[1]. 1. If |options|.{{MLLstmOptions/bias}} [=map/exists=]: @@ -5119,7 +5119,7 @@ partial interface MLGraphBuilder { 1. Let |outputShape| be an empty array of {{unsigned long}}. 1. If |newShape| is a scalar [=number=], set |outputShape| to the empty [=/list=] « » (reshaping to scalar). 1. Otherwise, if |newShape| is an array of {{unsigned long}}: - 1. If the [=list/size=] of |newShape| is 0, set |outputShape| to the empty [=/list=] «» (reshaping to scalar). + 1. If the [=list/size=] of |newShape| is 0, set |outputShape| to the empty [=/list=] « » (reshaping to scalar). 1. If any value in |newShape| is 0, then [=exception/throw=] a "{{DataError}}" {{DOMException}}. 1. Let |inputElementCount| be the product of all elements in |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dimensions}}. 1. If product of all values in |newShape| is not equal to |inputElementCount|, then [=exception/throw=] a "{{DataError}}" {{DOMException}}. From 1d2f305cf73ab6fa9296c3b0b68435a13f54671c Mon Sep 17 00:00:00 2001 From: Dwayne Robinson Date: Thu, 8 Feb 2024 18:39:28 -0800 Subject: [PATCH 06/10] Fix bikeshed validation on LSTM tensor names --- index.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.bs b/index.bs index fd8a1892..033fa4f2 100644 --- a/index.bs +++ b/index.bs @@ -3994,7 +3994,7 @@ partial interface MLGraphBuilder {
The shape of |input|, |weight| or |recurrentWeight| could be also checked here.
- 1. Require the shape of each tensor to match its expected rank, or else [=exception/throw=] a "{{DataError}}" {{DOMException}}: the rank of |input|, |weight|, |recurrentWeight|, |initialHiddenState|, and |initialCellState| is 3; and the rank of |bias|, |recurrentBias|, and |peepholeWeight| is 2. + 1. Require the shape of each tensor to match its expected rank, or else [=exception/throw=] a "{{DataError}}" {{DOMException}}: the rank of |input|, |weight|, |recurrentWeight|, |options|.{{MLLstmOptions/initialHiddenState}}, and |options|.{{MLLstmOptions/initialCellState}} is 3; and the rank of |options|.{{MLLstmOptions/bias}}, |options|.{{MLLstmOptions/recurrentBias}}, and |options|.{{MLLstmOptions/peepholeWeight}} is 2. 1. If |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dimensions}}[0] is not equal to |steps|, then [=exception/throw=] a "{{DataError}}" {{DOMException}}. 1. Let |batchSize| be |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dimensions}}[1]. 1. If |options|.{{MLLstmOptions/bias}} [=map/exists=]: From 21546e65dbb92f7a7356b8d5a98164d18154b694 Mon Sep 17 00:00:00 2001 From: Dwayne Robinson Date: Thu, 8 Feb 2024 18:52:04 -0800 Subject: [PATCH 07/10] Fix reshape bad merge --- index.bs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/index.bs b/index.bs index 033fa4f2..b1ebd9aa 100644 --- a/index.bs +++ b/index.bs @@ -5117,12 +5117,10 @@ partial interface MLGraphBuilder {
1. Let |outputShape| be an empty array of {{unsigned long}}. - 1. If |newShape| is a scalar [=number=], set |outputShape| to the empty [=/list=] « » (reshaping to scalar). - 1. Otherwise, if |newShape| is an array of {{unsigned long}}: - 1. If the [=list/size=] of |newShape| is 0, set |outputShape| to the empty [=/list=] « » (reshaping to scalar). - 1. If any value in |newShape| is 0, then [=exception/throw=] a "{{DataError}}" {{DOMException}}. - 1. Let |inputElementCount| be the product of all elements in |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dimensions}}. - 1. If product of all values in |newShape| is not equal to |inputElementCount|, then [=exception/throw=] a "{{DataError}}" {{DOMException}}. + 1. If the [=list/size=] of |newShape| is 0, set |outputShape| to the empty [=/list=] « » (reshaping to scalar). + 1. If any value in |newShape| is 0, then [=exception/throw=] a "{{DataError}}" {{DOMException}}. + 1. Let |inputElementCount| be the product of all elements in |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dimensions}}. + 1. If product of all values in |newShape| is not equal to |inputElementCount|, then [=exception/throw=] a "{{DataError}}" {{DOMException}}. 1. Let |desc| be a copy of |input|.{{MLOperand/[[descriptor]]}}. 1. Set |desc|.{{MLOperandDescriptor/dimensions}} to |newShape|. 1. If any of the following sub-steps fail, [=exception/throw=] an "{{OperationError}}" {{DOMException}}. From 4ea29a9be6c024feb0af02aefaf2e56dd7a1f004 Mon Sep 17 00:00:00 2001 From: Dwayne Robinson Date: Thu, 8 Feb 2024 19:01:05 -0800 Subject: [PATCH 08/10] Unbracket MLCommandEncoder in status text to appease bikeshed --- index.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.bs b/index.bs index b1ebd9aa..f8f8267f 100644 --- a/index.bs +++ b/index.bs @@ -23,7 +23,7 @@ Logo: https://webmachinelearning.github.io/webmachinelearning-logo.png Deadline: 2023-10-01 Status Text:

Further implementation experience and user feedback is being gathered for the - {{MLCommandEncoder}} interface that proposes to enable more efficient WebGPU + MLCommandEncoder interface that proposes to enable more efficient WebGPU integration. A proposal to simplify MLContext creation is being discussed. This document is maintained and From ac9a7193859c70dba490df760c4e16ba7ef77372 Mon Sep 17 00:00:00 2001 From: Dwayne Robinson Date: Fri, 9 Feb 2024 14:34:42 -0800 Subject: [PATCH 09/10] CR feedback --- index.bs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/index.bs b/index.bs index f8f8267f..30dd53b9 100644 --- a/index.bs +++ b/index.bs @@ -1815,7 +1815,7 @@ Data truncation will occur when the specified value exceeds the range of the spe

1. Let |descriptor| be a new {{MLOperandDescriptor}}. 1. Set |descriptor|.{{MLOperandDescriptor/dataType}} to |type|. - 1. Set |descriptor|.{{MLOperandDescriptor/dimensions}} to the empty [=/list=] « ». + 1. Set |descriptor|.{{MLOperandDescriptor/dimensions}} to an empty [=/list=]. 1. If any of the following sub-steps fail, [=exception/throw=] an "{{OperationError}}" {{DOMException}}. 1. Let |operand| be the result of [=creating an MLOperand=] given [=this=] and |descriptor|. 1. Make a request to the underlying platform to: @@ -3991,10 +3991,7 @@ partial interface MLGraphBuilder {
1. Let |numDirections| be 1 if |options|.{{MLLstmOptions/direction}} is {{MLRecurrentNetworkDirection/"forward"}}, or otherwise let it be 2. -
- The shape of |input|, |weight| or |recurrentWeight| could be also checked here. -
- 1. Require the shape of each tensor to match its expected rank, or else [=exception/throw=] a "{{DataError}}" {{DOMException}}: the rank of |input|, |weight|, |recurrentWeight|, |options|.{{MLLstmOptions/initialHiddenState}}, and |options|.{{MLLstmOptions/initialCellState}} is 3; and the rank of |options|.{{MLLstmOptions/bias}}, |options|.{{MLLstmOptions/recurrentBias}}, and |options|.{{MLLstmOptions/peepholeWeight}} is 2. + 1. If the [=rank=] of |input| or |weight| or |recurrentWeight| is not 3, then [=exception/throw=] a "{{DataError}}" {{DOMException}}. 1. If |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dimensions}}[0] is not equal to |steps|, then [=exception/throw=] a "{{DataError}}" {{DOMException}}. 1. Let |batchSize| be |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dimensions}}[1]. 1. If |options|.{{MLLstmOptions/bias}} [=map/exists=]: @@ -5117,9 +5114,9 @@ partial interface MLGraphBuilder {
1. Let |outputShape| be an empty array of {{unsigned long}}. - 1. If the [=list/size=] of |newShape| is 0, set |outputShape| to the empty [=/list=] « » (reshaping to scalar). + 1. If the [=list/size=] of |newShape| is 0, set |outputShape| to an empty [=/list=] for a scalar. 1. If any value in |newShape| is 0, then [=exception/throw=] a "{{DataError}}" {{DOMException}}. - 1. Let |inputElementCount| be the product of all elements in |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dimensions}}. + 1. Let |inputElementCount| be the product of all elements in |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dimensions}}. Empty dimensions yield an |inputElementCount| of 0. 1. If product of all values in |newShape| is not equal to |inputElementCount|, then [=exception/throw=] a "{{DataError}}" {{DOMException}}. 1. Let |desc| be a copy of |input|.{{MLOperand/[[descriptor]]}}. 1. Set |desc|.{{MLOperandDescriptor/dimensions}} to |newShape|. From 6e19e571b727b0416c270c8fd6658dd693e7ab6e Mon Sep 17 00:00:00 2001 From: Dwayne Robinson Date: Fri, 9 Feb 2024 14:39:18 -0800 Subject: [PATCH 10/10] Fix empty reshape dimensions to 1, not 0 --- index.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.bs b/index.bs index 30dd53b9..3be7a34f 100644 --- a/index.bs +++ b/index.bs @@ -5116,7 +5116,7 @@ partial interface MLGraphBuilder { 1. Let |outputShape| be an empty array of {{unsigned long}}. 1. If the [=list/size=] of |newShape| is 0, set |outputShape| to an empty [=/list=] for a scalar. 1. If any value in |newShape| is 0, then [=exception/throw=] a "{{DataError}}" {{DOMException}}. - 1. Let |inputElementCount| be the product of all elements in |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dimensions}}. Empty dimensions yield an |inputElementCount| of 0. + 1. Let |inputElementCount| be the product of all elements in |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dimensions}}. Empty dimensions yield an |inputElementCount| of 1. 1. If product of all values in |newShape| is not equal to |inputElementCount|, then [=exception/throw=] a "{{DataError}}" {{DOMException}}. 1. Let |desc| be a copy of |input|.{{MLOperand/[[descriptor]]}}. 1. Set |desc|.{{MLOperandDescriptor/dimensions}} to |newShape|.