Skip to content

Commit 6557422

Browse files
committed
sparse_mkl backend integration
1 parent 69874f3 commit 6557422

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ data/
33
test.py
44
github_ssh
55
github_ssh.pub
6+
mkl_rt.2.dll
67

78

89
# =================== PYCHARM ===================

pygrank/core/backend/sparse_dot_mkl.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,17 @@
55
import os
66
if "MKL_NUM_THREADS" not in os.environ:
77
os.environ["MKL_NUM_THREADS"] = str(os.cpu_count())
8-
import sparse_dot_mkl
8+
9+
10+
__pygrank_sparse_dot_mkl_warning = False
11+
try:
12+
import sparse_dot_mkl
13+
except Exception as e:
14+
__pygrank_sparse_dot_mkl_warning = True
15+
warnings.warn("sparse_dot_mkl could not be imported.\n"
16+
"Please check your environment setup."
17+
"Falling back to numpy implementation for this backend.")
18+
warnings.warn(str(e))
919

1020

1121
def backend_init():
@@ -61,8 +71,6 @@ def self_normalize(obj):
6171
obj = obj / np_sum
6272
return obj
6373

64-
__pygrank_sparse_dot_mkl_warning = False
65-
6674

6775
def conv(signal, M):
6876
global __pygrank_sparse_dot_mkl_warning

0 commit comments

Comments
 (0)