aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/kann/kautodiff.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-07-03 12:36:18 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-07-03 12:36:18 +0100
commit55f59de699aa0c7c7018e05375131d22cfd46530 (patch)
tree1fc8072b713108e865084d80b4513bd79b7667d9 /contrib/kann/kautodiff.c
parent4a08d5f01e27aa2e67e54386c9206ad4f42d40c1 (diff)
downloadrspamd-55f59de699aa0c7c7018e05375131d22cfd46530.tar.gz
rspamd-55f59de699aa0c7c7018e05375131d22cfd46530.zip
[Minor] Allow to work without cblas.h
Diffstat (limited to 'contrib/kann/kautodiff.c')
-rw-r--r--contrib/kann/kautodiff.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/contrib/kann/kautodiff.c b/contrib/kann/kautodiff.c
index f303a723f..bc9458f42 100644
--- a/contrib/kann/kautodiff.c
+++ b/contrib/kann/kautodiff.c
@@ -1,3 +1,5 @@
+#include "config.h"
+
#include <stdlib.h>
#include <assert.h>
#include <stdarg.h>
@@ -898,7 +900,20 @@ void kad_vec_mul_sum(int n, float *a, const float *b, const float *c)
void kad_saxpy(int n, float a, const float *x, float *y) { kad_saxpy_inlined(n, a, x, y); }
#ifdef HAVE_CBLAS
+#ifdef HAVE_CBLAS_H
#include "cblas.h"
+#else
+/* Poor man approach */
+enum CBLAS_ORDER {CblasRowMajor=101, CblasColMajor=102 };
+enum CBLAS_TRANSPOSE {CblasNoTrans=111, CblasTrans=112 };
+extern void cblas_sgemm(const enum CBLAS_ORDER Order,
+ const enum CBLAS_TRANSPOSE TA,
+ const enum CBLAS_TRANSPOSE TB,
+ const int M, const int N, const int K,
+ const float alpha, const float *A, const int lda,
+ const float *B, const int ldb, const float beta,
+ float *C, const int ldc);
+#endif
void kad_sgemm_simple(int trans_A, int trans_B, int M, int N, int K, const float *A, const float *B, float *C)
{
cblas_sgemm(CblasRowMajor, trans_A? CblasTrans : CblasNoTrans, trans_B? CblasTrans : CblasNoTrans, M, N, K, 1.0f, A, trans_A? M : K, B, trans_B? K : N, 1.0f, C, N);