You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let preload = "default:CPU:GGML:llama-2-7b-chat.Q5_K_M.gguf";
121
+
let result = NNPreload::from_str(preload);
122
+
assert!(result.is_err());
123
+
let err = result.unwrap_err();
124
+
assert_eq!(
125
+
WasmEdgeError::Operation(
126
+
"Failed to convert to NNBackend value. Unknown NNBackend type: CPU".to_string()
127
+
),
128
+
err
129
+
);
130
+
131
+
// invalid preload string: unsupported target
132
+
let preload = "default:GGML:NPU:llama-2-7b-chat.Q5_K_M.gguf";
133
+
let result = NNPreload::from_str(preload);
134
+
assert!(result.is_err());
135
+
let err = result.unwrap_err();
136
+
assert_eq!(
137
+
WasmEdgeError::Operation(
138
+
"Failed to convert to ExecutionTarget value. Unknown ExecutionTarget type: NPU"
139
+
.to_string()
140
+
),
141
+
err
142
+
);
143
+
144
+
// invalid preload string: invalid format
145
+
let preload = "default:GGML:CPU";
146
+
let result = NNPreload::from_str(preload);
147
+
assert!(result.is_err());
148
+
let err = result.unwrap_err();
149
+
assert_eq!(
150
+
WasmEdgeError::Operation(
151
+
"Failed to convert to NNPreload value. Invalid preload string: default:GGML:CPU. The correct format is: 'alias:backend:target:path'"
152
+
.to_string()
153
+
),
154
+
err
155
+
);
156
+
}
60
157
61
158
/// Describes the encoding of the graph.
62
159
#[cfg(feature = "wasi_nn")]
@@ -160,7 +257,7 @@ impl PluginManager {
160
257
/// * If the path is not given, then the default plugin paths will be used. The default plugin paths are
161
258
///
162
259
/// * The environment variable "WASMEDGE_PLUGIN_PATH".
163
-
///
260
+
///
164
261
/// * The `../plugin/` directory related to the WasmEdge installation path.
165
262
///
166
263
/// * The `wasmedge/` directory under the library path if the WasmEdge is installed under the "/usr".
@@ -184,6 +281,39 @@ impl PluginManager {
184
281
}
185
282
}
186
283
284
+
/// Initialize the wasi_nn plug-in with the preloads.
285
+
///
286
+
/// Note that this function is only available after loading the wasi_nn plug-in and before creating, and before creating the module instance from the plug-in.
287
+
///
288
+
/// # Argument
289
+
///
290
+
/// * `preloads` - The preload list.
291
+
///
292
+
/// # Example
293
+
///
294
+
/// ```ignore
295
+
/// // load wasinn-pytorch-plugin from the default plugin directory: /usr/local/lib/wasmedge
0 commit comments