-
Notifications
You must be signed in to change notification settings - Fork 82
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
Allow non-canonical type alignment? #258
Comments
In theory, yes, it makes sense and seems complementary to what we were talking about in #194, and maybe belongs as part of the same feature. Just to help me understand the motivation (and see if there's a short-term workaround): what's the reason for using a |
Well, the |
Yeah, I was asking about having a separate |
Yeah, I don't think I'm in a terrible hurry so I can see two options: (a) use [edit: I'm kind of asking, do you just want me to submit a PR for this kind of thing or do you think more thought/discussion is needed?] |
(sorry for the delay; back from the wasm CG meeting) That's a good question; thanks for asking. Given that Preview 2 is almost done and there's not really time to make a significant addition like this, I think it's probably a good idea to go with approach (a), so that you can produce a nice working Preview 2 interface without waiting on anything else, and then we can include this issue as a use case for a possible Preview 3-or-after feature addition to the C-M/WIT that would improve the quality/ergonomics of the existing working interface. |
Over in wasi-nn, we have been wondering whether there might be a way to specify an alignment for a type larger than the one specified by the canonical ABI. This is similar to what @titzer brings up in #194 but I thought it was different enough to merit its own issue.
wasi-nn currently specifies the tensor data as
list<u8>
(WIT). The initial rationale (long ago, back in the WITX days) was a performance consideration: ML frameworks can deal with tensor data as byte blobs and if we can just "pass the bytes through" we can avoid some extra copies. This means that when we, as a wasi-nn guest user, receive tensor data back we must convert it somehow fromlist<u8>
tolist<f64>
, e.g. This conversion is an unsafe cast in some of the bindings — what if thelist<u8>
is not aligned to cast tolist<f64>
? There has been an outstanding issue (WebAssembly/wasi-nn#27) to figure this out. One solution would be to always copy the data; another to conditionally copy the data only if unaligned; etc.The solution I'm asking about here is adding some way to inform the runtime of the alignment we would like when allocating space for the tensor data. Is this possible? Is it different enough from what @titzer is asking? I suspect we would only want to allow allocations for alignments larger than what the canonical ABI specifies, but maybe not.
The text was updated successfully, but these errors were encountered: