Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
inexorabletash committed Apr 26, 2024
1 parent ad239bc commit 48b240b
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,8 @@ An {{MLOperand}}'s <dfn for=MLOperand>dataType</dfn> is its {{MLOperand/[[descri

Since the {{MLOperand/[[builder]]}} object is bound by the {{MLGraphBuilder/constructor()}} constructor to an {{MLContext}} object, an {{MLOperand}} is also always bound to the same {{MLContext}} object.

If an operation supports only a subset of {{MLOperandDataType}}s, the <dfn>allowed data types</dfn> for each operation's input operands, including both positional arguments and options, are given as either an explicit list of {{MLOperandDataType}}s, or a constraint that the operand's [=MLOperand/dataType=] must be the <dfn lt="same as">same type as</dfn> the [=MLOperand/dataType=] of another input operand.

### Creating an {{MLOperand}} ### {#api-mloperand-create}
The {{MLOperand}} objects are created by the methods of {{MLGraphBuilder}}, internally using the following algorithms.

Expand Down Expand Up @@ -1551,6 +1553,27 @@ partial interface MLGraphBuilder {
- *options*: an optional {{MLBatchNormalizationOptions}}. Specifies the optional parameters of the operation.

**Returns:** an {{MLOperand}}. The batch-normalized N-D tensor of the same shape as *input*.

<b>[=allowed data types|Types=]:</b>
<div link-for="MLGraphBuilder/batchNormalization(input, mean, variance, options)">
- {{input}}: {{MLOperandDataType/"float32"}}, {{MLOperandDataType/"float16"}}
- {{mean}}: [=/same as=] {{input}}
- {{variance}}: [=/same as=] {{input}}
- {{MLBatchNormalizationOptions/scale}}: [=/same as=] {{input}}
- {{MLBatchNormalizationOptions/bias}}: [=/same as=] {{input}}
</div>
</div>

Another option for presentation, just throwing it out there:

<div link-for="MLGraphBuilder/batchNormalization(input, mean, variance, options)">
<pre class=simpledef>
{{input}}: {{MLOperandDataType/"float32"}}, {{MLOperandDataType/"float16"}}
{{mean}}: [=/same as=] {{input}}
{{variance}}: [=/same as=] {{input}}
{{MLBatchNormalizationOptions/scale}}: [=/same as=] {{input}}
{{MLBatchNormalizationOptions/bias}}: [=/same as=] {{input}}
</pre>
</div>

<details open algorithm>
Expand All @@ -1559,20 +1582,20 @@ partial interface MLGraphBuilder {
</summary>
1. If [=MLGraphBuilder/validating operand=] with [=this=] and any of |input|, |mean|, |variance|, |options|.{{MLBatchNormalizationOptions/scale}} (if it [=map/exists=]), and |options|.{{MLBatchNormalizationOptions/bias}} (if it [=map/exists=]) returns false, then [=exception/throw=] a {{TypeError}}.
1. If |options|.{{MLBatchNormalizationOptions/activation}} [=map/exists=], and [=MLGraphBuilder/validating activation=] with [=this=] and it returns false, then [=exception/throw=] a {{TypeError}}.
1. If |input|'s [=MLOperand/dataType=] is not {{MLOperandDataType/"float32"}} or {{MLOperandDataType/"float16"}}, then [=exception/throw=] a {{TypeError}}.
1. If |input|'s [=MLOperand/dataType=] is not one of its [=allowed data types=], then [=exception/throw=] a {{TypeError}}.
1. If |options|.{{MLBatchNormalizationOptions/axis}} is not in [=the range=] 0 to |input|'s [=MLOperand/rank=], exclusive, then [=exception/throw=] a {{TypeError}}.
1. If |mean|'s [=MLOperand/dataType=] is not equal to |input|'s [=MLOperand/dataType=], then [=exception/throw=] a {{TypeError}}.
1. If |mean|'s [=MLOperand/dataType=] is not one of its [=allowed data types=], then [=exception/throw=] a {{TypeError}}.
1. If |mean|'s [=MLOperand/rank=] is not 1, then [=exception/throw=] a {{TypeError}}.
1. If |mean|'s [=MLOperand/shape=][0] is not equal to |input|'s [=MLOperand/shape=][|options|.{{MLBatchNormalizationOptions/axis}}], then [=exception/throw=] a {{TypeError}}.
1. If |variance|'s [=MLOperand/dataType=] is not equal to |input|'s [=MLOperand/dataType=], then [=exception/throw=] a {{TypeError}}.
1. If |variance|'s [=MLOperand/dataType=] is not one of its [=allowed data types=], then [=exception/throw=] a {{TypeError}}.
1. If |variance|'s [=MLOperand/rank=] is not 1, then [=exception/throw=] a {{TypeError}}.
1. If |variance|'s [=MLOperand/shape=][0] is not equal to |input|'s [=MLOperand/shape=][|options|.{{MLBatchNormalizationOptions/axis}}], then [=exception/throw=] a {{TypeError}}.
1. If |options|.{{MLBatchNormalizationOptions/scale}} [=map/exists=]:
1. If its [=MLOperand/dataType=] is not equal to |input|'s [=MLOperand/dataType=], then [=exception/throw=] a {{TypeError}}.
1. If its [=MLOperand/dataType=] is not one of its [=allowed data types=], then [=exception/throw=] a {{TypeError}}.
1. If its [=MLOperand/rank=] is not 1, then [=exception/throw=] a {{TypeError}}.
1. If its [=MLOperand/shape=][0] is not equal to |input|'s [=MLOperand/shape=][|options|.{{MLBatchNormalizationOptions/axis}}], then [=exception/throw=] a {{TypeError}}.
1. If |options|.{{MLBatchNormalizationOptions/bias}} [=map/exists=]:
1. If its [=MLOperand/dataType=] is not equal to |input|'s [=MLOperand/dataType=], then [=exception/throw=] a {{TypeError}}.
1. If its [=MLOperand/dataType=] is not one of its [=allowed data types=], then [=exception/throw=] a {{TypeError}}.
1. If its [=MLOperand/rank=] is not 1, then [=exception/throw=] a {{TypeError}}.
1. If its [=MLOperand/shape=][0] is not equal to |input|'s [=MLOperand/shape=][|options|.{{MLBatchNormalizationOptions/axis}}], then [=exception/throw=] a {{TypeError}}.
1. If |options|.{{MLBatchNormalizationOptions/activation}} [=map/exists=], and running its [=MLActivation/validation steps=]] with |input|.{{MLOperand/[[descriptor]]}} returns false, then [=exception/throw=] a {{TypeError}}.
Expand Down

0 comments on commit 48b240b

Please sign in to comment.