11use super :: { LARGE_COST , OptimizationLossMetric , positive_x} ;
22
3- #[ cfg( feature = "portable-simd" ) ]
43const MAX_POLYNOMIAL_PARAMS : usize = 10 ;
54
6- #[ cfg( feature = "portable-simd" ) ]
75#[ cfg( not( target_arch = "wasm32" ) ) ]
86type Vf64 = std:: simd:: f64x8 ;
9- #[ cfg( feature = "portable-simd" ) ]
107#[ cfg( target_arch = "wasm32" ) ]
118type Vf64 = std:: simd:: f64x2 ;
129
13- #[ cfg( feature = "portable-simd" ) ]
1410use std:: simd:: Select ;
15- #[ cfg( feature = "portable-simd" ) ]
1611use std:: simd:: StdFloat ;
17- #[ cfg( feature = "portable-simd" ) ]
1812use std:: simd:: cmp:: SimdPartialOrd ;
19- #[ cfg( feature = "portable-simd" ) ]
2013use std:: simd:: num:: SimdFloat ;
2114
2215pub ( super ) fn polynomial_cost (
@@ -25,14 +18,7 @@ pub(super) fn polynomial_cost(
2518 y_values : & [ f64 ] ,
2619 loss_metric : OptimizationLossMetric ,
2720) -> f64 {
28- #[ cfg( feature = "portable-simd" ) ]
29- {
30- polynomial_cost_simd ( param, x_values, y_values, loss_metric)
31- }
32- #[ cfg( not( feature = "portable-simd" ) ) ]
33- {
34- polynomial_cost_scalar ( param, x_values, y_values, loss_metric)
35- }
21+ polynomial_cost_simd ( param, x_values, y_values, loss_metric)
3622}
3723
3824pub ( super ) fn inverse_cost (
@@ -41,14 +27,7 @@ pub(super) fn inverse_cost(
4127 y_values : & [ f64 ] ,
4228 loss_metric : OptimizationLossMetric ,
4329) -> f64 {
44- #[ cfg( feature = "portable-simd" ) ]
45- {
46- inverse_cost_simd ( param, x_values, y_values, loss_metric)
47- }
48- #[ cfg( not( feature = "portable-simd" ) ) ]
49- {
50- inverse_cost_scalar ( param, x_values, y_values, loss_metric)
51- }
30+ inverse_cost_simd ( param, x_values, y_values, loss_metric)
5231}
5332
5433pub ( super ) fn accumulate_polynomial_gradient (
@@ -58,14 +37,7 @@ pub(super) fn accumulate_polynomial_gradient(
5837 loss_metric : OptimizationLossMetric ,
5938 gradient : & mut [ f64 ] ,
6039) {
61- #[ cfg( feature = "portable-simd" ) ]
62- {
63- accumulate_polynomial_gradient_simd ( x_values, y_values, param, loss_metric, gradient) ;
64- }
65- #[ cfg( not( feature = "portable-simd" ) ) ]
66- {
67- accumulate_polynomial_gradient_scalar ( x_values, y_values, param, loss_metric, gradient) ;
68- }
40+ accumulate_polynomial_gradient_simd ( x_values, y_values, param, loss_metric, gradient) ;
6941}
7042
7143pub ( super ) fn accumulate_inverse_gradient (
@@ -75,14 +47,7 @@ pub(super) fn accumulate_inverse_gradient(
7547 loss_metric : OptimizationLossMetric ,
7648 gradient : & mut [ f64 ] ,
7749) {
78- #[ cfg( feature = "portable-simd" ) ]
79- {
80- accumulate_inverse_gradient_simd ( x_values, y_values, param, loss_metric, gradient) ;
81- }
82- #[ cfg( not( feature = "portable-simd" ) ) ]
83- {
84- accumulate_inverse_gradient_scalar ( x_values, y_values, param, loss_metric, gradient) ;
85- }
50+ accumulate_inverse_gradient_simd ( x_values, y_values, param, loss_metric, gradient) ;
8651}
8752
8853pub ( super ) fn polynomial_cost_scalar (
@@ -205,7 +170,6 @@ pub(super) fn accumulate_inverse_gradient_scalar(
205170 }
206171}
207172
208- #[ cfg( feature = "portable-simd" ) ]
209173fn value_from_residual_simd ( loss_metric : OptimizationLossMetric , residual : Vf64 ) -> Vf64 {
210174 match loss_metric {
211175 OptimizationLossMetric :: Mse => residual * residual,
@@ -217,7 +181,6 @@ fn value_from_residual_simd(loss_metric: OptimizationLossMetric, residual: Vf64)
217181 }
218182}
219183
220- #[ cfg( feature = "portable-simd" ) ]
221184fn residual_derivative_simd ( loss_metric : OptimizationLossMetric , residual : Vf64 ) -> Vf64 {
222185 match loss_metric {
223186 OptimizationLossMetric :: Mse => Vf64 :: splat ( 2.0 ) * residual,
@@ -235,7 +198,6 @@ fn residual_derivative_simd(loss_metric: OptimizationLossMetric, residual: Vf64)
235198 }
236199}
237200
238- #[ cfg( feature = "portable-simd" ) ]
239201pub ( super ) fn polynomial_cost_simd (
240202 param : & [ f64 ] ,
241203 x_values : & [ f64 ] ,
@@ -293,7 +255,6 @@ pub(super) fn polynomial_cost_simd(
293255 }
294256}
295257
296- #[ cfg( feature = "portable-simd" ) ]
297258pub ( super ) fn inverse_cost_simd (
298259 param : & [ f64 ] ,
299260 x_values : & [ f64 ] ,
@@ -344,7 +305,6 @@ pub(super) fn inverse_cost_simd(
344305 }
345306}
346307
347- #[ cfg( feature = "portable-simd" ) ]
348308pub ( super ) fn accumulate_polynomial_gradient_simd (
349309 x_values : & [ f64 ] ,
350310 y_values : & [ f64 ] ,
@@ -398,7 +358,6 @@ pub(super) fn accumulate_polynomial_gradient_simd(
398358 }
399359}
400360
401- #[ cfg( feature = "portable-simd" ) ]
402361pub ( super ) fn accumulate_inverse_gradient_simd (
403362 x_values : & [ f64 ] ,
404363 y_values : & [ f64 ] ,
0 commit comments