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

Wasm SIMD support #1361

Open
ulan opened this issue Mar 25, 2024 · 5 comments
Open

Wasm SIMD support #1361

ulan opened this issue Mar 25, 2024 · 5 comments

Comments

@ulan
Copy link
Contributor

ulan commented Mar 25, 2024

Wasm SIMD is a stable feature that is supported by many Wasm runtimes. It is available in Rust in core::arch::wasm32.

I have two questions to the maintainers:

  1. Do you have plans to implement Wasm SIMD support?
  2. Would you accept an external contribution that implements support for Wasm SIMD?
@kali
Copy link
Collaborator

kali commented Mar 25, 2024

  1. this is not an active topic for us
  2. yes

@ulan
Copy link
Contributor Author

ulan commented Mar 25, 2024

Would you accept an external contribution that implements support for Wasm SIMD?
yes

Great, thanks! I am learning the source code of tract and my current understanding is to add linalg/wasm and follow one of the existing SIMD implementations. Do you have any suggestions or thing to look out for when implementing?

How would you approach this on the high-level if you were to implement Wasm SIMD?

@kali
Copy link
Collaborator

kali commented Mar 25, 2024

You should try to produce a square-ish mat * mul (m=n) implementation, and also a mat * vec (n=1).

You should be able leverage the tests available for the others products. Start implementing return_zero, return_c, the add/mul by row and cols: these are the one that will cover the load and store functions. Do the actual dot product at the end.

Have fun! And feel free to ask any question.

@kali
Copy link
Collaborator

kali commented Mar 25, 2024

Depending on your familiarity of efficient mat mul implemetation, you may want to check out the sonos tech blog articles (https://tech-blog.sonos.com/posts/the-anatomy-of-efficient-matrix-multipliers/ and part 3).

For tile sizes, I would probably start with 8x8 (easy to map to aarch64 and intel) and 32x1 for mat vec.

@ulan
Copy link
Contributor Author

ulan commented Mar 26, 2024

Thank you for the pointers @kali!

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

2 participants