You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bug fix: Fix MLGraphBuilder.input()'s handling of scalars (#575)
* Bug fix: Fix MLGraphBuilder.input()'s handling of scalars. Fixes#502
MLOperandDescriptor was updated in c320472 to always have dimensions,
defaulted to an empty list for scalars. That makes the current prose
for input() incorrect. Issue #502 already tracked correcting it, so
let's simplify - just change the logic for "is a scalar?" and drop the
bogus assert.
* Remove conditional and fix check dimensions to allow 0
* Factor byte length check into checking dimensions
* Oops, this should go too.
* type -> dataType
* (1) simplify (2) move into MLOperandDescriptor (3) link to #456
* Restore dimension check and reorder byte length to last
* Fix build for missing dimensions
---------
Co-authored-by: Dwayne Robinson <[email protected]>
Copy file name to clipboardexpand all lines: index.bs
+21-19
Original file line number
Diff line number
Diff line change
@@ -1604,8 +1604,7 @@ Create a constant {{MLOperand}} of the specified data type and shape that contai
1604
1604
<div class="note">
1605
1605
The permissions and context validity have been checked by [[#api-mlgraphbuilder-constructor]] steps.
1606
1606
</div>
1607
-
1. If |descriptor|'s [=byte length=] is not supported by the underlying platform, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
1608
-
1. If the [=checking dimensions=] given |descriptor|.{{MLOperandDescriptor/dataType}} and |descriptor|.{{MLOperandDescriptor/dimensions}} returns false, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
1607
+
1. If [=checking dimensions=] given |descriptor| returns false, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
1609
1608
1. If [=validating buffer with descriptor=] given |bufferView| and |descriptor| returns false, then [=exception/throw=] a {{TypeError}}.
1610
1609
1. If any of the following sub-steps fail, [=exception/throw=] an "{{OperationError}}" {{DOMException}}.
1611
1610
1. Let |operand| be the result of [=creating an MLOperand=] given [=this=] and |descriptor|.
@@ -3318,10 +3317,7 @@ Create a named {{MLOperand}} based on a descriptor, that can be used as an input
3318
3317
The permissions and context validity have been checked by [[#api-mlgraphbuilder-constructor]] steps.
3319
3318
</div>
3320
3319
1. If |name| is empty, then [=exception/throw=] a {{TypeError}}.
3321
-
1. [=Assert=]: If |descriptor|.{{MLOperandDescriptor/dimensions}} does not [=map/exist=], then |descriptor| defines a scalar input.
3322
-
1. If |descriptor|.{{MLOperandDescriptor/dimensions}}[=map/exists=]:
3323
-
1. If [=checking dimensions=] given |descriptor|.{{MLOperandDescriptor/dataType}} and |descriptor|.{{MLOperandDescriptor/dimensions}} returns false, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
3324
-
1. If |descriptor|'s [=byte length=] is not supported by the underlying platform, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
3320
+
1. If [=checking dimensions=] given |descriptor| returns false, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
3325
3321
1. If any of the following sub-steps fail, [=exception/throw=] an "{{OperationError}}" {{DOMException}}.
3326
3322
1. Let |operand| be the result of [=creating an MLOperand=] given [=this=] and |descriptor|.
3327
3323
1. Set |operand|.{{MLOperand/[[name]]}} to |name|.
@@ -5781,26 +5777,14 @@ The {{MLOperand}} objects are created by the methods of {{MLGraphBuilder}}, inte
5781
5777
</div>
5782
5778
</details>
5783
5779
5784
-
<details open algorithm>
5785
-
<summary>
5786
-
To <dfn>check dimensions</dfn> given [=/list=] |dimensions| and {{MLOperandDataType}} |type|, run the following steps:
5787
-
</summary>
5788
-
<div class=algorithm-steps>
5789
-
1. If |dimensions|'s [=list/size=] is 0, return false.
5790
-
1. If |dimensions|'s [=list/size=] is too large to be supported by the implementation, return false.
5791
-
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.
5792
-
1. Return true.
5793
-
</div>
5794
-
</details>
5795
-
5796
5780
<details open algorithm>
5797
5781
<summary>
5798
5782
To <dfn for="MLOperand">validate MLOperand</dfn> given {{MLOperand}} |operand| and {{MLGraphBuilder}} |builder|, run the following steps:
5799
5783
</summary>
5800
5784
<div class=algorithm-steps>
5801
5785
1. If |builder| is not equal to |operand|.{{MLOperand/[[builder]]}}, return false.
5802
5786
1. Let |desc| be |operand|.{{MLOperand/[[descriptor]]}}.
5803
-
1. If [=checking dimensions=] given |desc|.{{MLOperandDescriptor/dimensions}} and |desc|.{{MLOperandDescriptor/dataType}} returns false, then return false.
5787
+
1. If [=checking dimensions=] given |desc| returns false, then return false.
0 commit comments