-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
As discussed in #43, there is no requirement to set up tensors prior to calling `compute` as well as retrieving them separately afterwards. As of #59, passing around tensors is cheap (they're resources now), so there is no data copy necessary if we adopt this PR. This change proposes removing the `set-input` and `get-output` functions, moving all of the tensor-passing to `compute`. Closes #43.
- Loading branch information
Showing
2 changed files
with
17 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -169,49 +169,29 @@ e.g., cannot access a hardware feature requested | |
#### <a name="tensor"></a>`type tensor` | ||
[`tensor`](#tensor) | ||
<p> | ||
#### <a name="tensor_data"></a>`type tensor-data` | ||
[`tensor-data`](#tensor_data) | ||
<p> | ||
#### <a name="graph_execution_context"></a>`resource graph-execution-context` | ||
#### <a name="named_tensor"></a>`tuple named-tensor` | ||
<p>Identify a tensor by name; this is necessary to associate tensors to | ||
graph inputs and outputs.</p> | ||
<h5>Tuple Fields</h5> | ||
<ul> | ||
<li><a name="named_tensor.0"></a><code>0</code>: <code>string</code></li> | ||
<li><a name="named_tensor.1"></a><code>1</code>: own<<a href="#tensor"><a href="#tensor"><code>tensor</code></a></a>></li> | ||
</ul> | ||
<h4><a name="graph_execution_context"></a><code>resource graph-execution-context</code></h4> | ||
<p>Bind a <a href="#graph"><code>graph</code></a> to the input and output tensors for an inference.</p> | ||
<h2>TODO: this may no longer be necessary in WIT | ||
(https://github.com/WebAssembly/wasi-nn/issues/43)</h2> | ||
<h3>Functions</h3> | ||
<h4><a name="method_graph_execution_context_set_input"></a><code>[method]graph-execution-context.set-input: func</code></h4> | ||
<p>Define the inputs to use for inference.</p> | ||
<h5>Params</h5> | ||
<ul> | ||
<li><a name="method_graph_execution_context_set_input.self"></a><code>self</code>: borrow<<a href="#graph_execution_context"><a href="#graph_execution_context"><code>graph-execution-context</code></a></a>></li> | ||
<li><a name="method_graph_execution_context_set_input.name"></a><code>name</code>: <code>string</code></li> | ||
<li><a name="method_graph_execution_context_set_input.tensor"></a><a href="#tensor"><code>tensor</code></a>: own<<a href="#tensor"><a href="#tensor"><code>tensor</code></a></a>></li> | ||
</ul> | ||
<h5>Return values</h5> | ||
<ul> | ||
<li><a name="method_graph_execution_context_set_input.0"></a> result<_, own<<a href="#error"><a href="#error"><code>error</code></a></a>>></li> | ||
</ul> | ||
<h4><a name="method_graph_execution_context_compute"></a><code>[method]graph-execution-context.compute: func</code></h4> | ||
<p>Compute the inference on the given inputs.</p> | ||
<p>Note the expected sequence of calls: <code>set-input</code>, <code>compute</code>, <code>get-output</code>. TODO: this | ||
expectation could be removed as a part of | ||
https://github.com/WebAssembly/wasi-nn/issues/43.</p> | ||
<h5>Params</h5> | ||
<ul> | ||
<li><a name="method_graph_execution_context_compute.self"></a><code>self</code>: borrow<<a href="#graph_execution_context"><a href="#graph_execution_context"><code>graph-execution-context</code></a></a>></li> | ||
<li><a name="method_graph_execution_context_compute.inputs"></a><code>inputs</code>: list<<a href="#named_tensor"><a href="#named_tensor"><code>named-tensor</code></a></a>></li> | ||
</ul> | ||
<h5>Return values</h5> | ||
<ul> | ||
<li><a name="method_graph_execution_context_compute.0"></a> result<_, own<<a href="#error"><a href="#error"><code>error</code></a></a>>></li> | ||
</ul> | ||
<h4><a name="method_graph_execution_context_get_output"></a><code>[method]graph-execution-context.get-output: func</code></h4> | ||
<p>Extract the outputs after inference.</p> | ||
<h5>Params</h5> | ||
<ul> | ||
<li><a name="method_graph_execution_context_get_output.self"></a><code>self</code>: borrow<<a href="#graph_execution_context"><a href="#graph_execution_context"><code>graph-execution-context</code></a></a>></li> | ||
<li><a name="method_graph_execution_context_get_output.name"></a><code>name</code>: <code>string</code></li> | ||
</ul> | ||
<h5>Return values</h5> | ||
<ul> | ||
<li><a name="method_graph_execution_context_get_output.0"></a> result<own<<a href="#tensor"><a href="#tensor"><code>tensor</code></a></a>>, own<<a href="#error"><a href="#error"><code>error</code></a></a>>></li> | ||
<li><a name="method_graph_execution_context_compute.0"></a> result<list<<a href="#named_tensor"><a href="#named_tensor"><code>named-tensor</code></a></a>>, own<<a href="#error"><a href="#error"><code>error</code></a></a>>></li> | ||
</ul> | ||
<h2><a name="wasi_nn_graph_0_2_0_rc_2024_08_19"></a>Import interface wasi:nn/[email protected]</h2> | ||
<p>A <a href="#graph"><code>graph</code></a> is a loaded instance of a specific ML model (e.g., MobileNet) for a specific ML | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters