Skip to content

Commit 479ce17

Browse files
Bug fix: resample2d output size calculation algorithm and usage (webmachinelearning#520)
* Per webmachinelearning#395 make it clearer that the algorithm is working on a new descriptor (a copy of the input's) * When invoking the algorithm, pass the required input argument. * Rename algorithm from "resample output sizes" to "calculate resample output sizes" which more clearly descripts what is happening and aligns with similar algorithms in the spec, and add types.
1 parent c050f31 commit 479ce17

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

index.bs

+3-4
Original file line numberDiff line numberDiff line change
@@ -5241,10 +5241,10 @@ partial interface MLGraphBuilder {
52415241
<details open algorithm>
52425242

52435243
<summary>
5244-
To <dfn for="MLGraphBuilder">resample output sizes</dfn> given |input| and |options|, run the following steps:
5244+
To <dfn for="MLGraphBuilder">calculate resample output sizes</dfn> given {{MLOperand}} |input| and {{MLResample2dOptions}} |options|, run the following steps:
52455245
</summary>
52465246
<div class=algorithm-steps>
5247-
1. Let |desc| be an {{MLOperandDescriptor}} initialized to |input|.{{MLOperand/[[descriptor]]}}.
5247+
1. Let |desc| be a new {{MLOperandDescriptor}} initialized to |input|.{{MLOperand/[[descriptor]]}}.
52485248
1. For |index| in [=the range=] 0 to the [=list/size=] of |options|.{{MLResample2dOptions/axes}}, exclusive:
52495249
1. If |options|.{{MLResample2dOptions/sizes}} [=map/exists=], set |desc|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dimensions}}[|options|.{{MLResample2dOptions/axes}}[|index|]] to |options|.{{MLResample2dOptions/sizes}}[|index|] and return |desc|.
52505250
1. Otherwise, set |desc|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dimensions}}[|options|.{{MLResample2dOptions/axes}}[|index|]] to |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dimensions}}[|index|] multiplied by |options|.{{MLResample2dOptions/scales}}.
@@ -5260,8 +5260,7 @@ partial interface MLGraphBuilder {
52605260
<div class=algorithm-steps>
52615261
1. If the [=list/size=] of |input|.{{MLOperand/[[descriptor]]}}.{{MLOperandDescriptor/dimensions}} is not 4, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
52625262
1. If [=checking resample options=] given |options| returns false, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
5263-
1. Let |desc| be the result of [=resampling output sizes=] given |options|.
5264-
1. If that [=exception/throws=] an error, re-[=exception/throw=] the error.
5263+
1. Let |desc| be the result of [=calculating resample output sizes=] given |input| and |options|.
52655264
1. If any of the following sub-steps fail, [=exception/throw=] an "{{OperationError}}" {{DOMException}}.
52665265
1. Let |output| be the result of [=creating an MLOperand=] given [=this=] and |desc|.
52675266
1. Make a request to the underlying platform to:

0 commit comments

Comments
 (0)