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

Vectorize QuantizeLinear, second stage of DynamicQuantizeLinear #538

Merged
merged 3 commits into from
Jan 16, 2025

Conversation

robertknight
Copy link
Owner

Use SIMD operations for QuantizeLinear in the f32 -> u8 case, which also forms the second stage of DynamicQuantizeLinear. This makes DQL about ~3.5x faster under AVX2.

@robertknight robertknight force-pushed the quantize-linear-simd branch 2 times, most recently from 1f39c34 to e7ee69e Compare January 16, 2025 08:52
Add SIMD operations that will be useful for implementing vectorized quantization.

To enable SIMD operations to return SIMD vectors of narrower data types, needed
by `saturating_cast_u8`, a "dummy" impl of `Simd` was added for arrays. This is
initially limited to `[u8; N]`.
@robertknight robertknight marked this pull request as ready for review January 16, 2025 09:01
@robertknight robertknight merged commit 44a3a99 into main Jan 16, 2025
2 checks passed
@robertknight robertknight deleted the quantize-linear-simd branch January 16, 2025 09:04
@robertknight
Copy link
Owner Author

The SimdInt::saturating_cast_u8 impls for wasm32 and Arm are simple versions for which the work is punted to the compiler. These might end up needing specialized implementations as exists for AVX2.

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

Successfully merging this pull request may close these issues.

1 participant