From df7860b4f37b98c322c40471f3129fa93c7b5b70 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sun, 3 Mar 2024 13:47:42 +0800 Subject: [PATCH] =?UTF-8?q?simd=E5=AE=8C=E6=B4=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/evaluate.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/evaluate.rs b/src/evaluate.rs index 20266fa..c10ffbb 100644 --- a/src/evaluate.rs +++ b/src/evaluate.rs @@ -255,6 +255,8 @@ const INTERCEPT: f64 = 743.345708241252; #[cfg(feature = "simd")] use std::simd::f64x64; +#[cfg(feature = "simd")] +use std::simd::num::SimdFloat; use crate::name::Namer; @@ -311,7 +313,15 @@ pub fn predict(name: &Namer) -> f64 { sum += simd_module.0[i] * simd_target.0[i]; } // 主! 体! - + let mut tmp = f64x64::splat(0.0); + for i in 0..simd_module.1.len() { + tmp += simd_module.1[i] * simd_target.1[i]; + } + sum += tmp.reduce_sum(); + // 后面多出来的 + for i in 0..simd_module.2.len() { + sum += simd_module.2[i] * simd_target.2[i]; + } } #[cfg(not(feature = "simd"))] {