Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dimensions for 0D scalars #476

Merged
merged 12 commits into from
Feb 13, 2024
7 changes: 3 additions & 4 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,6 @@ The {{MLOperand}} objects are created by the methods of {{MLGraphBuilder}}, inte
To <dfn>check dimensions</dfn> given |dimensions| and |type|, run the following steps:
</summary>
<div class=algorithm-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.
Expand Down Expand Up @@ -1611,7 +1610,7 @@ Create a named {{MLOperand}} based on a descriptor, that can be used as an input
</div>
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.
fdwr marked this conversation as resolved.
Show resolved Hide resolved
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}}.
Expand Down Expand Up @@ -4863,9 +4862,9 @@ partial interface MLGraphBuilder {
<div class=algorithm-steps>
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 `«»`.
fdwr marked this conversation as resolved.
Show resolved Hide resolved
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}}.
Expand Down