Skip to content

Commit 9774d49

Browse files
authored
Merge pull request #364 from zolkis/builder-input-method
Add the builder.input() method steps
2 parents a115073 + 25f8982 commit 9774d49

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

index.bs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1189,7 +1189,7 @@ interface MLGraphBuilder {
11891189
constructor(MLContext context);
11901190

11911191
// Create an operand for a graph input.
1192-
MLOperand input(DOMString name, MLOperandDescriptor desc);
1192+
MLOperand input(DOMString name, MLOperandDescriptor descriptor);
11931193

11941194
// Create an operand for a graph constant.
11951195
MLOperand constant(MLOperandDescriptor descriptor, MLBufferView bufferView);
@@ -1224,6 +1224,33 @@ The [=new=] {{MLGraphBuilder}} constructor steps are:
12241224
1. If the <a>validate MLContext</a> steps given |context| return `false`, throw a "{{TypeError}}" and abort these steps.
12251225
1. Set {{MLGraphBuilder/[[context]]}} to |context|.
12261226

1227+
### The {{MLGraphBuilder/input()}} method ### {#api-mlgraphbuilder-input}
1228+
Create a named {{MLOperand}} based on a descriptor, that can be used as an input.
1229+
<div class="note">
1230+
**Arguments:**
1231+
- *name*: a [=string=] name of the input.
1232+
- *descriptor*: an {{MLOperandDescriptor}} object.
1233+
**Returns:**: an {{MLOperand}} object.
1234+
</div>
1235+
<div algorithm=input>
1236+
The {{MLGraphBuilder/input(name, descriptor)}} steps are:
1237+
<div class="note">
1238+
The permissions and context validity have been checked by [[#api-mlgraphbuilder-constructor]] steps.
1239+
</div>
1240+
1. Let |name| be the first argument.
1241+
1. If |name| is `undefined` or an empty [=string=], then throw a "{{TypeError}}" {{DOMException}} and stop.
1242+
1. Let |descriptor| be the second argument.
1243+
1. If |descriptor| is not an an object that [=implements=] {{MLOperandDescriptor}}, then throw a "{{TypeError}}" {{DOMException}} and stop.
1244+
1. [=Assert=]: If |descriptor|.{{MLOperandDescriptor/dimensions}} does not [=map/exist=], then |descriptor| defines a scalar input.
1245+
1. If |descriptor|.{{MLOperandDescriptor/dimensions}} [=map/exists=]:
1246+
1. If the [=check dimensions=] steps given |descriptor|.{{MLOperandDescriptor/type}} and |descriptor|.{{MLOperandDescriptor/dimensions}} return `false`, throw a "{{DataError}}" {{DOMException}} and stop.
1247+
1. If the [=byte length=] of |descriptor| is not supported by the underlying platform, then throw a "{{DataError}}" {{DOMException}} and stop.
1248+
1. Let |operand| be the result of invoking the <a>create MLOperand</a> steps with [=this=], `"input"` and |descriptor|.
1249+
1. If that throws, re-throw the exception and stop.
1250+
1. Set |operand|.{{MLOperand/[[name]]}} to |name|.
1251+
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]]}}.
1252+
1. If that fails, throw an "{{OperationError}}" {{DOMException}} and abort these steps.
1253+
12271254
### The constant() method ### {#api-mlgraphbuilder-constant-method}
12281255
Create a constant {{MLOperand}} that can be used in {{MLGraphBuilder}} methods.
12291256

0 commit comments

Comments
 (0)