-
Notifications
You must be signed in to change notification settings - Fork 737
[WIP] feat: support graph encoding backend auto-detection in wasi-nn #4702
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[WIP] feat: support graph encoding backend auto-detection in wasi-nn #4702
Conversation
|
In current implementation of this PR, we assume that loading will fail if the format is not matched. Wondering whether there is an additional API for each back-end to check whether the model file is encoded in its way? |
|
How to check model file format: openvino: onnx: tensorflow: pytorch: tensorflowlite: ggml: |
9e94c9d to
44d2094
Compare
4e8212d to
08a1d08
Compare
|
i guess you should explain the motivation of auto-detection. |
The motivation is to implement auto-detect option in encoding when loading a model file. In case a binary model file without an extension is provided, or in case different types of model files are used by application user. |
| res = ensure_backend(instance, autodetect, wasi_nn_ctx); | ||
| if (res != success) | ||
| goto fail; | ||
| if (ends_with(nul_terminated_name, TFLITE_MODEL_FILE_EXT)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name here is not necessarily a filename.
see #4331
| NN_ERR_PRINTF("Model too small to be a valid TFLite file."); | ||
| return invalid_argument; | ||
| } | ||
| if (memcmp(tfl_ctx->models[*g].model_pointer + 4, "TFL3", 4) != 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
model_pointer is not even allocated at this point.
i feel it's too much for a wasm runtime to implement file format detection. |
I believe this is exactly because of wasi-nn’s design goal.
In other words, wasi-nn is intentionally trying to be model-agnostic, which is why the API does not allow specifying the backend either in load or load_by_name. So I think the intention is not to “guess” the format, but to stay consistent with the model-agnostic design and wasi-nn interface, where the runtime determines whether the provided model is supported or not. |
No description provided.