Skip to content
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

Runtime metadata construction #140

Closed
FL33TW00D opened this issue Mar 26, 2024 · 2 comments
Closed

Runtime metadata construction #140

FL33TW00D opened this issue Mar 26, 2024 · 2 comments

Comments

@FL33TW00D
Copy link
Collaborator

Some operations require their metadata struct to be constructed at runtime (we don't know the size of the metadata struct at compile time).

Concat is a good example, as there may be $0..n$ tensors being concatenated.
Therefore, we need some way of building the struct at runtime, whilst ensuring that we maintain the correct WGSL memory layout (play around here: https://webgpufundamentals.org/webgpu/lessons/resources/wgsl-offset-computer.html).

I'm currently thinking of the following:

use indexmap::IndexMap;
pub struct MetaMap(IndexMap<K, V, S = RandomState>)
where V: encase::ShaderSize

We can then convert this into a [u8] with members padded and offset correctly.

We would have needed to do this when we were JITting anyway.

@FL33TW00D
Copy link
Collaborator Author

FL33TW00D commented Mar 27, 2024

Better solution: teoxoy/encase#46

Field rearranging would be interesting here, but it would save a few bytes, not worth it.

@FL33TW00D
Copy link
Collaborator Author

#137 solved, but isn't perfect. Thanks to @cwfitzgerald for the PR on encase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant