def is_max_supported_instructions_set(instructions_set): result = False if re.search(instructions_set.replace('4_2', '4.2'), mkl.get_version()['Processor'].decode(), re.IGNORECASE): result = True return result
# Use mkl-service to check version if it's installed # Since it's not on PyPi I don't want to make this an actual package dependency # So without it just create mock functions and don't do version checking try: from mkl import get_version, get_version_string except ImportError: def get_version(): return None def get_version_string(): return None if get_version() is not None and get_version()["MajorVersion"] < 2020: msg = "Loaded version of MKL is out of date: {v}".format( v=get_version_string()) warnings.warn(msg) import numpy as np import scipy.sparse as _spsparse from numpy.ctypeslib import ndpointer, as_array NUMPY_FLOAT_DTYPES = [np.float32, np.float64] class MKL: """ This class holds shared object references to C functions with arg and returntypes that can be adjusted""" MKL_INT = None
def __dir__(): return list(globals().keys() | {'Tester', 'testing'}) else: # We don't actually use this ourselves anymore, but I'm not 100% sure that # no-one else in the world is using it (though I hope not) from .testing import Tester # Pytest testing from numpy._pytesttester import PytestTester test = PytestTester(__name__) del PytestTester import mkl __mkl_version__ = "{MajorVersion}.{UpdateVersion}".format( **mkl.get_version()) def _sanity_check(): """ Quick sanity checks for common bugs caused by environment. There are some cases e.g. with wrong BLAS ABI that cause wrong results under specific runtime conditions that are not necessarily achieved during test suite runs, and it is useful to catch those early. See https://github.com/numpy/numpy/issues/8577 and other similar bug reports. """ try: x = ones(2, dtype=float32) if not abs(x.dot(x) - 2.0) < 1e-5:
# oldnumeric and numarray were removed in 1.9. In case some packages import # but do not use them, we define them here for backward compatibility. oldnumeric = 'removed' numarray = 'removed' # We don't actually use this ourselves anymore, but I'm not 100% sure that # no-one else in the world is using it (though I hope not) from .testing import Tester # Pytest testing from numpy._pytesttester import PytestTester test = PytestTester(__name__) del PytestTester import mkl __mkl_version__ = "{MajorVersion}.{UpdateVersion}".format(**mkl.get_version()) def _sanity_check(): """ Quick sanity checks for common bugs caused by environment. There are some cases e.g. with wrong BLAS ABI that cause wrong results under specific runtime conditions that are not necessarily achieved during test suite runs, and it is useful to catch those early. See https://github.com/numpy/numpy/issues/8577 and other similar bug reports. """ try: x = ones(2, dtype=float32)
def test_get_version(self): v = mkl.get_version() assert (isinstance(v, dict)) assert ('MajorVersion' in v) assert ('MinorVersion' in v) assert ('UpdateVersion' in v)