8000 safeguards · jeremiedbb/scikit-learn@b104d5e · GitHub
[go: up one dir, main page]

Skip to content

Commit b104d5e

Browse files
committed
safeguards
1 parent c260147 commit b104d5e

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

sklearn/utils/_openmp_helpers.pyx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,20 @@ def set_openblas_openmp_callback():
111111
cdef openblas_set_threads_callback_function_type f_ptr
112112

113113
for ct in openblas_controllers:
114+
if not hasattr(ct, "dynlib"):
115+
# too old version of threadpoolctl
116+
continue
117+
114118
lib = ct.dynlib
115119

116-
# openblas_set_threads_callback_function is available since v0.3.28
117-
if hasattr(lib, "openblas_set_threads_callback_function"):
118-
func = lib.openblas_set_threads_callback_function
120+
if not hasattr(lib, "openblas_set_threads_callback_function"):
121+
# openblas_set_threads_callback_function is available since v0.3.28
122+
continue
123+
124+
func = lib.openblas_set_threads_callback_function
119125

120-
# cast to the correct function pointer type
121-
f_ptr = (<openblas_set_threads_callback_function_type*><size_t>addressof(func))[0]
122-
f_ptr(openblas_openmp_callback)
126+
# cast to the correct function pointer type
127+
f_ptr = (<openblas_set_threads_callback_function_type*><size_t>addressof(func))[0]
128+
f_ptr(openblas_openmp_callback)
123129

124-
print("OpenBLAS OpenMP backend callback set")
130+
print("OpenBLAS OpenMP backend callback set")

0 commit comments

Comments
 (0)
0