From 7cc30ec6817dec403ec98f1e0da30dfc7473f413 Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin Date: Mon, 27 Nov 2023 16:44:11 -0500 Subject: Force vectorization for DNN primitives Avoids having to write intrinsics for simple loops --- dnn/nnet_arch.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/dnn/nnet_arch.h b/dnn/nnet_arch.h index 3c53e619..b61ebf54 100644 --- a/dnn/nnet_arch.h +++ b/dnn/nnet_arch.h @@ -38,6 +38,13 @@ #define RTCD_SUF(name) CAT_SUFFIX(name, RTCD_ARCH) +/* Force vectorization on for DNN code because some of the loops rely on + compiler vectorization rather than explicitly using intrinsics. */ +#ifdef __GNUC__ +#pragma GCC push_options +#pragma GCC optimize("tree-vectorize") +#endif + #define MAX_ACTIVATIONS (4096) @@ -216,4 +223,8 @@ void RTCD_SUF(compute_conv2d_)(const Conv2dLayer *conv, float *out, float *mem, } } +#ifdef __GNUC__ +#pragma GCC pop_options +#endif + #endif -- cgit v1.2.3