diff --git a/index.bs b/index.bs index f6fafdc0..96cd6729 100644 --- a/index.bs +++ b/index.bs @@ -1054,7 +1054,7 @@ The {{MLActivation}} objects (including the ones passed as input to methods) are
- To create MLActivation given |builder|, |name| and |options|, run the following steps: + To create MLActivation given |builder|, |name|, |options| and |init-steps|, run the following steps:
1. If |builder| is not an instance of {{MLGraphBuilder}}, throw a "{{TypeError}}" and abort these steps. @@ -1063,8 +1063,12 @@ The {{MLActivation}} objects (including the ones passed as input to methods) are 1. Set |activation|.{{MLActivation/[[builder]]}} to |builder|. 1. Set |activation|.{{MLActivation/[[name]]}} to |name|. 1. If |options| is an [=object=], set |activation|.{{MLActivation/[[options]]}} to |options|. - 1. Make a request to the underlying platform to bind the [=implementation-defined=] platform operator for |name| to |activation|.{{MLActivation/[[operator]]}}. - 1. If that fails, throw a "{{TypeError}}" and abort these steps. + 1. If any of the following sub-steps fail, throw an "{{OperationError}}" {{DOMException}} and stop. + 1. Make a request to the underlying platform to: + 1. Create an [=implementation-defined=] platform operator |opImpl| for the given |name| operation. + 1. Store a reference of |opImpl| in |activation|.{{MLActivation/[[operator]]}}. + 1. If |init-steps| are defined, run |init-steps| with |options|. + 1. Otherwise, initialize |activation|.{{MLActivation/[[operator]]}} given |options| in an [=implementation-defined=] way for the given |name| operation. 1. Return |activation|.
@@ -1580,11 +1584,13 @@ Create a named {{MLOperand}} based on a descriptor, that can be used as an input 1. If |descriptor|.{{MLOperandDescriptor/dimensions}} [=map/exists=]: 1. If the [=check dimensions=] steps given |descriptor|.{{MLOperandDescriptor/type}} and |descriptor|.{{MLOperandDescriptor/dimensions}} return `false`, throw a "{{DataError}}" {{DOMException}} and stop. 1. If the [=byte length=] of |descriptor| is not supported by the underlying platform, then throw a "{{DataError}}" {{DOMException}} and stop. - 1. Let |operand| be the result of invoking the create MLOperand steps with [=this=] and |descriptor|. - 1. If that throws, re-throw the exception and stop. - 1. Set |operand|.{{MLOperand/[[name]]}} to |name|. - 1. Make a request to the underlying platform to register |operand| as an input and store a reference to the corresponding [=implementation-defined=] platform object in |operand|.{{MLOperand/[[operand]]}}. - 1. If that fails, throw an "{{OperationError}}" {{DOMException}} and abort these steps. + 1. If any of the following sub-steps fail, throw an "{{OperationError}}" {{DOMException}} and stop. + 1. Let |operand| be the result of invoking the create MLOperand steps with [=this=] and |descriptor|. + 1. Set |operand|.{{MLOperand/[[name]]}} to |name|. + 1. Make a request to the underlying platform to: + 1. Create an [=implementation-defined=] platform input operand |operandImpl| given |descriptor|. + 1. Store a reference of |operandImpl| in |operand|.{{MLOperand/[[operand]]}}. + 1. Register |operand| as an input. 1. Return |operand|. @@ -1614,11 +1620,13 @@ Create a constant {{MLOperand}} that can be used in {{MLGraphBuilder}} methods. 1. If the [=check dimensions=] steps given |descriptor|.{{MLOperandDescriptor/type}} and |descriptor|.{{MLOperandDescriptor/dimensions}} return `false`, throw a "{{DataError}}" {{DOMException}} and stop. 1. Let |bufferView| be the second argument. 1. If invoking validate buffer with descriptor given |bufferView| and |descriptor| return `false`, then throw a "{{TypeError}}" {{DOMException}} and stop. - 1. Let |operand| be the result of invoking the create MLOperand steps with [=this=] and |descriptor|. - 1. If that throws, re-throw the exception and stop. - 1. Let |bytes| be the result of invoking [[=get a copy of the bytes held by the buffer source=]] given |bufferView|. - 1. Make a request to the underlying platform to register |operand| as a tensor constant with |bytes| as value and store a reference to the corresponding [=implementation-defined=] object to |operand|.{{MLOperand/[[operand]]}}. - 1. If that fails, throw an "{{OperationError}}" {{DOMException}} and stop. + 1. If any of the following sub-steps fail, throw an "{{OperationError}}" {{DOMException}} and stop. + 1. Let |operand| be the result of invoking the create MLOperand steps with [=this=] and |descriptor|. + 1. Let |bytes| be the result of invoking [[=get a copy of the bytes held by the buffer source=]] given |bufferView|. + 1. Make a request to the underlying platform to: + 1. Create an [=implementation-defined=] platform operand |constantImpl| to represent a constant, given |descriptor|. + 1. Store a reference of |constantImpl| in |operand|.{{MLOperand/[[operand]]}}. + 1. Register |operand| as a tensor constant with |bytes| as value. 1. Return |operand|. @@ -1649,10 +1657,12 @@ Create a constant {{MLOperand}} that can be used in {{MLGraphBuilder}} methods.
In the case of a scalar constant, |descriptor|.{{MLOperandDescriptor/dimensions}} is ignored.
- 1. Let |operand| be the result of invoking the create MLOperand steps with [=this=] and |descriptor|. - 1. If that throws, re-throw the exception and stop. - 1. Make a request to the underlying platform to register |operand| as a scalar constant with |value| as value and store a reference of the [=implementation-defined=] platform object for the corresponding (scalar or tensor constant) operand to |operand|.{{MLOperand/[[operand]]}}. - 1. If that throws, re-throw the error and stop. + 1. If any of the following sub-steps fail, throw an "{{OperationError}}" {{DOMException}} and stop. + 1. Let |operand| be the result of invoking the create MLOperand steps with [=this=] and |descriptor|. + 1. Make a request to the underlying platform to: + 1. Create an [=implementation-defined=] platform operand |constantImpl| to represent a constant, given |descriptor|. + 1. Store a reference of |constantImpl| in |operand|.{{MLOperand/[[operand]]}}. + 1. Register |operand| as a scalar constant with |value| as value. 1. Return |operand|. @@ -1724,12 +1734,13 @@ partial interface MLGraphBuilder { 1. If |options|.axis is not a number between 0 and the rank of |input|, then throw a "{{TypeError}}" {{DOMException}} and abort these steps. 1. If |input| is a 4-D tensor of the *"nchw"* layout, set |options|.axis to 1. 1. If |input| is a 4-D tensor of the *"nhwc"* layout, set |options|.axis to 3. - 1. Let |result| be an {{MLOperand}} representing the results. It may use the same underlying data as |input|. - 1. Issue a request to the underlying platform to initialize the batch normalization, passing the arguments |input|, |mean|, |variance| and |options| and given |result| to store the results and |options|. Wait for completion. -
- 1. If |options|.activation [=map/exists=], implementations MAY use it to optimize the operation flow. -
- 1. Return |result|. + 1. If any of the following sub-steps fail, throw an "{{OperationError}}" {{DOMException}} and stop. + 1. Let |output| be the result of invoking the create MLOperand steps with [=this=] and |descriptor|, that may use the same underlying data as |input|. + 1. Make a request to the underlying platform to initialize the batch normalization: + 1. Create an [=implementation-defined=] platform operator |batchNormImpl| for this method, given |input|, |mean|, |variance| and |options|. + 1. If |options|.activation [=map/exists=],register it as activation to |batchNormImpl|. + 1. Connect |output| as output to |batchNormImpl|. + 1. Return |output|. @@ -1824,16 +1835,16 @@ partial interface MLGraphBuilder { 1. Let |operand| be the first argument. 1. Let |options| be the second argument. 1. If running the check clamp options steps with |options| returns `false`, then throw a "{{TypeError}}" {{DOMException}} and abort these steps. - 1. Let |result| be the result of invoking the copy MLOperand steps given |operand|. - 1. If that throws an error, re-throw the error and abort these steps. 1. If any of the following sub-steps fail, throw an "{{OperationError}}" {{DOMException}} and stop. - 1. Make a request to the underlying platform to create an [=implementation-defined=] platform operand |operandImpl| given |result|.{{MLOperand/[[descriptor]]}}. - 1. Store a reference to |operandImpl| in |result|.{{MLOperand/[[operand]]}}. - 1. Make a request to the underlying platform to create an [=implementation-defined=] platform operator |operatorImpl| for clamp with |options|.{{MLClampOptions/minValue}} and |options|.{{MLClampOptions/minValue}}. - 1. Register the |operand|.{{MLOperand/[[operand]]}} as an input to |operatorImpl|. - 1. Register the |result|.{{MLOperand/[[operand]]}} as output to |operatorImpl|. - 1. Store a reference to |operatorImpl| in |result|.{{MLOperand/[[operator]]}}. - 1. Return |result|. + 1. Let |output| be the result of invoking the copy MLOperand steps given |operand|. + 1. Make a request to the underlying platform to: + 1. Create an [=implementation-defined=] platform operator |clampImpl| for this method, given |options|.{{MLClampOptions/minValue}} and |options|.{{MLClampOptions/minValue}}. + 1. Store a reference of |clampImpl| in |output|.{{MLOperand/[[operator]]}}. + 1. Create an [=implementation-defined=] platform operand |outputImpl| to represent clamp output, given |output| and |clampImpl|. + 1. Store a reference to |outputImpl| in |output|.{{MLOperand/[[operand]]}}. + 1. Connect |operand|.{{MLOperand/[[operand]]}} as input to |clampImpl|. + 1. Connect |output|.{{MLOperand/[[operand]]}} as output to |clampImpl|. + 1. Return |output|. @@ -1856,9 +1867,6 @@ partial interface MLGraphBuilder { 1. If running the check clamp 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 `"clamp"` and |options|. 1. If that throws an error, re-throw the error and abort these steps. - 1. If any of the following sub-steps fail, throw an "{{OperationError}}" {{DOMException}} and stop. - 1. Make a request to the underlying platform to connect |op| with the [=implementation-defined=] platform operator for clamp |operatorImpl|. - 1. Store a reference to |operatorImpl| in |op|.{{MLActivation/[[operator]]}}. 1. Return |op|. @@ -1910,10 +1918,15 @@ partial interface MLGraphBuilder { 1. If |dim| is not equal to |axis| and if |inputs|[|index|].{{MLOperandDescriptor/dimensions}}[|dim|] is not equal to |inputs|[0].{{MLOperandDescriptor/dimensions}}[|dim|], fail. 1. If |inputs|[|dim|].{{MLOperandDescriptor/type}} is not equal to |inputs|[0].{{MLOperandDescriptor/type}}. 1. If |dim| is equal to |axis|, add to |desc|.{{MLOperandDescriptor/dimensions}}[|axis|] the value of |inputs|[|index|].{{MLOperandDescriptor/dimensions}}[|dim|]. - 1. Let |output| be the result of invoking the create MLOperand steps given [=this=] and |desc|. - 1. If that throws an error, re-throw the error and stop. - 1. Make a request to the underlying platform to create an operator for this method with |inputs| connected as input and |output| connected as output and store a reference to the [=implementation-defined=] platform object to |output|.{{MLOperand/[[operand]]}}. - 1. If that fails, throw a "{{DataError}}" {{DOMException}} and stop. + 1. If any of the following sub-steps fail, throw an "{{OperationError}}" {{DOMException}} and stop. + 1. Let |output| be the result of invoking the create MLOperand steps given [=this=] and |desc|. + 1. Make a request to the underlying platform to: + 1. Create an [=implementation-defined=] platform operator |concatImpl| for this method, given |inputs| and |axis|. + 1. Store a reference of |concatImpl| in |output|.{{MLOperand/[[operator]]}}. + 1. Create an [=implementation-defined=] platform operand |outputImpl| to represent output,given |output| and |concatImpl|. + 1. Store a reference to |outputImpl| in |output|.{{MLOperand/[[operand]]}}. + 1. Connect |inputs| as input to |concatImpl|. + 1. Connect |output|.{{MLOperand/[[operand]]}} as output to |concatImpl|. 1. Return |output|. @@ -2712,7 +2725,7 @@ partial interface MLGraphBuilder { - *options*: an optional {{MLGruOptions}}. The optional parameters of the operation. - *bias*: an {{MLOperand}}. The 2-D input bias tensor of shape [num_directions, 4 * hidden_size]. The ordering of the bias vectors in the second dimension of the tensor shape is specified according to the *options.layout* argument. - *recurrentBias*: an {{MLOperand}}. The 2-D recurrent bias tensor of shape [num_directions, 4 * hidden_size]. The ordering of the bias vectors in the second dimension of the tensor shape is specified according to the *options.layout* argument. - - *peepholeWeight*: an {{MLOperand}}. The 2-D weight tensor for peepholes of shape [num_directions, 4 * hidden_size]. The pack ordering of the weight vectors is for the *input (i)*, *output (o)*, and *forget (f)* gate respectively. + - *peepholeWeight*: an {{MLOperand}}. The 2-D weight tensor for peepholes of shape [num_directions, 3 * hidden_size]. The pack ordering of the weight vectors is for the *input (i)*, *output (o)*, and *forget (f)* gate respectively. - *initialHiddenState*: an {{MLOperand}}. The 3-D initial hidden state tensor of shape [num_directions, batch_size, hidden_size]. When not specified, it's assumed to be a tensor filled with zero. - *initialCellState*: an {{MLOperand}}. The 3-D initial hidden state tensor of shape [num_directions, batch_size, hidden_size]. When not specified, it's assumed to be a tensor filled with zero. - *returnSequence*: a {{boolean}} indicating whether to also return the entire sequence with every output from each time step in it in addition to the output of the last time step. Default to false. @@ -2755,7 +2768,7 @@ partial interface MLGraphBuilder { currentRecurrentBias.push(options.recurrentBias ? (builder.squeeze(builder.slice(options.recurrentBias, [dir, 0], [1, 4 * hidden_size]), { axes: [0] })) : null); currentPeepholeWeight.push(options.peepholeWeight ? - (builder.squeeze(builder.slice(options.peepholeWeight, [dir, 0], [1, 4 * hidden_size]), { axes: [0] })) : null); + (builder.squeeze(builder.slice(options.peepholeWeight, [dir, 0], [1, 3 * hidden_size]), { axes: [0] })) : null); } for (let step = 0; step < steps; ++step) { @@ -2782,8 +2795,8 @@ partial interface MLGraphBuilder { let output = builder.reshape(results[0], [1, null, hiddenSize]); let cell = builder.reshape(results[1], [1, null, hiddenSize]); - nextHidden = (nextHidden ? builder.concat([nextHidden, result], 0) : output); - nextCell = (nextCell ? builder.concat([nextCell, result], 0) : cell); + nextHidden = (nextHidden ? builder.concat([nextHidden, output], 0) : output); + nextCell = (nextCell ? builder.concat([nextCell, cell], 0) : cell); } hiddenState = nextHidden;