Skip to content

Commit cfab815

Browse files
Bug fix: Link operator names to the MLGraphBuilder methods (#547)
For a "reshape" reference a malformed IDL link was present. The other references are linked as appropriately to the builder references rather than just being styled text or links to document sections.
1 parent f8403b7 commit cfab815

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

docs/SpecCodingConventions.md

+2
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ Example:
7070
1. If |shape| is a [=circle=], draw it at |shape|'s [=circle/origin=].
7171
```
7272

73+
* When referencing an operator in text (e.g. sigmoid, tanh, etc), link the operator name to the `MLGraphBuilder` methods for creating the corresponding `MLOperand` or `MLActivation`, e.g. `{{MLGraphBuilder/sigmoid()}}`. This provides consistent styling, and provides a thorough overview of the operator, even if the method itself isn't being discussed.
74+
7375

7476
### Formatting
7577

index.bs

+9-9
Original file line numberDiff line numberDiff line change
@@ -858,12 +858,12 @@ interface MLActivation {
858858
</div>
859859

860860
<div class="note">
861-
These activations function types are used to create other operations. One such use of this interface is for when an activation function is fused into another operation such as [[#api-mlgraphbuilder-conv2d]] or [[#api-mlgraphbuilder-batchnorm]] during a graph construction session. Such fused activation functions can provide a significant performance improvement when supported natively by the underlying implementation. This is intended as an optimization opportunity for implementers.
861+
These activations function types are used to create other operations. One such use of this interface is for when an activation function is fused into another operation such as {{MLGraphBuilder/conv2d()}} or {{MLGraphBuilder/batchNormalization()}} during a graph construction session. Such fused activation functions can provide a significant performance improvement when supported natively by the underlying implementation. This is intended as an optimization opportunity for implementers.
862862
</div>
863863

864864
### Creating {{MLActivation}} ### {#api-mlactivation-create}
865865
<div class="note">
866-
The {{MLActivation}} objects (including the ones passed as input to methods) are created by the methods of {{MLGraphBuilder}} and are identified by their name. The |options| dictionary is defined by those methods. The actual creation of the activation function e.g. a [[#api-mlgraphbuilder-sigmoid-method]] or [[#api-mlgraphbuilder-relu-method]] can then be deferred until when the rest of the graph is ready to connect with it such as during the construction of [[#api-mlgraphbuilder-conv2d]] for example.
866+
The {{MLActivation}} objects (including the ones passed as input to methods) are created by the methods of {{MLGraphBuilder}} and are identified by their name. The |options| dictionary is defined by those methods. The actual creation of the activation function e.g. a {{MLGraphBuilder/sigmoid()}} or {{MLGraphBuilder/relu()}} can then be deferred until when the rest of the graph is ready to connect with it such as during the construction of {{MLGraphBuilder/conv2d()}} for example.
867867
</div>
868868

869869
<details open algorithm>
@@ -1333,7 +1333,7 @@ partial interface MLGraphBuilder {
13331333
<div class="note">
13341334
<details open>
13351335
<summary>
1336-
The behavior of this operation when the input tensor is 4-D of the {{MLInputOperandLayout/"nchw"}} layout and the activation is of operator type *relu* can be generically emulated from the usage of other operations as follow. However, user agents typically have a more efficient implementation for it, therefore its usage is encouraged from the performance standpoint.
1336+
The behavior of this operation when the input tensor is 4-D of the {{MLInputOperandLayout/"nchw"}} layout and the activation is {{MLGraphBuilder/relu()}} can be generically emulated from the usage of other operations as follow. However, user agents typically have a more efficient implementation for it, therefore its usage is encouraged from the performance standpoint.
13371337
</summary>
13381338
<pre highlight="js">
13391339
const shape = [1,null,1,1];
@@ -2170,7 +2170,7 @@ partial interface MLGraphBuilder {
21702170
</div>
21712171

21722172
<div class="note">
2173-
Although operations *greaterOrEqual* and *lesserOrEqual* can each be implemented in terms of operations *not*, *lesser*, and *greater* in other words `greater-or-equal(a, b)` is `not(lesser(a, b))`, they are specifically defined to handle NaN cases and for performance reason to avoid double comparisons.
2173+
Although operations {{MLGraphBuilder/greaterOrEqual()}} and {{MLGraphBuilder/lesserOrEqual()}} can each be implemented in terms of operations {{MLGraphBuilder/not()}}, {{MLGraphBuilder/lesser()}}, and {{MLGraphBuilder/greater()}} in other words `builder.greaterOrEqual(a, b)` is `builder.not(builder.lesser(a, b))`, they are specifically defined to handle NaN cases and for performance reason to avoid double comparisons.
21742174
</div>
21752175

21762176
<details open algorithm>
@@ -3028,7 +3028,7 @@ partial interface MLGraphBuilder {
30283028
<div class="note">
30293029
<details open>
30303030
<summary>
3031-
The behavior of this operation can be generically emulated via other operations as shown below, when the weight layout is the default {{MLGruWeightLayout/"zrn"}} layout, and the activation functions of the update/reset gate and new gate are of the operator types *sigmoid* and *tanh* respectively.
3031+
The behavior of this operation can be generically emulated via other operations as shown below, when the weight layout is the default {{MLGruWeightLayout/"zrn"}} layout, and the activation functions of the update/reset gate and new gate are {{MLGraphBuilder/sigmoid()}} and {{MLGraphBuilder/tanh()}} respectively.
30323032
</summary>
30333033
<pre highlight="js">
30343034
const one = builder.constant(1);
@@ -3334,7 +3334,7 @@ Create a named {{MLOperand}} based on a descriptor, that can be used as an input
33343334
</details>
33353335

33363336
### instanceNormalization ### {#api-mlgraphbuilder-instancenorm}
3337-
Normalize the input using [[Instance-Normalization]]. Unlike [[#api-mlgraphbuilder-batchnorm]] where the mean and variance values used in the normalization are computed across all the samples in the batch dimension while the model is trained, the mean and variance values used in the instance normalization are computed on the fly for each input feature of each individual sample in the batch.
3337+
Normalize the input using [[Instance-Normalization]]. Unlike {{MLGraphBuilder/batchNormalization()}} where the mean and variance values used in the normalization are computed across all the samples in the batch dimension while the model is trained, the mean and variance values used in the instance normalization are computed on the fly for each input feature of each individual sample in the batch.
33383338

33393339
<script type=idl>
33403340
dictionary MLInstanceNormalizationOptions {
@@ -3436,7 +3436,7 @@ partial interface MLGraphBuilder {
34363436
</div>
34373437

34383438
### layerNormalization ### {#api-mlgraphbuilder-layernorm}
3439-
Normalize the input using [[Layer-Normalization]]. Unlike [[#api-mlgraphbuilder-batchnorm]] where the mean and variance values are computed across all the samples in the batch dimension while the model is trained, and in [[#api-mlgraphbuilder-instancenorm]] where the mean and variance values are computed on the fly for each input feature of each individual sample in the batch, the means and variance values of the layer normalization are computed on the fly across all the input features of each individual sample in the batch.
3439+
Normalize the input using [[Layer-Normalization]]. Unlike {{MLGraphBuilder/batchNormalization()}} where the mean and variance values are computed across all the samples in the batch dimension while the model is trained, and in {{MLGraphBuilder/instanceNormalization()}} where the mean and variance values are computed on the fly for each input feature of each individual sample in the batch, the means and variance values of the layer normalization are computed on the fly across all the input features of each individual sample in the batch.
34403440

34413441
<script type=idl>
34423442
dictionary MLLayerNormalizationOptions {
@@ -4031,7 +4031,7 @@ partial interface MLGraphBuilder {
40314031
<div class="note">
40324032
<details open>
40334033
<summary>
4034-
The behavior of this operation can be generically emulated via other operations as shown below, when the weight layout is the default {{MLLstmWeightLayout/"iofg"}} layout, and the activation functions of the input/forget/output gate and the cell gate/the cell state's filter for the output hidden state are of the operator types *sigmoid* and *tanh* respectively.
4034+
The behavior of this operation can be generically emulated via other operations as shown below, when the weight layout is the default {{MLLstmWeightLayout/"iofg"}} layout, and the activation functions of the input/forget/output gate and the cell gate/the cell state's filter for the output hidden state are {{MLGraphBuilder/sigmoid()}} and {{MLGraphBuilder/tanh()}} respectively.
40354035
</summary>
40364036
<pre highlight="js">
40374037
const zero = builder.constant(0);
@@ -4948,7 +4948,7 @@ partial interface MLGraphBuilder {
49484948
<div class="note">
49494949
<details open>
49504950
<summary>
4951-
Many shape-related operations such as [squeeze](https://pytorch.org/docs/stable/generated/torch.squeeze.html), [unsqueeze](https://pytorch.org/docs/stable/generated/torch.unsqueeze.html), and [flatten](https://pytorch.org/docs/stable/generated/torch.flatten.html) can be generically implemented using the *reshape*}} operation as follows:
4951+
Many shape-related operations such as [squeeze](https://pytorch.org/docs/stable/generated/torch.squeeze.html), [unsqueeze](https://pytorch.org/docs/stable/generated/torch.unsqueeze.html), and [flatten](https://pytorch.org/docs/stable/generated/torch.flatten.html) can be generically implemented using the {{MLGraphBuilder/reshape()}} operation as follows:
49524952
</summary>
49534953
<pre highlight="js">
49544954
// Returns a tensor with all specified dimensions of input of size 1 removed.

0 commit comments

Comments
 (0)