pub struct SIMDOptimizer { /* private fields */ }Expand description
SIMD operations for optimizer kernels
Implementations§
Source§impl SIMDOptimizer
impl SIMDOptimizer
Sourcepub fn new(config: SIMDConfig) -> Self
pub fn new(config: SIMDConfig) -> Self
Create a new SIMD optimizer with configuration
Sourcepub fn detect_capabilities() -> SIMDConfig
pub fn detect_capabilities() -> SIMDConfig
Detect available SIMD instruction sets
Sourcepub unsafe fn adam_update_avx2(
&self,
params: &mut [f32],
gradients: &[f32],
momentum: &mut [f32],
velocity: &mut [f32],
lr: f32,
beta1: f32,
beta2: f32,
eps: f32,
step: i32,
) -> Result<()>
pub unsafe fn adam_update_avx2( &self, params: &mut [f32], gradients: &[f32], momentum: &mut [f32], velocity: &mut [f32], lr: f32, beta1: f32, beta2: f32, eps: f32, step: i32, ) -> Result<()>
SIMD-optimized Adam update with AVX2
§Safety
Caller must ensure the CPU supports AVX2 instructions. This is guaranteed
when the function is invoked via the #[target_feature(enable = "avx2")]
dispatch path only on hardware where the feature is available.
Sourcepub unsafe fn adamw_update_avx2(
&self,
params: &mut [f32],
gradients: &[f32],
momentum: &mut [f32],
velocity: &mut [f32],
lr: f32,
beta1: f32,
beta2: f32,
eps: f32,
weight_decay: f32,
step: i32,
) -> Result<()>
pub unsafe fn adamw_update_avx2( &self, params: &mut [f32], gradients: &[f32], momentum: &mut [f32], velocity: &mut [f32], lr: f32, beta1: f32, beta2: f32, eps: f32, weight_decay: f32, step: i32, ) -> Result<()>
SIMD-optimized AdamW update with AVX2 (decoupled weight decay)
§Safety
Caller must ensure the CPU supports AVX2 instructions. This is guaranteed
when the function is invoked via the #[target_feature(enable = "avx2")]
dispatch path only on hardware where the feature is available.
Sourcepub unsafe fn sgd_momentum_update_avx2(
&self,
params: &mut [f32],
gradients: &[f32],
momentum: &mut [f32],
lr: f32,
momentum_factor: f32,
weight_decay: f32,
nesterov: bool,
) -> Result<()>
pub unsafe fn sgd_momentum_update_avx2( &self, params: &mut [f32], gradients: &[f32], momentum: &mut [f32], lr: f32, momentum_factor: f32, weight_decay: f32, nesterov: bool, ) -> Result<()>
SIMD-optimized SGD with momentum update
§Safety
Caller must ensure the CPU supports AVX2 instructions. This is guaranteed
when the function is invoked via the #[target_feature(enable = "avx2")]
dispatch path only on hardware where the feature is available.
Sourcepub unsafe fn clip_gradients_avx2(
&self,
gradients: &mut [f32],
max_norm: f32,
) -> Result<f32>
pub unsafe fn clip_gradients_avx2( &self, gradients: &mut [f32], max_norm: f32, ) -> Result<f32>
SIMD-optimized gradient clipping
§Safety
Caller must ensure the CPU supports AVX2 instructions. This is guaranteed
when the function is invoked via the #[target_feature(enable = "avx2")]
dispatch path only on hardware where the feature is available.
Sourcepub unsafe fn vector_add_avx2(
&self,
a: &mut [f32],
b: &[f32],
scale: f32,
) -> Result<()>
pub unsafe fn vector_add_avx2( &self, a: &mut [f32], b: &[f32], scale: f32, ) -> Result<()>
SIMD-optimized vector addition (for gradient accumulation)
§Safety
Caller must ensure the CPU supports AVX2 instructions. This is guaranteed
when the function is invoked via the #[target_feature(enable = "avx2")]
dispatch path only on hardware where the feature is available.
Sourcepub unsafe fn dot_product_avx2(&self, a: &[f32], b: &[f32]) -> Result<f32>
pub unsafe fn dot_product_avx2(&self, a: &[f32], b: &[f32]) -> Result<f32>
SIMD-optimized dot product
§Safety
Caller must ensure the CPU supports AVX2 instructions. This is guaranteed
when the function is invoked via the #[target_feature(enable = "avx2")]
dispatch path only on hardware where the feature is available.
Sourcepub fn adam_update_fallback(
&self,
params: &mut [f32],
gradients: &[f32],
momentum: &mut [f32],
velocity: &mut [f32],
lr: f32,
beta1: f32,
beta2: f32,
eps: f32,
step: i32,
) -> Result<()>
pub fn adam_update_fallback( &self, params: &mut [f32], gradients: &[f32], momentum: &mut [f32], velocity: &mut [f32], lr: f32, beta1: f32, beta2: f32, eps: f32, step: i32, ) -> Result<()>
Fallback implementations for non-x86 architectures
Sourcepub fn adam_update(
&self,
params: &mut [f32],
gradients: &[f32],
momentum: &mut [f32],
velocity: &mut [f32],
lr: f32,
beta1: f32,
beta2: f32,
eps: f32,
step: i32,
) -> Result<()>
pub fn adam_update( &self, params: &mut [f32], gradients: &[f32], momentum: &mut [f32], velocity: &mut [f32], lr: f32, beta1: f32, beta2: f32, eps: f32, step: i32, ) -> Result<()>
Auto-dispatch to best available implementation
Sourcepub fn adamw_update(
&self,
params: &mut [f32],
gradients: &[f32],
momentum: &mut [f32],
velocity: &mut [f32],
lr: f32,
beta1: f32,
beta2: f32,
eps: f32,
weight_decay: f32,
step: i32,
) -> Result<()>
pub fn adamw_update( &self, params: &mut [f32], gradients: &[f32], momentum: &mut [f32], velocity: &mut [f32], lr: f32, beta1: f32, beta2: f32, eps: f32, weight_decay: f32, step: i32, ) -> Result<()>
Auto-dispatch AdamW
Sourcepub fn get_performance_info(&self) -> SIMDPerformanceInfo
pub fn get_performance_info(&self) -> SIMDPerformanceInfo
Get performance statistics
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SIMDOptimizer
impl RefUnwindSafe for SIMDOptimizer
impl Send for SIMDOptimizer
impl Sync for SIMDOptimizer
impl Unpin for SIMDOptimizer
impl UnsafeUnpin for SIMDOptimizer
impl UnwindSafe for SIMDOptimizer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more