mirror of https://github.com/pyodide/pyodide.git
46 lines
1.6 KiB
Diff
46 lines
1.6 KiB
Diff
From 2c816f54d3a6b056f42b97ad646789e9fe31a670 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Lo=C3=AFc=20Est=C3=A8ve?= <loic.esteve@ymail.com>
|
|
Date: Thu, 6 Apr 2023 17:52:34 +0200
|
|
Subject: [PATCH] Avoid signature mismatch in sdot detection.
|
|
|
|
In Pyodide, OpenBLAS sdot returns float so use it rather than trying
|
|
to adapt the somewhat tricky gensim logic.
|
|
---
|
|
gensim/models/word2vec_inner.pyx | 20 +++-----------------
|
|
1 file changed, 3 insertions(+), 17 deletions(-)
|
|
|
|
diff --git a/gensim/models/word2vec_inner.pyx b/gensim/models/word2vec_inner.pyx
|
|
index 1c0807ee..3d4a6847 100755
|
|
--- a/gensim/models/word2vec_inner.pyx
|
|
+++ b/gensim/models/word2vec_inner.pyx
|
|
@@ -939,23 +939,9 @@ def init():
|
|
EXP_TABLE[i] = <REAL_t>(EXP_TABLE[i] / (EXP_TABLE[i] + 1))
|
|
LOG_TABLE[i] = <REAL_t>log( EXP_TABLE[i] )
|
|
|
|
- # check whether sdot returns double or float
|
|
- d_res = dsdot(&size, x, &ONE, y, &ONE)
|
|
- p_res = <float *>&d_res
|
|
- if abs(d_res - expected) < 0.0001:
|
|
- our_dot = our_dot_double
|
|
- our_saxpy = saxpy
|
|
- return 0 # double
|
|
- elif abs(p_res[0] - expected) < 0.0001:
|
|
- our_dot = our_dot_float
|
|
- our_saxpy = saxpy
|
|
- return 1 # float
|
|
- else:
|
|
- # neither => use cython loops, no BLAS
|
|
- # actually, the BLAS is so messed up we'll probably have segfaulted above and never even reach here
|
|
- our_dot = our_dot_noblas
|
|
- our_saxpy = our_saxpy_noblas
|
|
- return 2
|
|
+ our_dot = our_dot_float
|
|
+ our_saxpy = saxpy
|
|
+ return 1 # float
|
|
|
|
FAST_VERSION = init() # initialize the module
|
|
MAX_WORDS_IN_BATCH = MAX_SENTENCE_LEN
|
|
--
|
|
2.34.1
|
|
|