Skip to main content

The Blis BLAS-like linear algebra library, as a self-contained C-extension.

Project description

Cython BLIS: Fast BLAS-like operations from Python and Cython, without the tears

This repository provides the Blis linear algebra routines as a self-contained Python C-extension.

Currently, we only supports single-threaded execution, as this is actually best for our workloads (ML inference).

Azure Pipelines pypi Version conda Python wheels

Installation

You can install the package via pip, first making sure that pip, setuptools, and wheel are up-to-date:

pip install -U pip setuptools wheel
pip install blis

Wheels should be available, so installation should be fast. If you want to install from source and you're on Windows, you'll need to install LLVM.

Building BLIS for alternative architectures

The provided wheels should work on x86_64 architectures. Unfortunately we do not currently know a way to provide different wheels for alternative architectures, and we cannot provide a single binary that works everywhere. So if the wheel doesn't work for your CPU, you'll need to specify source distribution, and tell Blis your CPU architecture using the BLIS_ARCH environment variable.

a) Installing with generic arch support

BLIS_ARCH="generic" pip install spacy --no-binary blis

b) Building specific support

In order to compile Blis, cython-blis bundles makefile scripts for specific architectures, that are compiled by running the Blis build system and logging the commands. We do not yet have logs for every architecture, as there are some architectures we have not had access to.

See here for list of architectures. For example, here's how to build support for the ARM architecture cortexa57:

git clone https://github.com/explosion/cython-blis && cd cython-blis
git pull && git submodule init && git submodule update && git submodule status
python3 -m venv env3.6
source env3.6/bin/activate
pip install -r requirements.txt
./bin/generate-make-jsonl linux cortexa57
BLIS_ARCH="cortexa57" python setup.py build_ext --inplace
BLIS_ARCH="cortexa57" python setup.py bdist_wheel

Fingers crossed, this will build you a wheel that supports your platform. You could then submit a PR with the blis/_src/make/linux-cortexa57.jsonl and blis/_src/include/linux-cortexa57/blis.h files so that you can run:

BLIS_ARCH=cortexa57 pip install --no-binary=blis

Usage

Two APIs are provided: a high-level Python API, and direct Cython access, which provides fused-type, nogil Cython bindings to the underlying Blis linear algebra library. Fused types are a simple template mechanism, allowing just a touch of compile-time generic programming:

cimport blis.cy
A = <float*>calloc(nN * nI, sizeof(float))
B = <float*>calloc(nO * nI, sizeof(float))
C = <float*>calloc(nr_b0 * nr_b1, sizeof(float))
blis.cy.gemm(blis.cy.NO_TRANSPOSE, blis.cy.NO_TRANSPOSE,
             nO, nI, nN,
             1.0, A, nI, 1, B, nO, 1,
             1.0, C, nO, 1)

Bindings have been added as we've needed them. Please submit pull requests if the library is missing some functions you require.

Development

To build the source package, you should run the following command:

./bin/update-vendored-source

This populates the blis/_src folder for the various architectures, using the flame-blis submodule.

Updating the build files

In order to compile the Blis sources, we use jsonl files that provide the explicit compiler flags. We build these jsonl files by running Blis's build system, and then converting the log. This avoids us having to replicate the build system within Python: we just use the jsonl to make a bunch of subprocess calls. To support a new OS/architecture combination, we have to provide the jsonl file and the header.

Linux

The Linux build files need to be produced from within the manylinux1 docker container, so that they will be compatible with the wheel building process.

First, install docker. Then do the following to start the container:

sudo docker run -it quay.io/pypa/manylinux1_x86_64:latest

Once within the container, the following commands should check out the repo and build the jsonl files for the generic arch:

mkdir /usr/local/repos
cd /usr/local/repos
git clone https://github.com/explosion/cython-blis && cd cython-blis
git pull && git submodule init && git submodule update && git submodule
status
/opt/python/cp36-cp36m/bin/python -m venv env3.6
source env3.6/bin/activate
pip install -r requirements.txt
./bin/generate-make-jsonl linux generic --export
BLIS_ARCH=generic python setup.py build_ext --inplace
# N.B.: don't copy to /tmp, docker cp doesn't work from there.
cp blis/_src/include/linux-generic/blis.h /linux-generic-blis.h
cp blis/_src/make/linux-generic.jsonl /

Then from a new terminal, retrieve the two files we need out of the container:

