Intel MKL wrapper for sparse matrix multiplication
Project description
sparse_dot_mkl
This is a wrapper for the sparse matrix multiplication in the intel MKL library.
It is implemented entirely in native python using ctypes
.
The main advantage to MKL (which motivated this) is multithreaded sparse matrix multiplication.
The scipy sparse implementation is single-threaded at the time of writing (2020-01-03).
A secondary advantage is the direct multiplication of a sparse and a dense matrix without requiring any
intermediate conversion (also multithreaded).
The only function explicitly available is dot_product_mkl
, which takes two matrices
dot_product_mkl(A, B)
and returns a matrix that is A (dot) B
.
If both matrices are dense, the output will be dense.
If one matrix is dense and one is sparse, the output will be dense.
If both matrices are sparse, the output will be sparse unless the dense=True
flag is passed.
The dense flag will directly multiply to a dense matrix without requiring intermediate conversion.
It has no effect if set when a dense output would normally be produced.
If both matrices are sparse, they must be of the same type (CSC or CSR). There is no support currently for COO or BSR sparse matrices. Numpy (dense) arrays must be C-ordered and contiguous (these are the defaults in most situations).
This only does floating point data, and both matrices must be identical types.
If cast=True
non-float matrices will be converted to doubles,
and a single-precision matrix will be promoted to doubles unless both matrices are single-precision.
cast=True
will not change data in-place, but will instead make an internal copy.
This function may also reorder sparse data structures without warning while creating MKL's internal matrix representation
(reordering does not change data, only the way it is stored).
This package requires libmkl_rt.so
(or libmkl_rt.dylib
for OSX, or libmkl_rt.dll
for WIN).
If the MKL library cannot be loaded an ImportError
will be raised when the package is first imported.
MKL is distributed with the full version of conda,
and can be installed into Miniconda with conda install -c intel mkl
.
Alternatively, you may add need to add the path to MKL shared objects to LD_LIBRARY_PATH
(e.g. export LD_LIBRARY_PATH=/opt/intel/mkl/lib/intel64:$LD_LIBRARY_PATH
).
There are some known bugs in MKL v2019 which may cause intermittent segfaults.
Updating to MKL v2020 is highly recommended if you encounter any problems.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for sparse_dot_mkl-0.2.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e346f2d407928d29988537de4edf3772501b84ddcf3c00c062d17fc93e29a8e0 |
|
MD5 | ae1f17a8f61a461be1c4b1e2d03e5c61 |
|
BLAKE2b-256 | 3babef599ae6bb3b069ae7bff9079804d5c3ff16c6b1001a504a3ad948a14747 |