Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions ml.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,44 @@ graph IR in parts (e.g., OpenVINO stores its IR and weights separately).</p>
<ul>
<li><a name="method_graph_init_execution_context.0"></a> result&lt;own&lt;<a href="#graph_execution_context"><a href="#graph_execution_context"><code>graph-execution-context</code></a></a>&gt;, own&lt;<a href="#error"><a href="#error"><code>error</code></a></a>&gt;&gt;</li>
</ul>
<h4><a name="method_graph_list_properties"></a><code>[method]graph.list-properties: func</code></h4>
<p>Retrieve the properties of the graph.</p>
<p>These are metadata about the graph, unique to the graph and the
ML backend providing it.</p>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this something supposed to be used to query zero_point/scale?

anyway the description seems too abstract. it would be nicer to give a few examples.

<h5>Params</h5>
<ul>
<li><a name="method_graph_list_properties.self"></a><code>self</code>: borrow&lt;<a href="#graph"><a href="#graph"><code>graph</code></a></a>&gt;</li>
</ul>
<h5>Return values</h5>
<ul>
<li><a name="method_graph_list_properties.0"></a> list&lt;<code>string</code>&gt;</li>
</ul>
<h4><a name="method_graph_get_property"></a><code>[method]graph.get-property: func</code></h4>
<p>Retrieve the value of a property.</p>
<p>If the property does not exist, this function returns <code>none</code>.</p>
<h5>Params</h5>
<ul>
<li><a name="method_graph_get_property.self"></a><code>self</code>: borrow&lt;<a href="#graph"><a href="#graph"><code>graph</code></a></a>&gt;</li>
<li><a name="method_graph_get_property.name"></a><code>name</code>: <code>string</code></li>
</ul>
<h5>Return values</h5>
<ul>
<li><a name="method_graph_get_property.0"></a> option&lt;<code>string</code>&gt;</li>
</ul>
<h4><a name="method_graph_set_property"></a><code>[method]graph.set-property: func</code></h4>
<p>Modify the value of a property.</p>
<p>If the operation fails, this function returns a string from the ML
backend describing the error.</p>
<h5>Params</h5>
<ul>
<li><a name="method_graph_set_property.self"></a><code>self</code>: borrow&lt;<a href="#graph"><a href="#graph"><code>graph</code></a></a>&gt;</li>
<li><a name="method_graph_set_property.name"></a><code>name</code>: <code>string</code></li>
<li><a name="method_graph_set_property.value"></a><code>value</code>: <code>string</code></li>
</ul>
<h5>Return values</h5>
<ul>
<li><a name="method_graph_set_property.0"></a> result&lt;_, <code>string</code>&gt;</li>
</ul>
<h4><a name="load"></a><code>load: func</code></h4>
<p>Load a <a href="#graph"><code>graph</code></a> from an opaque sequence of bytes to use for inference.</p>
<h5>Params</h5>
Expand Down
17 changes: 17 additions & 0 deletions wit/wasi-nn.wit
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,23 @@ interface graph {
/// An execution graph for performing inference (i.e., a model).
resource graph {
init-execution-context: func() -> result<graph-execution-context, error>;

/// Retrieve the properties of the graph.
///
/// These are metadata about the graph, unique to the graph and the
/// ML backend providing it.
list-properties: func() -> list<string>;

/// Retrieve the value of a property.
///
/// If the property does not exist, this function returns `none`.
get-property: func(name: string) -> option<string>;

/// Modify the value of a property.
///
/// If the operation fails, this function returns a string from the ML
/// backend describing the error.
set-property: func(name: string, value: string) -> result<_, string>;
}

/// Describes the encoding of the graph. This allows the API to be implemented by various
Expand Down