Crate rten_vecmath
source ·Expand description
rten-vecmath provides portable SIMD types for implementing vectorized functions that work across different architectures.
§Portable SIMD types
The simd_vec
module contains types and traits to support
writing portable SIMD code, that works on stable Rust.
§Supported architectures
SIMD wrappers are provided for the following architectures:
- Arm Neon
- AVX 2 / FMA
- AVX-512 (requires
avx512
feature and nightly Rust) - WebAssembly SIMD
There is also a scalar fallback that works on all platforms, but provides no performance benefit over non-SIMD code.
§Vectorized math functions
This crate contains SIMD-vectorized implementations of various math functions that are commonly used in neural networks.
For each function in this library there are multiple variants, which typically include:
- A version that operates on scalars
- A version that reads values from an input slice and writes to the
corresponding position in an equal-length output slice. These have a
vec_
prefix. - A version that reads values from a mutable input slice and writes
the computed values back in-place. These have a
vec_
prefix and_in_place
suffix.
All variants use the same underlying implementation and should have the same accuracy.
See the source code for comments on accuracy.
Modules§
- Traits to support writing portable SIMD code.
Functions§
- Computes the error function.
- Computes e^val. Functionally equivalent to f32::exp.
- Computes the sigmoid function, aka. the standard logistic function,
1. / (1. + (-x).exp())
. - Vectorized error function.
- Variant of vec_erf that modifies elements in-place.
- Vectorized exponential function.
- Variant of vec_exp that modifies elements in-place.
- Vectorized sigmoid function.
- Variant of vec_sigmoid that modifies elements in-place.
- Computes the softmax function over a slice of floats.
- Computes the softmax function over a slice of floats.
- Vectorized tanh implementation.