-
Notifications
You must be signed in to change notification settings - Fork 59
Closed
Description
Purpose/Motivation
Provides a means to execute a MLGraph using MLBuffer. This is a sub-issue of #482.
Proposed API
dictionary MLBufferView {
required MLBuffer buffer;
MLSize64 offset = 0;
MLSize64 size;
};
typedef record<DOMString, MLBufferView> MLNamedMLBufferViews;
[Exposed=(Window, DedicatedWorker), SecureContext]
partial interface MLContext {
undefined dispatch(
MLGraph graph, MLNamedMLBufferViews inputs, MLNamedMLBufferViews outputs);
}Example JS
const bufferA = new MLBuffer({size:4});
const bufferB = new MLBuffer({size:4});
const inputs = {'A': {bufferA, 0, bufferA.size()};
const outputs = {'B': {bufferB, 0, bufferB.size()};
context.dispatch(graph, inputs, outputs);- Enqueues a request to compute the graph onto some WebNN timeline
- Execution cannot start until all input and output MLBuffers are available
- All input and output MLBuffers are unavailable while execution is in progress
- All work submitted after this dispatch() call which relies on an input or output MLBuffer will be queued behind this execution
Alternative API proposals
N/A
Opens
- Should this method be on the MLGraph (related to API simplification: context owns builder, graph becomes internal slot #303)? @a-sully
- Is it valid to pass the same MLBuffer as both an input and output of the same dispatch() call? @a-sully
- If the approach is flexible enough to allow for graph execution on all backends. Do we need a separate compute() method? @a-sully
- Can dispatch be exclusive to MLBuffer bindings? @bbernhar
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels