From efe75ab0e3e479ede482c86bd308558816b97fa0 Mon Sep 17 00:00:00 2001 From: charles-r-earp Date: Sun, 3 Mar 2024 16:22:11 -0800 Subject: [PATCH] fix target-feature --- src/learn/neural_network/layer/conv_direct.rs | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/src/learn/neural_network/layer/conv_direct.rs b/src/learn/neural_network/layer/conv_direct.rs index f6648810..5e153f70 100644 --- a/src/learn/neural_network/layer/conv_direct.rs +++ b/src/learn/neural_network/layer/conv_direct.rs @@ -757,15 +757,13 @@ fn conv2_direct_host_f32( ) -> Array4 { #[allow(unused_mut, unused_assignments)] const fn twy_for_tby(tby: usize) -> usize { - #[cfg(target_feature = "avx")] - { - twy = 15 / (tby + 2); - } - #[cfg(target_feature = "fma")] - { - twy = 15 / (tby + 1); + if cfg!(target_feature = "fma") { + 15 / (tby + 1) + } else if cfg!(target_feature = "avx") { + 15 / (tby + 2) + } else { + 15 / (2 * (tby + 2)) } - 15 / (2 * (tby + 2)) } #[allow(clippy::too_many_arguments)] @@ -1155,17 +1153,14 @@ fn conv2_direct_backward_weight_host_f32( options: &Conv2Options, weight_shape: [usize; 4], ) -> Array4<[f32x8; TCX]> { - #[allow(unused_mut, unused_assignments)] const fn tw_for_tby(tby: usize) -> usize { - #[cfg(target_feature = "avx")] - { - tw = 15 / (tby + 2); - } - #[cfg(target_feature = "fma")] - { - tw = 15 / (tby + 1); + if cfg!(target_feature = "fma") { + 15 / (tby + 1) + } else if cfg!(target_feature = "avx") { + 15 / (tby + 2) + } else { + 15 / (2 * tby + 2) } - 15 / (2 * tby + 2) } fn inner(