Skip to content

Instantly share code, notes, and snippets.

@sebastian-schmidt
Created June 20, 2016 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sebastian-schmidt/9bb97354b481750209fd3dac1e748d31 to your computer and use it in GitHub Desktop.
Save sebastian-schmidt/9bb97354b481750209fd3dac1e748d31 to your computer and use it in GitHub Desktop.
import numpy as np
def _init_numpy_mkl():
# Numpy+MKL on Windows only
import os
import ctypes
if os.name != 'nt':
return
# disable Intel Fortran default console event handler
env = 'FOR_DISABLE_CONSOLE_CTRL_HANDLER'
if env not in os.environ:
os.environ[env] = '1'
# preload MKL DLLs from numpy.core
try:
_core = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'core')
print(_core)
for _dll in ('mkl_rt', 'libiomp5md', 'mkl_core', 'mkl_intel_thread',
'libmmd', 'libifcoremd', 'libimalloc'):
ctypes.cdll.LoadLibrary(os.path.join(_core,_dll))
except Exception:
print('bla')
_init_numpy_mkl()
del _init_numpy_mkl
A = np.arange(2*3).reshape(2,3).astype(np.float32)
B = np.arange(2*3*2731).reshape(2,3,2731).astype(np.int16)
print(np.dot(A, B))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment