@@ -32,17 +32,18 @@ interface ML {
32
32
Promise<MLContext> createContext(GPUDevice gpuDevice);
33
33
};
34
34
35
- typedef record<USVString, ArrayBufferView> MLNamedArrayBufferViews;
36
-
37
- dictionary MLComputeResult {
38
- MLNamedArrayBufferViews inputs;
39
- MLNamedArrayBufferViews outputs;
40
- };
35
+ typedef record<USVString, MLTensor> MLNamedTensors;
41
36
42
37
[SecureContext, Exposed=(Window, DedicatedWorker)]
43
38
interface MLContext {
44
- Promise<MLComputeResult> compute(
45
- MLGraph graph, MLNamedArrayBufferViews inputs, MLNamedArrayBufferViews outputs);
39
+ undefined dispatch(MLGraph graph, MLNamedTensors inputs, MLNamedTensors outputs);
40
+
41
+ Promise<MLTensor> createTensor(MLTensorDescriptor descriptor);
42
+
43
+ Promise<ArrayBuffer> readTensor(MLTensor tensor);
44
+ Promise<undefined> readTensor(MLTensor tensor, AllowSharedBufferSource outputData);
45
+
46
+ undefined writeTensor(MLTensor tensor, AllowSharedBufferSource inputData);
46
47
47
48
MLOpSupportLimits opSupportLimits();
48
49
};
@@ -105,6 +106,21 @@ dictionary MLOperatorOptions {
105
106
106
107
typedef (bigint or unrestricted double) MLNumber;
107
108
109
+ dictionary MLTensorDescriptor : MLOperandDescriptor {
110
+ boolean readable = false;
111
+ boolean writable = false;
112
+ };
113
+
114
+ [SecureContext, Exposed=(Window, DedicatedWorker)]
115
+ interface MLTensor {
116
+ readonly attribute MLOperandDataType dataType;
117
+ readonly attribute FrozenArray<unsigned long> shape;
118
+ readonly attribute boolean readable;
119
+ readonly attribute boolean writable;
120
+
121
+ undefined destroy();
122
+ };
123
+
108
124
typedef record<USVString, MLOperand> MLNamedOperands;
109
125
110
126
[SecureContext, Exposed=(Window, DedicatedWorker)]
@@ -116,7 +132,8 @@ interface MLGraphBuilder {
116
132
MLOperand input(USVString name, MLOperandDescriptor descriptor);
117
133
118
134
// Create an operand for a graph constant.
119
- MLOperand constant(MLOperandDescriptor descriptor, ArrayBufferView bufferView);
135
+ MLOperand constant(MLOperandDescriptor descriptor,
136
+ AllowSharedBufferSource buffer);
120
137
121
138
// Create a scalar operand from the specified number of the specified type.
122
139
MLOperand constant(MLOperandDataType type, MLNumber value);
0 commit comments