Skip to content

Commit e9f2ad2

Browse files
authored
Use "graph" name in the API (#51)
The API uses the word "graph" to describe the instantiation of an ML model. This change uses "graph" consistently where previously "model" was used.
1 parent 419a209 commit e9f2ad2

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

ml-example.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<p><code>wasi-nn</code> is a WASI API for performing machine learning (ML) inference. The API is not (yet)
33
capable of performing ML training. WebAssembly programs that want to use a host's ML
44
capabilities can access these capabilities through <code>wasi-nn</code>'s core abstractions: <em>graphs</em> and
5-
<em>tensors</em>. A user <a href="#load"><code>load</code></a>s a model -- instantiated as a <em>graph</em> -- to use in an ML <em>backend</em>.
5+
<em>tensors</em>. A user <a href="#load"><code>load</code></a>s an ML model -- instantiated as a <em>graph</em> -- to use in an ML <em>backend</em>.
66
Then, the user passes <em>tensor</em> inputs to the <em>graph</em>, computes the inference, and retrieves the
77
<em>tensor</em> outputs.</p>
88
<p>This example world shows how to use these primitives together.</p>
@@ -62,8 +62,8 @@ memory--e.g., using row-major ordering--and could perhaps be improved.</p>
6262
<li><a name="error.busy"><code>busy</code></a></li>
6363
<li><a name="error.runtime_error"><code>runtime-error</code></a></li>
6464
<li><a name="error.unsupported_operation"><code>unsupported-operation</code></a></li>
65-
<li><a name="error.model_too_large"><code>model-too-large</code></a></li>
66-
<li><a name="error.model_not_found"><code>model-not-found</code></a></li>
65+
<li><a name="error.too_large"><code>too-large</code></a></li>
66+
<li><a name="error.not_found"><code>not-found</code></a></li>
6767
</ul>
6868
<h2><a name="wasi:nn_graph">Import interface wasi:nn/graph</a></h2>
6969
<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
@@ -119,18 +119,18 @@ graph IR in parts (e.g., OpenVINO stores its IR and weights separately).</p>
119119
<ul>
120120
<li><a name="load.0"></a> result&lt;<a href="#graph"><a href="#graph"><code>graph</code></a></a>, <a href="#error"><a href="#error"><code>error</code></a></a>&gt;</li>
121121
</ul>
122-
<h4><a name="load_named_model"><code>load-named-model: func</code></a></h4>
122+
<h4><a name="load_by_name"><code>load-by-name: func</code></a></h4>
123123
<p>Load a <a href="#graph"><code>graph</code></a> by name.</p>
124124
<p>How the host expects the names to be passed and how it stores the graphs for retrieval via
125125
this function is <strong>implementation-specific</strong>. This allows hosts to choose name schemes that
126126
range from simple to complex (e.g., URLs?) and caching mechanisms of various kinds.</p>
127127
<h5>Params</h5>
128128
<ul>
129-
<li><a name="load_named_model.name"><code>name</code></a>: <code>string</code></li>
129+
<li><a name="load_by_name.name"><code>name</code></a>: <code>string</code></li>
130130
</ul>
131131
<h5>Return values</h5>
132132
<ul>
133-
<li><a name="load_named_model.0"></a> result&lt;<a href="#graph"><a href="#graph"><code>graph</code></a></a>, <a href="#error"><a href="#error"><code>error</code></a></a>&gt;</li>
133+
<li><a name="load_by_name.0"></a> result&lt;<a href="#graph"><a href="#graph"><code>graph</code></a></a>, <a href="#error"><a href="#error"><code>error</code></a></a>&gt;</li>
134134
</ul>
135135
<h2><a name="wasi:nn_inference">Import interface wasi:nn/inference</a></h2>
136136
<p>An inference &quot;session&quot; is encapsulated by a <a href="#graph_execution_context"><code>graph-execution-context</code></a>. This structure binds a

wasi-nn.witx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
$busy
1212
$runtime_error
1313
$unsupported_operation
14-
$model_too_large
15-
$model_not_found
14+
$too_large
15+
$not_found
1616
)
1717
)
1818
(typename $tensor_dimensions (list u32))
@@ -63,7 +63,7 @@
6363
(result $error (expected $graph (error $nn_errno)))
6464
)
6565
(@interface func (export "load_by_name")
66-
(param $model_name string)
66+
(param $name string)
6767
(result $error (expected $graph (error $nn_errno)))
6868
)
6969
(@interface func (export "init_execution_context")

wit/wasi-nn.wit

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package wasi:nn
33
/// `wasi-nn` is a WASI API for performing machine learning (ML) inference. The API is not (yet)
44
/// capable of performing ML training. WebAssembly programs that want to use a host's ML
55
/// capabilities can access these capabilities through `wasi-nn`'s core abstractions: _graphs_ and
6-
/// _tensors_. A user `load`s a model -- instantiated as a _graph_ -- to use in an ML _backend_.
6+
/// _tensors_. A user `load`s an ML model -- instantiated as a _graph_ -- to use in an ML _backend_.
77
/// Then, the user passes _tensor_ inputs to the _graph_, computes the inference, and retrieves the
88
/// _tensor_ outputs.
99
///
@@ -97,7 +97,7 @@ interface graph {
9797
/// How the host expects the names to be passed and how it stores the graphs for retrieval via
9898
/// this function is **implementation-specific**. This allows hosts to choose name schemes that
9999
/// range from simple to complex (e.g., URLs?) and caching mechanisms of various kinds.
100-
load-named-model: func(name: string) -> result<graph, error>
100+
load-by-name: func(name: string) -> result<graph, error>
101101
}
102102

103103
/// An inference "session" is encapsulated by a `graph-execution-context`. This structure binds a
@@ -138,11 +138,11 @@ interface errors {
138138
busy,
139139
// Runtime Error.
140140
runtime-error,
141-
// Unsupported operation
141+
// Unsupported operation.
142142
unsupported-operation,
143-
// Model too large
144-
model-too-large,
145-
// Model not found
146-
model-not-found
143+
// Graph is too large.
144+
too-large,
145+
// Graph not found.
146+
not-found
147147
}
148148
}

0 commit comments

Comments
 (0)