From dbb9d1cfdf805d00e701b8e118e7e7a5e83358fb Mon Sep 17 00:00:00 2001 From: Joshua Bell Date: Fri, 12 Jul 2024 16:20:44 -0700 Subject: [PATCH] Style: Link method argument definitions (#721) * Style: Link method argument definitions Also adds a lint rule to enforce that every argument given in IDL is linked to a prose definition for it, and a lint rule to look for argument definitions that don't match their methods. Fixes #574 * Fix merge glitches * Tweak wording --- index.bs | 375 ++++++++++++++++++++++++++----------------------- tools/lint.mjs | 15 ++ 2 files changed, 214 insertions(+), 176 deletions(-) diff --git a/index.bs b/index.bs index ffbef50c..8230e000 100644 --- a/index.bs +++ b/index.bs @@ -70,6 +70,11 @@ p, ul, ol, dl { margin: 1em 0; } +/* Override rule making smaller than surrounding text. */ +dfn code { + font-size: 100%; +} + /* Style
, for clarity of presentation of these blocks. */ details { padding: .5em; @@ -753,6 +758,13 @@ The powerPreference opt ### {{ML/createContext()}} ### {#api-ml-createcontext} +
+ **Arguments:** + - options: an {{MLContextOptions}}. Provides the application's preferences for the context. + - gpuDevice: a {{GPUDevice}}. A specific device to use with the context. + **Returns:** an {{MLContext}}. +
+
To create a context given [=realm=] |realm| and |options| (a {{GPUDevice}} or {{MLContextOptions}}), run these steps: @@ -905,11 +917,11 @@ Asynchronously carries out the computational workload of a compiled graph {{MLGr In accordance with the [=ArrayBufferView/write|Web IDL warning=], to prevent the calling thread from modifying the input and output resources while the computation is ongoing, this method [=MLNamedArrayBufferViews/transfer|transfers=] the input and output {{MLNamedArrayBufferViews}} to new views that share the same backing memory allocations. The transferred views are returned to the caller via the promise fulfillment with the computation result written into the backing memory of the output views. -
+
**Arguments:** - - *graph*: an {{MLGraph}}. The compiled graph to be executed. - - *inputs*: an {{MLNamedArrayBufferViews}}. The resources of inputs. Will be [=MLNamedArrayBufferViews/transfer|transferred=] if there are no validation errors. - - *outputs*: an {{MLNamedArrayBufferViews}}. The pre-allocated resources of required outputs. Will be [=MLNamedArrayBufferViews/transfer|transferred=] if there are no validation errors. + - graph: an {{MLGraph}}. The compiled graph to be executed. + - inputs: an {{MLNamedArrayBufferViews}}. The resources of inputs. Will be [=MLNamedArrayBufferViews/transfer|transferred=] if there are no validation errors. + - outputs: an {{MLNamedArrayBufferViews}}. The pre-allocated resources of required outputs. Will be [=MLNamedArrayBufferViews/transfer|transferred=] if there are no validation errors. **Returns:** Promise<{{MLComputeResult}}>.
@@ -1282,6 +1294,11 @@ The {{MLGraphBuilder}}.{{MLGraphBuilder/build()}} method compiles the graph buil ### {{MLGraphBuilder}} constructor ### {#api-mlgraphbuilder-constructor} +
+ **Arguments:** + - context: an {{MLContext}}. The context to associate with the {{MLGraphBuilder}}. +
+
The [=new=] MLGraphBuilder(|context|) constructor steps are: @@ -1294,10 +1311,10 @@ The {{MLGraphBuilder}}.{{MLGraphBuilder/build()}} method compiles the graph buil Create a named {{MLOperand}} based on a descriptor, that can be used as an input. -
+
**Arguments:** - - *name*: a [=string=] name of the input. - - *descriptor*: an {{MLOperandDescriptor}} object. + - name: a [=string=] name of the input. + - descriptor: an {{MLOperandDescriptor}} object. **Returns:** an {{MLOperand}} object.
@@ -1324,10 +1341,10 @@ Create a constant {{MLOperand}} that can be used in {{MLGraphBuilder}} methods. #### {{MLGraphBuilder/constant(descriptor, bufferView)}} #### {#api-mlgraphbuilder-constant-bufferview} Create a constant {{MLOperand}} of the specified data type and shape that contains the initializing data. -
+
**Arguments:** - - *descriptor*: an {{MLOperandDescriptor}}. The descriptor of the output tensor. - - *bufferView*: an {{ArrayBufferView}}. The view of the buffer containing the initializing data. + - descriptor: an {{MLOperandDescriptor}}. The descriptor of the output tensor. + - bufferView: an {{ArrayBufferView}}. The view of the buffer containing the initializing data. **Returns:** an {{MLOperand}}. The constant output tensor.
@@ -1351,10 +1368,10 @@ Create a scalar constant {{MLOperand}} of the specified value and data type. Data truncation will occur when the specified value exceeds the range of the specified output data type e.g. when a floating point value is assigned to an {{MLOperandDataType/"int8"}} data type, etc.
-
+
**Arguments:** - - *type*: an {{MLOperandDataType}}. - - *value*: an {{MLNumber}}. The value of the constant. + - type: an {{MLOperandDataType}}. + - value: an {{MLNumber}}. The value of the constant. **Returns:** an {{MLOperand}}. The constant output.
@@ -1375,6 +1392,12 @@ Data truncation will occur when the specified value exceeds the range of the spe ### build method ### {#api-mlgraphbuilder-build} Build a composed graph up to a given output operand into a computational graph asynchronously. +
+ **Arguments:** + - outputs: an {{MLNamedOperands}}. Identifies the {{MLOperand}}s that will be the outputs of the graph. + **Returns:** Promise<{{MLGraph}}>. +
+
The build(|outputs|) method steps are: @@ -1447,10 +1470,10 @@ partial interface MLGraphBuilder { If true, retains reduced dimensions with [=list/size=] 1. -
+
**Arguments:** - - *input*: an {{MLOperand}}. The input N-D tensor. - - *options*: an optional {{MLArgMinMaxOptions}}. The optional parameters of the operation. + - input: an {{MLOperand}}. The input N-D tensor. + - options: an optional {{MLArgMinMaxOptions}}. The optional parameters of the operation. **Returns:** an {{MLOperand}}. The N-D tensor of the reduced shape. The values must be of type {{MLOperandDataType/"int64"}} in the range [0, N-1] where N is the corresponding size of each of the input dimensions specified by options.axes.
@@ -1529,12 +1552,12 @@ partial interface MLGraphBuilder { A small value to prevent computational error due to divide-by-zero. -
+
**Arguments:** - - *input*: an {{MLOperand}}. The input N-D tensor. - - *mean*: an {{MLOperand}}. Specifies the 1-D tensor of the mean values of the input features across the batch. Its [=list/size=] is equal to the size of the input dimension denoted by {{MLBatchNormalizationOptions/axis}}. - - *variance*: an {{MLOperand}}. The 1-D tensor of the variance values of the input features across the batch whose [=list/size=] is equal to the size of the input dimension denoted by {{MLBatchNormalizationOptions/axis}}. - - *options*: an optional {{MLBatchNormalizationOptions}}. Specifies the optional parameters of the operation. + - input: an {{MLOperand}}. The input N-D tensor. + - mean: an {{MLOperand}}. Specifies the 1-D tensor of the mean values of the input features across the batch. Its [=list/size=] is equal to the size of the input dimension denoted by {{MLBatchNormalizationOptions/axis}}. + - variance: an {{MLOperand}}. The 1-D tensor of the variance values of the input features across the batch whose [=list/size=] is equal to the size of the input dimension denoted by {{MLBatchNormalizationOptions/axis}}. + - 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*.
@@ -1598,10 +1621,10 @@ partial interface MLGraphBuilder { MLOperand cast(MLOperand input, MLOperandDataType type); }; -
+
**Arguments:** - - *input*: an {{MLOperand}}. The input N-D tensor. - - *type*: an {{MLOperandDataType}}. The target data type. + - input: an {{MLOperand}}. The input N-D tensor. + - type: an {{MLOperandDataType}}. The target data type. **Returns:** an {{MLOperand}}. The N-D tensor of the same shape as *input* with each element casted to the target data type.
@@ -1642,10 +1665,10 @@ partial interface MLGraphBuilder { :: The maximum value of the range. When it is not specified, the clamping is not performed on the upper limit of the range. -
+
**Arguments:** - - *input*: an {{MLOperand}}. The input tensor. - - *options*: an optional {{MLClampOptions}}. The optional parameters of the operation. + - input: an {{MLOperand}}. The input tensor. + - options: an optional {{MLClampOptions}}. The optional parameters of the operation. **Returns:** - an {{MLOperand}}. The output tensor of the same shape as *operand*.
@@ -1706,11 +1729,11 @@ partial interface MLGraphBuilder { MLOperand concat(sequence inputs, [EnforceRange] unsigned long axis); }; -
+
**Arguments:** - - *inputs*: a sequence of {{MLOperand}}. All input tensors must have the + - inputs: a sequence of {{MLOperand}}. All input tensors must have the same shape, except for the size of the dimension to concatenate on. - - *axis*: an {{unsigned long}} scalar. The axis that the inputs concatenate along. Its value must be in the range [0, N-1] where N is the [=MLOperand/rank=] of the input tensors. + - axis: an {{unsigned long}} scalar. The axis that the inputs concatenate along. Its value must be in the range [0, N-1] where N is the [=MLOperand/rank=] of the input tensors. **Returns:** an {{MLOperand}}. The concatenated tensor of all the inputs along the *axis*. The output tensor has the same shape except on the dimension @@ -1825,13 +1848,13 @@ partial interface MLGraphBuilder { An additional 1-D tensor with the shape of *[outputChannels]* whose values are to be added to the convolution result. -
+
**Arguments:** - - *input*: an {{MLOperand}}. The input 4-D tensor. The logical shape + - input: an {{MLOperand}}. The input 4-D tensor. The logical shape is interpreted according to the value of *options*.{{MLConv2dOptions/inputLayout}}. - - *filter*: an {{MLOperand}}. The filter 4-D tensor. The logical shape is + - filter: an {{MLOperand}}. The filter 4-D tensor. The logical shape is interpreted according to the value of *options*.{{MLConv2dOptions/filterLayout}} and *options*.{{MLConv2dOptions/groups}}. - - *options*: an {{MLConv2dOptions}}. The optional parameters of the operation. + - options: an {{MLConv2dOptions}}. The optional parameters of the operation. **Returns:** an {{MLOperand}}. The output 4-D tensor that contains the convolution result. The output shape is interpreted according to the *options*.{{MLConv2dOptions/inputLayout}} value. More specifically, the spatial dimensions or the sizes of the last two dimensions of the output tensor for the *nchw* input layout can be calculated as follows: @@ -2040,13 +2063,13 @@ partial interface MLGraphBuilder { An additional 1-D tensor with the shape of *[outputChannels]* whose values are to be added to the convolution result. -
+
**Arguments:** - - *input*: an {{MLOperand}}. The input 4-D tensor. The logical shape + - input: an {{MLOperand}}. The input 4-D tensor. The logical shape is interpreted according to the value of *options*.{{MLConvTranspose2dOptions/inputLayout}}. - - *filter*: an {{MLOperand}}. The filter 4-D tensor. The logical shape is + - filter: an {{MLOperand}}. The filter 4-D tensor. The logical shape is interpreted according to the value of *options*.{{MLConvTranspose2dOptions/filterLayout}} and {{MLConvTranspose2dOptions/groups}}. - - *options*: an optional {{MLConvTranspose2dOptions}}. + - options: an optional {{MLConvTranspose2dOptions}}. **Returns:** an {{MLOperand}}. The output 4-D tensor that contains the transposed convolution result. The output shape is interpreted according to the *options*.{{MLConvTranspose2dOptions/inputLayout}} value. More specifically, unless the *options*.{{MLConvTranspose2dOptions/outputSizes}} values are explicitly specified, the *options*.{{MLConvTranspose2dOptions/outputPadding}} may be needed to compute the spatial dimension values of the output tensor as follows: @@ -2182,10 +2205,10 @@ partial interface MLGraphBuilder { }; -
+
**Arguments:** - - *a*: an {{MLOperand}}. The first input tensor. - - *b*: an {{MLOperand}}. The second input tensor. + - a: an {{MLOperand}}. The first input tensor. + - b: an {{MLOperand}}. The second input tensor. **Returns:** an {{MLOperand}}. The output tensor that contains the result of element-wise binary operation of the two input tensors. @@ -2292,10 +2315,10 @@ partial interface MLGraphBuilder { }; -
+
**Arguments:** - - *a*: an {{MLOperand}}. The first input tensor. - - *b*: an {{MLOperand}}. The second input tensor when specified. + - a: an {{MLOperand}}. The first input tensor. + - b: an {{MLOperand}}. The second input tensor when specified. **Returns:** an {{MLOperand}}. The output tensor that contains the result of element-wise comparison of the two input tensors.
@@ -2405,9 +2428,9 @@ partial interface MLGraphBuilder { }; -
+
**Arguments:** - - *input*: an {{MLOperand}}. The input tensor. + - input: an {{MLOperand}}. The input tensor. **Returns:** an {{MLOperand}}. The output tensor that contains the result of element-wise unary operation of the input tensor. The shape of the output @@ -2565,10 +2588,10 @@ partial interface MLGraphBuilder { #### {{MLGraphBuilder/elu(input, options)}} #### {#api-mlgraphbuilder-elu-input-options} -
+
**Arguments:** - - *input*: an {{MLOperand}}. The input tensor. - - *options*: an optional {{MLEluOptions}}. The optional parameters of the operation. + - input: an {{MLOperand}}. The input tensor. + - options: an optional {{MLEluOptions}}. The optional parameters of the operation. **Returns:** - an {{MLOperand}}. The output tensor of the same shape as *input*. @@ -2610,9 +2633,9 @@ partial interface MLGraphBuilder {
#### {{MLGraphBuilder/elu(options)}} #### {#api-mlgraphbuilder-elu-options} -
+
**Arguments:** - - *options*: an optional {{MLEluOptions}}. The optional parameters of the operation. + - options: an optional {{MLEluOptions}}. The optional parameters of the operation. **Returns:** - an {{MLActivation}}. The activation function representing the elu operation. @@ -2636,10 +2659,10 @@ partial interface MLGraphBuilder { MLOperand expand(MLOperand input, sequence<[EnforceRange] unsigned long> newShape); }; -
+
**Arguments:** - - *input*: an {{MLOperand}}. An input tensor - - *newShape*: a sequence of {{unsigned long}}. The new shape the input tensor is expanded to. + - input: an {{MLOperand}}. An input tensor + - newShape: a sequence of {{unsigned long}}. The new shape the input tensor is expanded to. **Returns:** an {{MLOperand}}. The tensor with expanded size dimensions.
@@ -2683,11 +2706,11 @@ partial interface MLGraphBuilder { The axis along which the gathered values are obtained. Its value must be in the range [0, N-1] where N is the [=MLOperand/rank=] of the input tensor. -
+
**Arguments:** - - *input*: an {{MLOperand}}. The input N-D tensor from which the values are gathered. - - *indices*: an {{MLOperand}}. The indices N-D tensor of the input values to gather. The values must be of type {{MLOperandDataType/"int32"}}, {{MLOperandDataType/"uint32"}} or {{MLOperandDataType/"int64"}}, and must be in the range -N (inclusive) to N (exclusive) where N is the size of the input dimension indexed by *options.axis*, and a negative index means indexing from the end of the dimension. - - *options*: an optional {{MLGatherOptions}}. The optional parameters of the operation. + - input: an {{MLOperand}}. The input N-D tensor from which the values are gathered. + - indices: an {{MLOperand}}. The indices N-D tensor of the input values to gather. The values must be of type {{MLOperandDataType/"int32"}}, {{MLOperandDataType/"uint32"}} or {{MLOperandDataType/"int64"}}, and must be in the range -N (inclusive) to N (exclusive) where N is the size of the input dimension indexed by *options.axis*, and a negative index means indexing from the end of the dimension. + - options: an optional {{MLGatherOptions}}. The optional parameters of the operation. **Returns:** an {{MLOperand}}. The output N-D tensor of [=MLOperand/rank=] equal to the [=MLOperand/rank=] of *input* + the [=MLOperand/rank=] of *indices* - 1.
@@ -2803,9 +2826,9 @@ partial interface MLGraphBuilder { #### {{MLGraphBuilder/gelu(input)}} #### {#api-mlgraphbuilder-gelu-input} -
+
**Arguments:** - - *input*: an {{MLOperand}}. The input tensor. + - input: an {{MLOperand}}. The input tensor. **Returns:** - an {{MLOperand}}. The output tensor of the same shape as *input*. @@ -2901,11 +2924,11 @@ partial interface MLGraphBuilder { Indicates if the second input should be transposed prior to calculating the output. -
+
**Arguments:** - - *a*: an {{MLOperand}}. The first input 2-D tensor with shape *[M, K]* if *aTranspose* is false, or *[K, M]* if *aTranspose* is true. - - *b*: an {{MLOperand}}. The second input 2-D tensor with shape *[K, N]* if *bTranspose* is false, or *[N, K]* if *bTranspose* is true. - - *options*: an optional {{MLGemmOptions}}. The optional parameters of the operation. + - a: an {{MLOperand}}. The first input 2-D tensor with shape *[M, K]* if *aTranspose* is false, or *[K, M]* if *aTranspose* is true. + - b: an {{MLOperand}}. The second input 2-D tensor with shape *[K, N]* if *bTranspose* is false, or *[N, K]* if *bTranspose* is true. + - options: an optional {{MLGemmOptions}}. The optional parameters of the operation. **Returns:** an {{MLOperand}}. The output 2-D tensor of shape *[M, N]* that contains the calculated product of all the inputs.
@@ -3038,14 +3061,14 @@ partial interface MLGraphBuilder { Specifies a pair of activation functions with the first function used for the update and reset gate, and the second used for the new gate. When not specified, implementations SHOULD use the pair of sigmoid ("sigmoid") and the hyperbolic tangent ("tanh") functions, respectively. -
+
**Arguments:** - - *input*: an {{MLOperand}}. The input 3-D tensor of shape *[steps, batchSize, inputSize]*. - - *weight*: an {{MLOperand}}. The 3-D input weight tensor of shape *[numDirections, 3 * hiddenSize, inputSize]*. The ordering of the weight vectors in the second dimension of the tensor shape is specified according to the |options|.{{MLGruOptions/layout}} argument. - - *recurrentWeight*: an {{MLOperand}}. The 3-D recurrent weight tensor of shape *[numDirections, 3 * hiddenSize, hiddenSize]*. The ordering of the weight vectors in the second dimension of the tensor shape is specified according to the |options|.{{MLGruOptions/layout}} argument. - - *steps*: an {{unsigned long}} scalar. The number of time steps in the recurrent network. The value must be greater than 0. - - *hiddenSize*: an {{unsigned long}} scalar. The value of the third dimension of the cell output tensor shape. It indicates the number of features in the hidden state. - - *options*: an optional {{MLGruOptions}}. The optional parameters of the operation. + - input: an {{MLOperand}}. The input 3-D tensor of shape *[steps, batchSize, inputSize]*. + - weight: an {{MLOperand}}. The 3-D input weight tensor of shape *[numDirections, 3 * hiddenSize, inputSize]*. The ordering of the weight vectors in the second dimension of the tensor shape is specified according to the |options|.{{MLGruOptions/layout}} argument. + - recurrentWeight: an {{MLOperand}}. The 3-D recurrent weight tensor of shape *[numDirections, 3 * hiddenSize, hiddenSize]*. The ordering of the weight vectors in the second dimension of the tensor shape is specified according to the |options|.{{MLGruOptions/layout}} argument. + - steps: an {{unsigned long}} scalar. The number of time steps in the recurrent network. The value must be greater than 0. + - hiddenSize: an {{unsigned long}} scalar. The value of the third dimension of the cell output tensor shape. It indicates the number of features in the hidden state. + - options: an optional {{MLGruOptions}}. The optional parameters of the operation. **Returns:** a sequence of {{MLOperand}}. The first element of the sequence is a 3-D tensor of shape *[numDirections, batchSize, hiddenSize]*, the cell output from the last time step of the network. Additionally, if |options|.{{MLGruOptions/returnSequence}} is set to true, the second element is the 4-D output tensor of shape *[steps, numDirections, batchSize, hiddenSize]* containing every cell outputs from each time step in the temporal sequence.
@@ -3262,14 +3285,14 @@ partial interface MLGraphBuilder { Specifies a pair of activation functions with the first function used for the update and reset gate, and the second used for the new gate. When not specified, implementations SHOULD use the pair of sigmoid ("sigmoid") and the hyperbolic tangent ("tanh") functions, respectively. -
+
**Arguments:** - - *input*: an {{MLOperand}}. The input 2-D tensor of shape *[batchSize, inputSize]*. - - *weight*: an {{MLOperand}}. The 2-D input weight tensor of shape *[3 * hiddenSize, inputSize]*. The ordering of the weight vectors in the first dimension of the tensor shape is specified according to the *options.layout* argument. - - *recurrentWeight*: an {{MLOperand}}. The 2-D recurrent weight tensor of shape *[3 * hiddenSize, hiddenSize]*. The ordering of the weight vectors in the first dimension of the tensor shape is specified according to the *options.layout* argument. - - *hiddenState*: an {{MLOperand}}. The 2-D input hidden state tensor of shape *[batchSize, hiddenSize]*. - - *hiddenSize*: an {{unsigned long}} scalar. The value of the second dimension of the output tensor shape. It indicates the number of features in the hidden state. - - *options*: an optional {{MLGruCellOptions}}. The optional parameters of the operation. + - input: an {{MLOperand}}. The input 2-D tensor of shape *[batchSize, inputSize]*. + - weight: an {{MLOperand}}. The 2-D input weight tensor of shape *[3 * hiddenSize, inputSize]*. The ordering of the weight vectors in the first dimension of the tensor shape is specified according to the *options.layout* argument. + - recurrentWeight: an {{MLOperand}}. The 2-D recurrent weight tensor of shape *[3 * hiddenSize, hiddenSize]*. The ordering of the weight vectors in the first dimension of the tensor shape is specified according to the *options.layout* argument. + - hiddenState: an {{MLOperand}}. The 2-D input hidden state tensor of shape *[batchSize, hiddenSize]*. + - hiddenSize: an {{unsigned long}} scalar. The value of the second dimension of the output tensor shape. It indicates the number of features in the hidden state. + - options: an optional {{MLGruCellOptions}}. The optional parameters of the operation. **Returns:** an {{MLOperand}}. The 2-D tensor of shape *[batchSize, hiddenSize]*, the cell output hidden state of a single time step of the recurrent network.
@@ -3445,10 +3468,10 @@ partial interface MLGraphBuilder { #### {{MLGraphBuilder/hardSigmoid(input, options)}} #### {#api-mlgraphbuilder-hardsigmoid-input-options} -
+
**Arguments:** - - *input*: an {{MLOperand}}. The input tensor. - - *options*: an optional {{MLHardSigmoidOptions}}. The optional parameters of the operation. + - input: an {{MLOperand}}. The input tensor. + - options: an optional {{MLHardSigmoidOptions}}. The optional parameters of the operation. **Returns:** - an {{MLOperand}}. The output tensor of the same shape as *input*. @@ -3491,9 +3514,9 @@ partial interface MLGraphBuilder {
#### {{MLGraphBuilder/hardSigmoid(options)}} #### {#api-mlgraphbuilder-hardsigmoid-options} -
+
**Arguments:** - - *options*: an optional {{MLHardSigmoidOptions}}. The optional parameters of the operation. + - options: an optional {{MLHardSigmoidOptions}}. The optional parameters of the operation. **Returns:** - an {{MLActivation}}. The activation function representing the hard sigmoid operation. @@ -3521,9 +3544,9 @@ partial interface MLGraphBuilder { #### {{MLGraphBuilder/hardSwish(input)}} #### {#api-mlgraphbuilder-hardswish-input} -
+
**Arguments:** - - *input*: an {{MLOperand}}. The input tensor. + - input: an {{MLOperand}}. The input tensor. **Returns:** - an {{MLOperand}}. The output tensor of the same shape as *input*. @@ -3566,7 +3589,7 @@ partial interface MLGraphBuilder {
#### {{MLGraphBuilder/hardSwish()}} #### {#api-mlgraphbuilder-hardswish} -
+
**Arguments:** - None. @@ -3620,10 +3643,10 @@ partial interface MLGraphBuilder { -
+
**Arguments:** - - *input*: an {{MLOperand}}. The input 4-D tensor. - - *options*: an optional {{MLInstanceNormalizationOptions}}. The optional parameters of the operation. + - input: an {{MLOperand}}. The input 4-D tensor. + - options: an optional {{MLInstanceNormalizationOptions}}. The optional parameters of the operation. **Returns:** an {{MLOperand}}. The instance-normalized 4-D tensor of the same shape as *input*.
@@ -3720,10 +3743,10 @@ partial interface MLGraphBuilder { A small value to prevent computational error due to divide-by-zero. -
+
**Arguments:** - - *input*: an {{MLOperand}}. The input N-D tensor. - - *options*: an optional {{MLLayerNormalizationOptions}}. The optional parameters of the operation. + - input: an {{MLOperand}}. The input N-D tensor. + - options: an optional {{MLLayerNormalizationOptions}}. The optional parameters of the operation. **Returns:** an {{MLOperand}}. The layer-normalized N-D tensor of the same shape as *input*.
@@ -3815,10 +3838,10 @@ partial interface MLGraphBuilder { #### {{MLGraphBuilder/leakyRelu(input, options)}} #### {#api-mlgraphbuilder-leaky-relu-input-options} -
+
**Arguments:** - - *input*: an {{MLOperand}}. The input tensor. - - *options*: an optional {{MLLeakyReluOptions}}. The optional parameters of the operation. + - input: an {{MLOperand}}. The input tensor. + - options: an optional {{MLLeakyReluOptions}}. The optional parameters of the operation. **Returns:** - an {{MLOperand}}. The output tensor of the same shape as *input*. @@ -3858,9 +3881,9 @@ partial interface MLGraphBuilder {
#### {{MLGraphBuilder/leakyRelu(options)}} #### {#api-mlgraphbuilder-leaky-relu-options} -
+
**Arguments:** - - *options*: an optional {{MLLeakyReluOptions}}. The optional parameters of the operation. + - options: an optional {{MLLeakyReluOptions}}. The optional parameters of the operation. **Returns:** - an {{MLActivation}}. The activation function representing the leaky relu operation. @@ -3903,10 +3926,10 @@ partial interface MLGraphBuilder { #### {{MLGraphBuilder/linear(input, options)}} #### {#api-mlgraphbuilder-linear-input-options} -
+
**Arguments:** - - *input*: an {{MLOperand}}. The input tensor. - - *options*: an optional {{MLLinearOptions}}. The optional parameters of the operation. + - input: an {{MLOperand}}. The input tensor. + - options: an optional {{MLLinearOptions}}. The optional parameters of the operation. **Returns:** - an {{MLOperand}}. The output tensor of the same shape as *input*. @@ -3945,9 +3968,9 @@ partial interface MLGraphBuilder {
#### {{MLGraphBuilder/linear(options)}} #### {#api-mlgraphbuilder-linear-options} -
+
**Arguments:** - - *options*: an optional {{MLLinearOptions}}. The optional parameters of the operation. + - options: an optional {{MLLinearOptions}}. The optional parameters of the operation. **Returns:** - an {{MLActivation}}. The activation function representing the linear operation. @@ -4035,14 +4058,14 @@ partial interface MLGraphBuilder { A list of three activation functions, the first one is used for the `input (i)`, `forget (f)`, and `output (o)` gate, the second one is used for the `cell (g)` gate, and the last used for filtering the output cell state before combining it with the result of the output gate to form the output hidden state. When not specified, implementations SHOULD use the sequence of the sigmoid function ("sigmoid") followed by two hyperbolic tangent functions ("tanh") respectively. -
+
**Arguments:** - - *input*: an {{MLOperand}}. The input 3-D tensor of shape *[steps, batchSize, inputSize]*. - - *weight*: an {{MLOperand}}. The 3-D input weight tensor of shape *[numDirections, 4 * hiddenSize, inputSize]*. The ordering of the weight vectors in the second dimension of the tensor shape is specified according to the |options|.{{MLLstmOptions/layout}}. - - *recurrentWeight*: an {{MLOperand}}. The 3-D recurrent weight tensor of shape *[numDirections, 4 * hiddenSize, hiddenSize]*. The ordering of the weight vectors in the second dimension of the tensor shape is specified according to the |options|.{{MLLstmOptions/layout}} argument. - - *steps*: an {{unsigned long}} scalar. The number of time steps in the recurrent network. The value must be greater than 0. - - *hiddenSize*: an {{unsigned long}} scalar. The value of the third dimension of the cell output tensor shape. It indicates the number of features in the hidden state. - - *options*: an optional {{MLLstmOptions}}. The optional parameters of the operation. + - input: an {{MLOperand}}. The input 3-D tensor of shape *[steps, batchSize, inputSize]*. + - weight: an {{MLOperand}}. The 3-D input weight tensor of shape *[numDirections, 4 * hiddenSize, inputSize]*. The ordering of the weight vectors in the second dimension of the tensor shape is specified according to the |options|.{{MLLstmOptions/layout}}. + - recurrentWeight: an {{MLOperand}}. The 3-D recurrent weight tensor of shape *[numDirections, 4 * hiddenSize, hiddenSize]*. The ordering of the weight vectors in the second dimension of the tensor shape is specified according to the |options|.{{MLLstmOptions/layout}} argument. + - steps: an {{unsigned long}} scalar. The number of time steps in the recurrent network. The value must be greater than 0. + - hiddenSize: an {{unsigned long}} scalar. The value of the third dimension of the cell output tensor shape. It indicates the number of features in the hidden state. + - options: an optional {{MLLstmOptions}}. The optional parameters of the operation. **Returns:** a sequence of {{MLOperand}}. The first element of the sequence is a 3-D tensor of shape *[numDirections, batchSize, hiddenSize]*, the output hidden state from the last time step of the network. The second element is a 3-D tensor of shape *[numDirections, batchSize, hiddenSize]*, the output cell state from the last time step of the network. Additionally, if |options|.{{MLLstmOptions/returnSequence}} is set to true, the third element is the 4-D output tensor of shape *[steps, numDirections, batchSize, hiddenSize]* containing every output from each time step in the temporal sequence.
@@ -4297,15 +4320,15 @@ partial interface MLGraphBuilder { A list of three activation functions, the first one is used for the `input (i)`, `forget (f)`, and `output (o)` gate, the second one is used for the `cell (g)` gate, and the last used for filtering the output cell state before combining it with the result of the output gate to form the output hidden state. When not specified, they are assumed to be of the sigmoid function ("sigmoid") followed by two hyperbolic tangent functions ("tanh") respectively. -
+
**Arguments:** - - *input*: an {{MLOperand}}. The input 2-D tensor of shape *[batchSize, inputSize]*. - - *weight*: an {{MLOperand}}. The 2-D input weight tensor of shape *[4 * hiddenSize, inputSize]*. The ordering of the weight vectors in the first dimension of the tensor shape is specified according to the *options.layout* argument. - - *recurrentWeight*: an {{MLOperand}}. The 2-D recurrent weight tensor of shape *[4 * hiddenSize, hiddenSize]*. The ordering of the weight vectors in the first dimension of the tensor shape is specified according to the *options.layout* argument. - - *hiddenState*: an {{MLOperand}}. The 2-D input hidden state tensor of shape *[batchSize, hiddenSize]*. - - *cellState*: an {{MLOperand}}. The 2-D input cell state tensor of shape *[batchSize, hiddenSize]*. - - *hiddenSize*: an {{unsigned long}} scalar. The value of the second dimension of the output tensor shape. It indicates the number of features in the hidden state. - - *options*: an optional {{MLLstmCellOptions}}. The optional parameters of the operation. + - input: an {{MLOperand}}. The input 2-D tensor of shape *[batchSize, inputSize]*. + - weight: an {{MLOperand}}. The 2-D input weight tensor of shape *[4 * hiddenSize, inputSize]*. The ordering of the weight vectors in the first dimension of the tensor shape is specified according to the *options.layout* argument. + - recurrentWeight: an {{MLOperand}}. The 2-D recurrent weight tensor of shape *[4 * hiddenSize, hiddenSize]*. The ordering of the weight vectors in the first dimension of the tensor shape is specified according to the *options.layout* argument. + - hiddenState: an {{MLOperand}}. The 2-D input hidden state tensor of shape *[batchSize, hiddenSize]*. + - cellState: an {{MLOperand}}. The 2-D input cell state tensor of shape *[batchSize, hiddenSize]*. + - hiddenSize: an {{unsigned long}} scalar. The value of the second dimension of the output tensor shape. It indicates the number of features in the hidden state. + - options: an optional {{MLLstmCellOptions}}. The optional parameters of the operation. **Returns:** a sequence of {{MLOperand}}. The first element of the sequence is the output hidden state of the current time step of the recurrent network. The following element is the output cell state. Both elements are 2-D tensors of shape *[batchSize, hiddenSize]*.
@@ -4494,10 +4517,10 @@ partial interface MLGraphBuilder { }; -
+
**Arguments:** - - *a*: an {{MLOperand}}. The first input tensor which is at least 2-D. - - *b*: an {{MLOperand}}. The second input tensor which is at least 2-D. + - a: an {{MLOperand}}. The first input tensor which is at least 2-D. + - b: an {{MLOperand}}. The second input tensor which is at least 2-D. **Returns:** an {{MLOperand}}. The output tensor that contains the matrix product of two input tensors. @@ -4584,12 +4607,12 @@ partial interface MLGraphBuilder { The padding value when {{MLPadOptions/mode}} is set to {{MLPaddingMode/"constant"}}. -
+
**Arguments:** - - *input*: an {{MLOperand}}. The input tensor. - - *beginningPadding*: a sequence of {{unsigned long}}. The sequence of unsigned integer values indicating the number of padding values to add at the beginning of each input dimension, of length *N* where *N* is the [=MLOperand/rank=] of the input tensor. For each dimension *d* of *input*, *beginningPadding[d]* indicates how many values to add before the content in that dimension. - - *endingPadding*: a sequence of {{unsigned long}}. The sequence of unsigned integer values indicating the number of padding values to add at the ending of each input dimension, of length *N* where *N* is the [=MLOperand/rank=] of the input tensor. For each dimension *d* of *input*, *endingPadding[d]* indicates how many values to add after the content in that dimension. - - *options*: an optional {{MLPadOptions}}. The optional parameters of the operation. + - input: an {{MLOperand}}. The input tensor. + - beginningPadding: a sequence of {{unsigned long}}. The sequence of unsigned integer values indicating the number of padding values to add at the beginning of each input dimension, of length *N* where *N* is the [=MLOperand/rank=] of the input tensor. For each dimension *d* of *input*, *beginningPadding[d]* indicates how many values to add before the content in that dimension. + - endingPadding: a sequence of {{unsigned long}}. The sequence of unsigned integer values indicating the number of padding values to add at the ending of each input dimension, of length *N* where *N* is the [=MLOperand/rank=] of the input tensor. For each dimension *d* of *input*, *endingPadding[d]* indicates how many values to add after the content in that dimension. + - options: an optional {{MLPadOptions}}. The optional parameters of the operation. **Returns:** an {{MLOperand}}. The padded output tensor. Each dimension of the output tensor can be calculated as follows: @@ -4745,11 +4768,11 @@ partial interface MLGraphBuilder { If not specified, the output sizes are automatically computed. -
+
**Arguments:** - - *input*: an {{MLOperand}}. The input 4-D tensor. The logical shape + - input: an {{MLOperand}}. The input 4-D tensor. The logical shape is interpreted according to the value of *options.layout*. - - *options*: an optional {{MLPool2dOptions}}. The optional parameters of the operation. + - options: an optional {{MLPool2dOptions}}. The optional parameters of the operation. **Returns:** an {{MLOperand}}. The output 4-D tensor that contains the result of the reduction. The logical shape is interpreted according to the @@ -4894,10 +4917,10 @@ partial interface MLGraphBuilder { }; -
+
**Arguments:** - - *input*: an {{MLOperand}}. The input tensor. - - *slope*: an {{MLOperand}}. The slope tensor. Its shape is either the same as, or [=unidirectionally broadcastable=] to the shape of input tensor *input*. + - input: an {{MLOperand}}. The input tensor. + - slope: an {{MLOperand}}. The slope tensor. Its shape is either the same as, or [=unidirectionally broadcastable=] to the shape of input tensor *input*. **Returns:** - an {{MLOperand}}. The output tensor of the same shape as *input*. @@ -4972,10 +4995,10 @@ partial interface MLGraphBuilder { If true, the output has the same rank as the input, setting any reduced dimensions to size 1. -
+
**Arguments:** - - *input*: an {{MLOperand}}. The input tensor. - - *options*: an optional {{MLReduceOptions}}. The optional parameters of the operation. + - input: an {{MLOperand}}. The input tensor. + - options: an optional {{MLReduceOptions}}. The optional parameters of the operation. **Returns:** an {{MLOperand}}. The reduced output tensor.
@@ -5143,9 +5166,9 @@ partial interface MLGraphBuilder { #### {{MLGraphBuilder/relu(input)}} #### {#api-mlgraphbuilder-relu-input} -
+
**Arguments:** - - *input*: an {{MLOperand}}. The input tensor. + - input: an {{MLOperand}}. The input tensor. **Returns:** - an {{MLOperand}}. The output tensor of the same shape as *input*. @@ -5180,7 +5203,7 @@ partial interface MLGraphBuilder {
#### {{MLGraphBuilder/relu()}} #### {#api-mlgraphbuilder-relu} -
+
**Arguments:** - None. @@ -5215,10 +5238,10 @@ partial interface MLGraphBuilder { MLOperand resample2d(MLOperand input, optional MLResample2dOptions options = {}); }; -
+
**Arguments:** - - *input*: an {{MLOperand}}. The input 4-D tensor. - - *options*: an optional {{MLResample2dOptions}}. The optional parameters of the operation. + - input: an {{MLOperand}}. The input 4-D tensor. + - options: an optional {{MLResample2dOptions}}. The optional parameters of the operation. **Returns:** an {{MLOperand}}. The output 4-D tensor.
@@ -5297,10 +5320,10 @@ partial interface MLGraphBuilder { MLOperand reshape(MLOperand input, sequence<[EnforceRange] unsigned long> newShape); }; -
+
**Arguments:** - - *input*: an {{MLOperand}}. The input tensor. - - *newShape*: a sequence of {{unsigned long}}. The shape of the output tensor. + - input: an {{MLOperand}}. The input tensor. + - newShape: a sequence of {{unsigned long}}. The shape of the output tensor. The number of elements implied by *newShape* must be the same as the number of elements in the input tensor. @@ -5341,9 +5364,9 @@ partial interface MLGraphBuilder { #### {{MLGraphBuilder/sigmoid(input)}} #### {#api-mlgraphbuilder-sigmoid-input} -
+
**Arguments:** - - *input*: an {{MLOperand}}. The input tensor. + - input: an {{MLOperand}}. The input tensor. **Returns:** - an {{MLOperand}}. The output tensor of the same shape as *input*. @@ -5381,7 +5404,7 @@ partial interface MLGraphBuilder {
#### {{MLGraphBuilder/sigmoid()}} #### {#api-mlgraphbuilder-sigmoid} -
+
**Arguments:** - None. @@ -5406,11 +5429,11 @@ partial interface MLGraphBuilder { sequence<[EnforceRange] unsigned long> sizes); }; -
+
**Arguments:** - - *input*: an {{MLOperand}}. The input tensor. - - *starts*: a sequence of {{unsigned long}}. The sequence of unsigned integer values indicating the starting index to slice of each input dimension, of length N where N is the [=MLOperand/rank=] of the input tensor. For each dimension *d* of *input*, *starts[d]* indicates the starting index to slice in that dimension. The starting index must be in the range [0, input size - 1] in that dimension. - - *sizes*: a sequence of {{unsigned long}}. The sequence of unsigned integer values indicating the number of elements to slice of each input dimension, of length N where N is the [=MLOperand/rank=] of the input tensor. For each dimension *d* of *input*, *sizes[d]* indicates the number of elements to slice in that dimension. The size must not be 0 and must satisfy the constraint `starting index + size <= input size` in that dimension. + - input: an {{MLOperand}}. The input tensor. + - starts: a sequence of {{unsigned long}}. The sequence of unsigned integer values indicating the starting index to slice of each input dimension, of length N where N is the [=MLOperand/rank=] of the input tensor. For each dimension *d* of *input*, *starts[d]* indicates the starting index to slice in that dimension. The starting index must be in the range [0, input size - 1] in that dimension. + - sizes: a sequence of {{unsigned long}}. The sequence of unsigned integer values indicating the number of elements to slice of each input dimension, of length N where N is the [=MLOperand/rank=] of the input tensor. For each dimension *d* of *input*, *sizes[d]* indicates the number of elements to slice in that dimension. The size must not be 0 and must satisfy the constraint `starting index + size <= input size` in that dimension. **Returns:** an {{MLOperand}}. The output tensor of the same rank as the input tensor with tensor values stripped to the specified starting and ending indices in each dimension.
@@ -5447,10 +5470,10 @@ partial interface MLGraphBuilder { }; -
+
**Arguments:** - - *input*: an {{MLOperand}}. The input N-D tensor. - - *axis*: an {{unsigned long}} scalar. The dimension the reduction will be performed on. + - input: an {{MLOperand}}. The input N-D tensor. + - axis: an {{unsigned long}} scalar. The dimension the reduction will be performed on. **Returns:** - an {{MLOperand}}. The output N-D tensor that contains the softmax results, of the same shape as *input*. @@ -5505,9 +5528,9 @@ partial interface MLGraphBuilder { #### {{MLGraphBuilder/softplus(input)}} #### {#api-mlgraphbuilder-softplus-input} -
+
**Arguments:** - - *input*: an {{MLOperand}}. The input tensor. + - input: an {{MLOperand}}. The input tensor. **Returns:** - an {{MLOperand}}. The output tensor of the same shape as *input*. @@ -5543,7 +5566,7 @@ partial interface MLGraphBuilder {
#### {{MLGraphBuilder/softplus()}} #### {#api-mlgraphbuilder-softplus} -
+
**Arguments:** - None. @@ -5584,9 +5607,9 @@ partial interface MLGraphBuilder {
#### {{MLGraphBuilder/softsign(input)}} #### {#api-mlgraphbuilder-softsign-input} -
+
**Arguments:** - - *input*: an {{MLOperand}}. The input tensor. + - input: an {{MLOperand}}. The input tensor. **Returns:** - an {{MLOperand}}. The output tensor of the same shape as *input*. @@ -5608,7 +5631,7 @@ partial interface MLGraphBuilder {
#### {{MLGraphBuilder/softsign()}} #### {#api-mlgraphbuilder-softsign} -
+
**Arguments:** - None. @@ -5639,11 +5662,11 @@ partial interface MLGraphBuilder { }; -
+
**Arguments:** - - *input*: an {{MLOperand}}. The input tensor. - - *splits*: an {{unsigned long}} or a sequence of {{unsigned long}}. If an {{unsigned long}}, it specifies the number of output tensors along the axis. The number must evenly divide the dimension size of *input* along *options.axis*. If a sequence of {{unsigned long}}, it specifies the sizes of each output tensor along the *options.axis*. The sum of sizes must equal to the dimension size of *input* along *options.axis*. - - *options*: an optional {{MLSplitOptions}}. The optional parameters of the operation. + - input: an {{MLOperand}}. The input tensor. + - splits: an {{unsigned long}} or a sequence of {{unsigned long}}. If an {{unsigned long}}, it specifies the number of output tensors along the axis. The number must evenly divide the dimension size of *input* along *options.axis*. If a sequence of {{unsigned long}}, it specifies the sizes of each output tensor along the *options.axis*. The sum of sizes must equal to the dimension size of *input* along *options.axis*. + - options: an optional {{MLSplitOptions}}. The optional parameters of the operation. **Returns:** a sequence of {{MLOperand}}. The splitted output tensors. If *splits* is an {{unsigned long}}, the [=list/size=] of the output sequence equals to *splits*. The shape of each output tensor is the same as *input* except the dimension size of *axis* equals to the quotient of dividing the dimension size of *input* along *axis* by *splits*. If *splits* is a sequence of {{unsigned long}}, the [=list/size=] of the output sequence equals to the [=list/size=] of *splits*. The shape of the i-th output tensor is the same as *input* except along *axis* where the dimension size is *splits[i]*.
@@ -5723,9 +5746,9 @@ partial interface MLGraphBuilder { #### {{MLGraphBuilder/tanh(input)}} #### {#api-mlgraphbuilder-tanh-input} -
+
**Arguments:** - - *input*: an {{MLOperand}}. The input tensor. + - input: an {{MLOperand}}. The input tensor. **Returns:** - an {{MLOperand}}. The output tensor of the same shape as *input*. @@ -5766,7 +5789,7 @@ partial interface MLGraphBuilder {
#### {{MLGraphBuilder/tanh()}} #### {#api-mlgraphbuilder-tanh} -
+
**Arguments:** - None. @@ -5803,10 +5826,10 @@ partial interface MLGraphBuilder { These default values cause the output to become a transposed tensor of the input. When specified, the number of values in the sequence must be the same as the [=MLOperand/rank=] of the input tensor, and the values in the sequence must be within the range from 0 to N-1 with no two or more same values found in the sequence. -
+
**Arguments:** - - *input*: an {{MLOperand}}. The input N-D tensor. - - *options*: an optional {{MLTransposeOptions}}. The optional parameters of the operation. + - input: an {{MLOperand}}. The input N-D tensor. + - options: an optional {{MLTransposeOptions}}. The optional parameters of the operation. **Returns:** an {{MLOperand}}. The permuted or transposed N-D tensor.
@@ -5853,10 +5876,10 @@ partial interface MLGraphBuilder { Specifies how many diagonals above or below the main diagonals of the input matrix are retained or excluded. A value of 0 means no diagonals other than the main diagonals are affected. -
+
**Arguments:** - - *input*: an {{MLOperand}}. The input tensor which is at least 2-D. - - *options*: an optional {{MLTriangularOptions}}. The optional parameters of the operation. + - input: an {{MLOperand}}. The input tensor which is at least 2-D. + - options: an optional {{MLTriangularOptions}}. The optional parameters of the operation. **Returns:** an {{MLOperand}}. The output tensor representing a triangular matrix, or batch of matrices which is the same shape as the input.
@@ -5948,11 +5971,11 @@ partial interface MLGraphBuilder { }; -
+
**Arguments:** - - *condition*: an {{MLOperand}}. The condition tensor. - - *trueValue*: an {{MLOperand}}. The trueValue tensor from which the value is selected when the condition of the corresponding element is set to true. - - *falseValue*: an {{MLOperand}}. The falseValue tensor from which the value is selected when the condition of the corresponding element is set to false. + - condition: an {{MLOperand}}. The condition tensor. + - trueValue: an {{MLOperand}}. The tensor from which the value is selected when the condition of the corresponding element is set to true. + - falseValue: an {{MLOperand}}. The tensor from which the value is selected when the condition of the corresponding element is set to false. **Returns:** an {{MLOperand}}. The output tensor that contains the values selected element-wise from either the trueValue or the falseValue tensor.
diff --git a/tools/lint.mjs b/tools/lint.mjs index 8b0beb2c..52cea5b6 100755 --- a/tools/lint.mjs +++ b/tools/lint.mjs @@ -288,4 +288,19 @@ for (const dfn of root.querySelectorAll('dfn[data-dfn-type=method]')) { } } +// Ensure every IDL argument is linked to a definition. +for (const dfn of root.querySelectorAll('pre.idl dfn[data-dfn-type=argument]')) { + const dfnFor = dfn.getAttribute('data-dfn-for'); + error(`Missing ${dfn.innerText} (or equivalent)`); +} + +// Ensure every argument dfn is correctly associated with a method. +// This tries to catch extraneous definitions, e.g. after an arg is removed. +for (const dfn of root.querySelectorAll('dfn[data-dfn-type=argument]')) { + const dfnFor = dfn.getAttribute('data-dfn-for'); + if (!dfnFor.split(/\b/).includes(dfn.innerText)) { + error(`Argument definition '${dfn.innerText}' doesn't appear in '${dfnFor}'`); + } +} + globalThis.process.exit(exitCode);