From c1535c8ccfcb31008ce5528deeb2f206f95ce3c9 Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin Date: Thu, 24 Jun 2021 17:31:05 -0400 Subject: [PATCH] Adding option to disable int8 dot products --- dnn/configure.ac | 10 +++++++++- dnn/vec.h | 2 ++ dnn/vec_avx.h | 2 ++ dnn/vec_neon.h | 2 ++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/dnn/configure.ac b/dnn/configure.ac index 9efc10fe..fad54e27 100644 --- a/dnn/configure.ac +++ b/dnn/configure.ac @@ -73,6 +73,14 @@ AS_IF([test "$enable_assertions" = "yes"], [ AC_DEFINE([OP_ENABLE_ASSERTIONS], [1], [Enable assertions in code]) ]) +AC_ARG_ENABLE([dot-product], + AS_HELP_STRING([--disable-dot-product], [Disable dot product implementation]),, + enable_dot_product=yes) + +AS_IF([test "$enable_dot_product" = "no"], [ + AC_DEFINE([DISABLE_DOT_PROD], [1], [Disable dot product instructions]) +]) + AS_CASE(["$ac_cv_search_lrintf"], ["no"],[], ["none required"],[], @@ -114,8 +122,8 @@ AC_MSG_NOTICE([ ------------------------------------------------------------------------ $PACKAGE_NAME $PACKAGE_VERSION: Automatic configuration OK. + Dot product intrinsics ....... ${enable_dot_product} Assertions ................... ${enable_assertions} - Hidden visibility ............ ${cc_cv_flag_visibility} API documentation ............ ${enable_doc} diff --git a/dnn/vec.h b/dnn/vec.h index dbf50587..ef44cba5 100644 --- a/dnn/vec.h +++ b/dnn/vec.h @@ -45,8 +45,10 @@ #define NO_OPTIMIZATIONS +#ifndef DISABLE_DOT_PROD #define DOT_PROD //#define USE_SU_BIAS +#endif #ifdef DOT_PROD typedef signed char qweight; diff --git a/dnn/vec_avx.h b/dnn/vec_avx.h index 53c725ff..ad39d0f7 100644 --- a/dnn/vec_avx.h +++ b/dnn/vec_avx.h @@ -34,8 +34,10 @@ #include +#ifndef DISABLE_DOT_PROD #define DOT_PROD #define USE_SU_BIAS +#endif #ifdef __AVX2__ static inline __m256 exp8_approx(__m256 X) diff --git a/dnn/vec_neon.h b/dnn/vec_neon.h index 39432232..1209b760 100644 --- a/dnn/vec_neon.h +++ b/dnn/vec_neon.h @@ -30,7 +30,9 @@ #include +#ifndef DISABLE_DOT_PROD #define DOT_PROD +#endif typedef signed char qweight;