Currently, compute() calls validate graph resources with the passed input (or output) maps and the graph's input (or output) descriptors.
I believe the intent is to ensure that all of a graph's input (or output) descriptors are matched to a (name, buffer) pair in the passed input (or output) resources.
The steps are:
To validate graph resources, given MLNamedArrayBufferViews resources and ordered map descriptors, run the following steps:
For each name → resource of resources:
If descriptors[name] does not exist, return false.
If validating buffer with descriptor given resource and descriptors[name] returns false, then return false.
Return true.
This instead seems to be ensuring that each (name, buffer) pair in the passed resources has a corresponding input (or output) descriptor - which is similar but backwards.
i.e.
const builder = new MLGraphBuilder(context);
const input1 = builder.input('input1', desc1);
const input2 = builder.input('input2', desc2);
const output1 = builder.mul(input1, input2);
const graph = await builder.build({'output1': output1});
// graph has two inputs (input1, input2) and one output (output1)
// Expected usage
await context.compute(graph, {input1: inbuf1, input2: inbuf2}, {output1: outbuf1});
// Should fail, because input2 is missing - but it *doesn't*.
await context.compute(graph, {input1: inbuf1}, {output1: outbuf1});
// Maybe fail, because output2 is passed but unused. Currently it *does* fail.
await context.compute(graph, {input1: inbuf1, input2: inbuf2}, {output1: outbuf1, output2: outbuf2});
It seems like we've got two options:
Invert the test - iterate over the descriptors, and verify that there are matching resources
Make the test reflexive - the set of expected and passed resources must exactly match
Currently, compute() calls validate graph resources with the passed input (or output) maps and the graph's input (or output) descriptors.
I believe the intent is to ensure that all of a graph's input (or output) descriptors are matched to a (name, buffer) pair in the passed input (or output) resources.
The steps are:
This instead seems to be ensuring that each (name, buffer) pair in the passed resources has a corresponding input (or output) descriptor - which is similar but backwards.
i.e.
It seems like we've got two options: