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_86 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/copy-source-files.sh

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.4.tar.gz (2.8 MB view details)

Uploaded Source

Built Distributions

blis-0.7.4-cp39-cp39-win_amd64.whl (6.5 MB view details)

Uploaded CPython 3.9 Windows x86-64

blis-0.7.4-cp39-cp39-manylinux2014_x86_64.whl (9.8 MB view details)

Uploaded CPython 3.9

blis-0.7.4-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.4-cp38-cp38-win_amd64.whl (6.5 MB view details)

Uploaded CPython 3.8 Windows x86-64

blis-0.7.4-cp38-cp38-manylinux2014_x86_64.whl (9.8 MB view details)

Uploaded CPython 3.8

blis-0.7.4-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.4-cp37-cp37m-win_amd64.whl (6.5 MB view details)

Uploaded CPython 3.7m Windows x86-64

blis-0.7.4-cp37-cp37m-manylinux2014_x86_64.whl (9.8 MB view details)

Uploaded CPython 3.7m

blis-0.7.4-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.4-cp36-cp36m-win_amd64.whl (6.5 MB view details)

Uploaded CPython 3.6m Windows x86-64

blis-0.7.4-cp36-cp36m-manylinux2014_x86_64.whl (9.8 MB view details)

Uploaded CPython 3.6m

blis-0.7.4-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.4.tar.gz.

File metadata

  • Download URL: blis-0.7.4.tar.gz
  • Upload date:
  • Size: 2.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

File hashes

Hashes for blis-0.7.4.tar.gz
Algorithm Hash digest
SHA256 7daa615a97d4f28db0f332b710bfe1900b15d0c25841c6d727965e4fd91e09cf
MD5 45a4e7d91e10fe84c3bdbd5433062e76
BLAKE2b-256 b154b0de9905ee80aebd64c333bc112cacfe06849a9b5a7230a02dfde73e7aad

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blis-0.7.4-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 6.5 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

File hashes

Hashes for blis-0.7.4-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 78a8e0ee72a42c3b2f5b9114500a781119995f76fa6c21d4b02c6fb9c21df2cc
MD5 47d63c50bd9c1d189ad290ca3f7ce9ee
BLAKE2b-256 521c3bbb7c382d728f94b9a9b911f54200da16bed3ef2d9adf3c81d2781ca652

See more details on using hashes here.

File details

Details for the file blis-0.7.4-cp39-cp39-manylinux2014_x86_64.whl.

File metadata

  • Download URL: blis-0.7.4-cp39-cp39-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 9.8 MB
  • Tags: CPython 3.9
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

File hashes

Hashes for blis-0.7.4-cp39-cp39-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5c1a2023f7d8431daa8d87d32f539bb23e1a009500c37f9eba0ac7b3f20f73eb
MD5 67de944f0f42ffd8b24486c573ab922c
BLAKE2b-256 c086937a97e4db05fda4b333f9267573316e0e7ce409ed48832773cc31cc53db

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blis-0.7.4-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.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

File hashes

Hashes for blis-0.7.4-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 168fd7bd763ebe529aa25a066d3a6b89f4c3f492f6297f881df6942741b95787
MD5 d5d6255eb289c79cfae68a0f1fd18aa8
BLAKE2b-256 3519c2d83aac652e904f1103721f13451b0f8b1f86e0cb5143e09715370c4a2a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blis-0.7.4-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 6.5 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

File hashes

Hashes for blis-0.7.4-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 94890b2296f1449baa56aede46627ea7fc8de11c788f9c261ee38c2eb4a2cc7d
MD5 5ee5430425f1f4f26008331677370fd7
BLAKE2b-256 efde4f0c01070a21633665f2ac5a0f608a8c6e78525167750c3c2cb698d47d87

See more details on using hashes here.

File details

Details for the file blis-0.7.4-cp38-cp38-manylinux2014_x86_64.whl.

File metadata

  • Download URL: blis-0.7.4-cp38-cp38-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 9.8 MB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

File hashes

Hashes for blis-0.7.4-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 445e4838b809e99677f5c0982fb9af320f0d91328fb28c8097e5f1173c4df9d6
MD5 0df8ce9827ceea781277285f67748cca
BLAKE2b-256 0634e896b84f7d2e3d61e9b5718670025988eae81ac10deb5c33979cd633e1de

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blis-0.7.4-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.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

File hashes

Hashes for blis-0.7.4-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 4222bbc7b9c47bc3cf6f36f2241862c1512ca7ebac3828267a2e05ef6c47fc54
MD5 a073de563e6a5ce863e4da9d9832fb90
BLAKE2b-256 4c8a520ce842368186de26a9f93a53832122fddb5b234dbf9256c59a2c6c2f94

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blis-0.7.4-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.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

File hashes

Hashes for blis-0.7.4-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 6814991b3e3193db4f9b2417174c6f24b9c0197409d864fa7628583bd2df1f0f
MD5 77839c184f54cda7805a56faf148c24c
BLAKE2b-256 7cf32c18510d125d6af493120ca50fc8f2e3c21c9f58fb38d34c032f813dadcb

See more details on using hashes here.

File details

Details for the file blis-0.7.4-cp37-cp37m-manylinux2014_x86_64.whl.

File metadata

  • Download URL: blis-0.7.4-cp37-cp37m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 9.8 MB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

File hashes

Hashes for blis-0.7.4-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5ecddc4c6daf80558154b091db0a9839bb15dbe65d2906a543a73b93fbce4f73
MD5 d65c42cef39868961d111739cf1017f9
BLAKE2b-256 0ec1f364687078298233696eff17305f9a54c4a27d9da03c07c0062909d550f1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blis-0.7.4-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.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

File hashes

Hashes for blis-0.7.4-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 d717b5dea407aac89a646908e7d9849105abab9c88a539c120518c200f899f4e
MD5 574ee4c337f6f370ae591ea81547f79f
BLAKE2b-256 5cf2c0bd2de42c442fe1e0826aa525f9a8037b37eda465dbe09e9d7edbfb2f15

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blis-0.7.4-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.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

File hashes

Hashes for blis-0.7.4-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 c2d8064217c326dd9a0dcbae294ffe8557263e2a00d76101ffa222b9c9d9c62d
MD5 c7cd5158786799b5ba8c9a97a54e65f9
BLAKE2b-256 d54e013b495c02ed555b56efe7c84b254a5e27f18aac34aac49d2ae1ea66b48e

See more details on using hashes here.

File details

Details for the file blis-0.7.4-cp36-cp36m-manylinux2014_x86_64.whl.

File metadata

  • Download URL: blis-0.7.4-cp36-cp36m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 9.8 MB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

File hashes

Hashes for blis-0.7.4-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9f9b829480c12fc834549306821e5c51cb28b216ca5f88c5b2cfedbeb9daf67d
MD5 2788a1ce67e4864ff719d1d9aef85722
BLAKE2b-256 bb9fe526cd764e2a2cf6958a1389a59c42acda7a65f24949256100cc94c2ff6d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blis-0.7.4-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.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

File hashes

Hashes for blis-0.7.4-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5b403deb2ad5515e1edb3c0867bccb5b974b461f24283d9219a3a761fd6dacc6
MD5 49c2887b335e9475884f2c238858e269
BLAKE2b-256 cc664390cb4842477f6a518875c5d04706279c730552472888fbddb944938290

See more details on using hashes here.

Supported by

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