sudo docker ps -l # Get the container ID
# When I'm in Vagrant, I need to go via cat -- but then I end up with dummy
# lines at the top and bottom. Sigh. If you don't have that problem and
# sudo docker cp just works, just copy the file.
sudo docker cp aa9d42588791:/linux-generic-blis.h - | cat > linux-generic-blis.h
sudo docker cp aa9d42588791:/linux-generic.jsonl - | cat > linux-generic.jsonl

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

blis-0.7.5.tar.gz (2.8 MB view details)

Uploaded Source

Built Distributions

blis-0.7.5-cp310-cp310-win_amd64.whl (6.6 MB view details)

Uploaded CPython 3.10 Windows x86-64

blis-0.7.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.9 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

blis-0.7.5-cp310-cp310-macosx_10_9_x86_64.whl (5.8 MB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

blis-0.7.5-cp39-cp39-win_amd64.whl (6.6 MB view details)

Uploaded CPython 3.9 Windows x86-64

blis-0.7.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.9 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

blis-0.7.5-cp39-cp39-macosx_10_9_x86_64.whl (5.8 MB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

blis-0.7.5-cp38-cp38-win_amd64.whl (6.6 MB view details)

Uploaded CPython 3.8 Windows x86-64

blis-0.7.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.9 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

blis-0.7.5-cp38-cp38-macosx_10_9_x86_64.whl (5.8 MB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

blis-0.7.5-cp37-cp37m-win_amd64.whl (6.5 MB view details)

Uploaded CPython 3.7m Windows x86-64

blis-0.7.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.9 MB view details)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

blis-0.7.5-cp37-cp37m-macosx_10_9_x86_64.whl (5.8 MB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

blis-0.7.5-cp36-cp36m-win_amd64.whl (6.5 MB view details)

Uploaded CPython 3.6m Windows x86-64

blis-0.7.5-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.9 MB view details)

Uploaded CPython 3.6m manylinux: glibc 2.17+ x86-64

blis-0.7.5-cp36-cp36m-macosx_10_9_x86_64.whl (5.8 MB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

Details for the file blis-0.7.5.tar.gz.

File metadata

  • Download URL: blis-0.7.5.tar.gz
  • Upload date:
  • Size: 2.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for blis-0.7.5.tar.gz
Algorithm Hash digest
SHA256 833e01e9eaff4c01aa6e049bbc1e6acb9eca6ee513d7b35b5bf135d49705ad33
MD5 566fcb7d5ec14b5598ae5ed68ee87a08
BLAKE2b-256 a432b29de050557c8ba7f6694d1c8c3b6dabe53af72e12c6dc39e2547d89232d

See more details on using hashes here.

File details

Details for the file blis-0.7.5-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: blis-0.7.5-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 6.6 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for blis-0.7.5-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 0e476931f0d5703a21c77e7f69b8ebdeeea493fc7858a86f627ac2b376a12c8d
MD5 448c47df6479a0c6e0cea540a6baebdd
BLAKE2b-256 86d552d273539e8eef217076d1ced3dcbb27f91e3bdb97709dbf19ba769a5fbc

See more details on using hashes here.

File details

Details for the file blis-0.7.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for blis-0.7.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9eecfce3d8fce61dede7b0ae0dffa461c22072437b6cde85587db0c1aa75b450
MD5 e787dfb66da525b01286ea64daef82ad
BLAKE2b-256 848f70af7aa283943bdfd654abdb186b439c1aed0cce23dd7497c9abb10e2ebf

See more details on using hashes here.

File details

Details for the file blis-0.7.5-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: blis-0.7.5-cp310-cp310-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 5.8 MB
  • Tags: CPython 3.10, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for blis-0.7.5-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5812a7c04561ae7332cf730f57d9f82cbd12c5f86a5bfad66ee244e51d06266d
MD5 e34a88ff6b612ba42455b232048fe981
BLAKE2b-256 f8b707e60c15ee3954968555526b6e7578bdeaa0dddcfb74cde263222b02db95

See more details on using hashes here.

File details

Details for the file blis-0.7.5-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: blis-0.7.5-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 6.6 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for blis-0.7.5-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 66204a19e38986645940c887498c7b5520efb5bbc6526bf1b8a58f7d3eb37da0
MD5 953b102d3e38a48e053c4b492b939f93
BLAKE2b-256 4df0e2e8092b21ce042d675d66f60640eb07359e22abd2603bc9d74c30df648f

See more details on using hashes here.

File details

Details for the file blis-0.7.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for blis-0.7.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8345bd04777557ef385e2f2d1f14a19d53b2ea9ca5fe107a2cdc50d7bafb8eb2
MD5 573a532e45f7f906004ab5b19a41480d
BLAKE2b-256 fa2ab76e7e06298ac035baca2e7c8d3d6b8eb80fe1c481c56b1768c431f917d2

See more details on using hashes here.

File details

Details for the file blis-0.7.5-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: blis-0.7.5-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 5.8 MB
  • Tags: CPython 3.9, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for blis-0.7.5-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 0c185979f8f528d634f5548b8cd84ab0366d340c27c039ad3937fab186c1c252
MD5 174bab74ea01f15f533b4a87a2353fcd
BLAKE2b-256 c2ceed2cf9284a319f14ba644a96b027f00cefb25e550a6a81a762b8d4fef819

See more details on using hashes here.

File details

Details for the file blis-0.7.5-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: blis-0.7.5-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 6.6 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for blis-0.7.5-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 31401da283ed42905f0fbf2f8b88ea424c6a911482426f84b5b88c54d382e4d1
MD5 6458cebca654e1375b26de7219ab0d06
BLAKE2b-256 2dd3b1e56c013113883d81af00c1c916e1be6695fadb6c867314ba0b449e9eba

See more details on using hashes here.

File details

Details for the file blis-0.7.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for blis-0.7.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cf11c233ea5c2d30683e7c9641c5dc4cd76ed0f64755ba3321dfb8db39feb316
MD5 30bd2e27ff1de87be7864a3f486a9b92
BLAKE2b-256 d6c44907eae6189089d8508263bfbdb145ee7adc6597f108e7c9bd4da23e215e

See more details on using hashes here.

File details

Details for the file blis-0.7.5-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: blis-0.7.5-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 5.8 MB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for blis-0.7.5-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 ad4af690c37a5953d3aea660ad89b636bfbb80ca1470995554670ca2143f0cb2
MD5 c107ff722555dd02ab40c3237c6a9085
BLAKE2b-256 9859f8974173fc33f29bd18546ad5b00076b84a98406ef2245696e3a24cca5b3

See more details on using hashes here.

File details

Details for the file blis-0.7.5-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: blis-0.7.5-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 6.5 MB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for blis-0.7.5-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 65ba723821cc57eb4227eb8dd05c57fff23d97f826d4325b316cd8a63aac8d6a
MD5 7a4f98ed6661962f4068e178164b020d
BLAKE2b-256 530f1f5e424617cf5a197974d344fabe49af28a7cfe428c4738e3733319d81ce

See more details on using hashes here.

File details

Details for the file blis-0.7.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for blis-0.7.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5023781272e0b2868be2f92017aa6836557990f1ca5ba2af5e9f5a0acf04fd8a
MD5 29f1ed9575ed4fbdd9801bdba7731216
BLAKE2b-256 5c7ea2710610d29a2f66fbca20f3839bb884072123e8c36a5ba10af97d478a23

See more details on using hashes here.

File details

Details for the file blis-0.7.5-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: blis-0.7.5-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 5.8 MB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for blis-0.7.5-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 2339cb19594134775bda8b86f23a893828fc7e8d63f09ba9a15f30b2b16c966c
MD5 a19c9543f84e5f260f7facc7595b9c4f
BLAKE2b-256 9597314c54069c1a66ee45dc8fd043598bad5ebd53799cf3713a9d54bd71a48f

See more details on using hashes here.

File details

Details for the file blis-0.7.5-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: blis-0.7.5-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 6.5 MB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for blis-0.7.5-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 730952f74adb0fa7dde9f1bc11249d5a64f3a3a9cf7dfa23b189a4b767bdf2d0
MD5 9ebe9eaef7c93fa6f205d9e8befc3e6b
BLAKE2b-256 c8dbd4e8b966a97bf56706260029c6d756f0774e3258d6af4065a12bb882dad1

See more details on using hashes here.

File details

Details for the file blis-0.7.5-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for blis-0.7.5-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d9034dabce4e42e3a1a7b99cc6de430484c8c369e51556ee8d47a53c085de681
MD5 02d65bbe5f2d44c0a5cfc9d794209901
BLAKE2b-256 3b08c1f61e1b53f40e0ac4b2a980951dcfaf2a8fe6df4674d56f205d4000baeb

See more details on using hashes here.

File details

Details for the file blis-0.7.5-cp36-cp36m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: blis-0.7.5-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 5.8 MB
  • Tags: CPython 3.6m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for blis-0.7.5-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5966ddf3bce84aa7bb09ce4ca059309602fa63280a5d5e5365bb2a294bd5a138
MD5 81d19c2dfbce4a254450516314274a83
BLAKE2b-256 6a5a7dcf18c7b41ff07a34a50658da354d7a0f321066e7da7fc37fe0ee093f7b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page