diff --git a/index.bs b/index.bs index c1eaf210..b233631a 100644 --- a/index.bs +++ b/index.bs @@ -3529,6 +3529,7 @@ partial interface MLGraphBuilder { ### The linear() method ### {#api-mlgraphbuilder-linear} Calculate a linear function `y = alpha * x + beta` on the input tensor. + -
- **Arguments:** - - *x*: an {{MLOperand}}. The input tensor. - - *options*: an optional {{MLLinearOptions}}. The optional parameters of the operation. - - *alpha*: a {{float}} scalar multiplier, default to 1. - - *beta*: a {{float}} scalar addition, default to 0. - - **Returns:** - - an {{MLOperand}}. The output tensor of the same shape as *x*. - - an {{MLActivation}}. The activation function representing the linear operation. -
+
The behavior of this operation 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 @@ -3561,9 +3552,87 @@ partial interface MLGraphBuilder { builder.mul(x, builder.constant(options.alpha)), builder.constant(options.beta)); -
+{{MLLinearOptions}} has the following members: +
+ : alpha + :: + A {{float}} scalar multiplier. + The default value is `1`. + : beta + :: + A {{float}} scalar addition. + The default value is `0`. +
+ +
+ + To check linear options given |options|, run the following steps: + +
+ 1. If |options| is not an [=object=] that [=implements=] {{MLLinearOptions}}, then return `false`. + 1. If |options|.{{MLEluOptions/alpha}} is `undefined`, set |options|.{{MLLinearOptions/alpha}} to `1`. + 1. Else if |options|.{{MLLinearOptions/alpha}} is not a [=numeric type=], then then return `false`. + 1. If |options|.{{MLLinearOptions/beta}} is `undefined`, set |options|.{{MLLinearOptions/beta}} to `0`. + 1. Else if |options|.{{MLLinearOptions/beta}} is not a [=numeric type=], then then return `false`. + 1. Return `true`. +
+
+ +#### The {{MLGraphBuilder/linear(input, options)}} method #### {#api-mlgraphbuilder-linear-input-options} +
+ **Arguments:** + - *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 *x*. +
+ +
+ + The {{MLGraphBuilder/linear(input, options)}} method steps are: + +
+ 1. Let |input| be the first argument. + 1. Let |options| be the second argument. + 1. If running the check linear options steps with |options| returns `false`, then throw a "{{TypeError}}" {{DOMException}} and abort these steps. + 1. If any of the following sub-steps fail, throw an "{{OperationError}}" {{DOMException}} and stop. + 1. Let |output| be the result of invoking the copy MLOperand steps given |input|. + 1. Make a request to the underlying platform to: + 1. Let |opImpl| be an [=implementation-defined=] platform operator for the linear operation, given |options|. + 1. Store a reference of |opImpl| in |output|.{{MLOperand/[[operator]]}}. + 1. Create an [=implementation-defined=] platform operand |outputImpl| to represent the output, given |output| and |opImpl|. + 1. Store a reference to |outputImpl| in |output|.{{MLOperand/[[operand]]}}. + 1. Connect |input|.{{MLOperand/[[operand]]}} as input to |opImpl|. + 1. Connect |output|.{{MLOperand/[[operand]]}} as output to |opImpl|. + 1. Return |output|. +
+
+ +#### The {{MLGraphBuilder/linear(options)}} method #### {#api-mlgraphbuilder-linear-options} +
+ **Arguments:** + - *options*: an optional {{MLLinearOptions}}. The optional parameters of the operation. + + **Returns:** + - an {{MLActivation}}. The activation function representing the linear operation. +
+ +
+ + The {{MLGraphBuilder/linear(options)}} method steps are: + +
+ 1. Let |options| be the first argument. + 1. If running the check linear options steps with |options| returns `false`, then throw a "{{TypeError}}" {{DOMException}} and abort these steps. + 1. Let |op| be the result of invoking the create MLActivation steps with `"linear"` and |options|. + 1. If that throws an error, re-throw the error and abort these steps. + 1. Return |op|. +
+
+ ### The lstm() method ### {#api-mlgraphbuilder-lstm} Long Short-Term Memory [[LSTM]] recurrent network uses an input, output, forget, and cell gate to compute the output state that rolls into the output across the temporal sequence of the network.