-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
wasi-nn: remove BackendKind
, add wrapper struct
s
#6893
Merged
Merged
Conversation
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
The wasi-nn crate uses virtual dispatch to handle different kinds of backends and registries. For easier use, these items are now wrapped in their own `Box<dyn ...>` structs.
This change completely removes the `BackendKind` enum, which uniquely listed the kinds of backends that the wasi-nn crate contained. Since we allow many kinds of backends in `WasiNnCtx` which can be implemented even outside the crate, this `BackendKind` enum no longer makes sense. This change uses `GraphEncoding` instead.
alexcrichton
approved these changes
Aug 24, 2023
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.
Nothing looks obviously wrong here to me but I'm not super familiar with the NN stuff of wasi-nn. It sounds like you're ok with that though so feel free to merge with my cursory review of "seems fine"
eduardomourar
pushed a commit
to eduardomourar/wasmtime
that referenced
this pull request
Sep 6, 2023
…e#6893) * wasi-nn: accept a list of backends instead of a hash map * wasi-nn: refactor with new `Backend` and `Registry` wrappers The wasi-nn crate uses virtual dispatch to handle different kinds of backends and registries. For easier use, these items are now wrapped in their own `Box<dyn ...>` structs. * wasi-nn: completely remove `BackendKind` This change completely removes the `BackendKind` enum, which uniquely listed the kinds of backends that the wasi-nn crate contained. Since we allow many kinds of backends in `WasiNnCtx` which can be implemented even outside the crate, this `BackendKind` enum no longer makes sense. This change uses `GraphEncoding` instead. * nit: move `pub mod backend` with other exports prtest:full * fix: remove broken doc links
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
One improvement that came from discussions with @geekbeast is that
BackendKind
, the enum used for differentiating between ML implementation, is no longer necessary. Instead, we can use the generatedGraphEncoding
type as the key to map to the right implementation.Also, this PR adopts the
Wrapper(Box<dyn ...>)
pattern everywhere, which now includes backends and registries. Since wasi-nn accepts multiple implementations for all of these things, we need a way to virtually dispatch to the right implementation. Previously we used theBox<dyn ...>
type explicitly in many places but this change opts to use a wrapper around this, expecting users to create the wrapper viaFrom
andInto
and internally accessing the implementation viaDeref
andDerefMut
. The idea is to eliminate some of the "type clutter;" let me know if you agree.