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

Uploaded Source

Built Distributions

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

Uploaded CPython 3.9 Windows x86-64

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

Uploaded CPython 3.9

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

Uploaded CPython 3.8 Windows x86-64

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

Uploaded CPython 3.8

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

Uploaded CPython 3.7m Windows x86-64

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

Uploaded CPython 3.7m

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

Uploaded CPython 3.6m Windows x86-64

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

Uploaded CPython 3.6m

blis-0.7.2-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.2.tar.gz.

File metadata

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

File hashes

Hashes for blis-0.7.2.tar.gz
Algorithm Hash digest
SHA256 c14fb9ec3f5ed7c4940c132c7691469ac5d3e302891d95e935623bf1d4e17fbb
MD5 055ef4b784e2aec12c518943d0454c7d
BLAKE2b-256 0643345e98e2895aaabda2992b9c1c5fbbd0a89d9443d825ce49583086f9bba6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blis-0.7.2-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.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9

File hashes

Hashes for blis-0.7.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 3bc769a096e4e3986f1278ed214755d5f6718506b03c960e2f2363e34fa30229
MD5 1883e1ef0b21d0f1ab0d1a84ceb2f873
BLAKE2b-256 07d1bd687752940e8cd89b6370c4e8aba0d13a807eca97bd2021b52eb8ed7f7d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blis-0.7.2-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.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9

File hashes

Hashes for blis-0.7.2-cp39-cp39-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5a1a9ef5defe93054536c3e8550f165ff9def5436e58c67ec9a576ec60ba190b
MD5 80b2faa0afb3f031b4c746a3bbd16c83
BLAKE2b-256 96693a56ff694c273976f194f0bcfc9719411cb7474a497a7e95a5fbc6af173f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blis-0.7.2-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.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9

File hashes

Hashes for blis-0.7.2-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 d86c11335b2b3dafa583b0f373544b38b4f6e06c2d8a56ec203b9290b39b83a3
MD5 08531d164c028de7ef470ce46b51e957
BLAKE2b-256 60cdd793b29724558f50be549b2db1cdf13258507abe37d9faf596fd59c4eca2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blis-0.7.2-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.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9

File hashes

Hashes for blis-0.7.2-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 1e69dd50e7eb557846ab40e42f9008a0f15fceb295beb3af3c2a735000ff33a9
MD5 9af9d1472818ddb8c4e663032c07113b
BLAKE2b-256 3c26aaecafd41d797b06c63780df6aef12a191a92c7e17bc0f1d3e763b6c5fc9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blis-0.7.2-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.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9

File hashes

Hashes for blis-0.7.2-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e8ad6fa77464587bdbd504be731350de2018423573b687895a67852bb7d949d1
MD5 d7edcddb1ef029e03d1bfa2880217e53
BLAKE2b-256 eb87820989a31cee313e4b700b3a9a96fa42eae07fc23d327536328c1c7447b4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blis-0.7.2-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.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9

File hashes

Hashes for blis-0.7.2-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 91fd972df6cf0dc9d911fe58ab30dfdab3f37f1708e43c390e10334ac33f7153
MD5 41bc52240feaf5d00a0685259d339eb8
BLAKE2b-256 aea7792511de0495d659e737970232ea6a9859d15c03a13fb8acd4a6290c6070

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blis-0.7.2-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.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9

File hashes

Hashes for blis-0.7.2-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 4f3dbdd8b2a4ce65241b2635aa4945e0ea37623976f0e167b22b762704c1f78a
MD5 6972839a19255656c247f44acc3ddc6e
BLAKE2b-256 0d1e54dbc50e37412468439888436f976392aae30ff2078e72dc908b6428c58d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blis-0.7.2-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.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9

File hashes

Hashes for blis-0.7.2-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ceeec392fdff23adbe6b66b5f6efad189955384b3e231bc64e715694dce7581d
MD5 7fd67a4165d15890366ba109900e1d36
BLAKE2b-256 7a4af9f56f1e1e555231e8d3084acbb4c3b84d374ec9090e1a62656559ed4d89

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blis-0.7.2-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.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9

File hashes

Hashes for blis-0.7.2-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 71210d062e990074935e1eda7b575f20144d24e488bdae177024e555345e4ec1
MD5 b99abfc49e9914bbc788587d8661a730
BLAKE2b-256 52afa2533bee81c17865e7244a46b6744960df57e3c27c4beae6d4f418f1dc87

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blis-0.7.2-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.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9

File hashes

Hashes for blis-0.7.2-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 56fab3c68f01de86ce9d10da9913e8ac92119904134cfa176e1223ac24422c5d
MD5 dbc0e8e4460d799301991dde95d0b049
BLAKE2b-256 196e5079afeca640eb4a80e5ccdc21cb3c8e089d8db721d844c1fb4ee0b5234e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blis-0.7.2-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.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9

File hashes

Hashes for blis-0.7.2-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 47b4c96f59b036b8172be6edc093fa838d42ae60ee5716843062931b788b6000
MD5 9ff2ffac13c8cd0c022fa5e76bd2b972
BLAKE2b-256 76c9e1f0d6eca16a9809bc729692b7156817ee1dc1c0053917d9ab5ffb0cf80e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blis-0.7.2-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.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9

File hashes

Hashes for blis-0.7.2-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 16ced4d2206b27b114e7d5c3f72880550971e3f9155f29bee5abf21b644b8ae7
MD5 d719fe3d1ef1ba9d7329c7ba1aab0d2a
BLAKE2b-256 23f1da16e03e68179d5ef8a8849a1a139130488ff0fe3eab0cef652d1caf4434

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