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

Uploaded Source

Built Distributions

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

Uploaded CPython 3.9 Windows x86-64

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

Uploaded CPython 3.9

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

Uploaded CPython 3.8 Windows x86-64

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

Uploaded CPython 3.8

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

Uploaded CPython 3.7m Windows x86-64

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

Uploaded CPython 3.7m

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

Uploaded CPython 3.6m Windows x86-64

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

Uploaded CPython 3.6m

blis-0.7.3-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.3.tar.gz.

File metadata

  • Download URL: blis-0.7.3.tar.gz
  • Upload date:
  • Size: 2.6 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.53.0 CPython/3.7.9

File hashes

Hashes for blis-0.7.3.tar.gz
Algorithm Hash digest
SHA256 19557b14763253ca3d4f6cfc9c9fe2eed3d65db14fa273ced8b0c17ce2bfda4a
MD5 c00f1baa08a7b419f7540af93f54157b
BLAKE2b-256 3b5b7f15e2db542e3df9ff04cf21a54d4e89ed778453fcb47cff1e4ee8636a6e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blis-0.7.3-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.53.0 CPython/3.7.9

File hashes

Hashes for blis-0.7.3-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 55bacf2a1eb72ae728b665ac46433bcfee670de84f9bdf99987adf836fd92309
MD5 6af749591db33564cb6993ed9c6c4a82
BLAKE2b-256 5d15a72e70c038905a43e2f076cf41b2723ed70c80a2af2d1e1c82997c6f8da2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blis-0.7.3-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.53.0 CPython/3.7.9

File hashes

Hashes for blis-0.7.3-cp39-cp39-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ca0bccd31a216931ada487264ad07fa64a0b5a42b51c80cdebb1d3764b813d3b
MD5 6e4629b06a3b5ff45d89c387e1899d40
BLAKE2b-256 2d9ea386f9c6df1131259e29a7073d9b02bd91501495be59318b2158380f9790

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blis-0.7.3-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.53.0 CPython/3.7.9

File hashes

Hashes for blis-0.7.3-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 9130e194f01124975a7bd76b8b65550f1f308610d596ec1992280b656e0c11be
MD5 6a6af2c27a26d4fbd1e59a749ef24ddb
BLAKE2b-256 9f03e43155b5d2a0bd0cab6842bdae2c171d4817fe6dc1466e1ecd700e7c3a82

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blis-0.7.3-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.53.0 CPython/3.7.9

File hashes

Hashes for blis-0.7.3-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 e4e8b0dfd32e12f6d380b77a916ef15793756b856d8b00453a7d0ed4ba29f9ea
MD5 68b82b489c5e34d475344f8d59520551
BLAKE2b-256 56bf52f571422fee4a98b85eabbb396ccc9189d702bc1ffe0ae14dca8efcc694

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blis-0.7.3-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.53.0 CPython/3.7.9

File hashes

Hashes for blis-0.7.3-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 59cc549e904fd4169105f92d6fac94495eca228c357232f29444ae79981af974
MD5 0814affc48a099ee8bb8c2c14234d9ef
BLAKE2b-256 f294e12627df94d56c2c84cf657359229970e6ca821514c3ed2a660d7a86a8ca

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blis-0.7.3-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.53.0 CPython/3.7.9

File hashes

Hashes for blis-0.7.3-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 c04165d196e16f652d21c2d1403a55fbae8721d74dbca1668fdfec6766687a12
MD5 6af85e5fd9a52b1837d5acdedbef238b
BLAKE2b-256 ea6610679290ec06b441e1bae731d13b983c75a8d2f3f5b34f78e8857cbb8d8d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blis-0.7.3-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.53.0 CPython/3.7.9

File hashes

Hashes for blis-0.7.3-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 7f3e9564023e59a0abe9642a94408b3d2fe05ff205d800d512a67828b61819a8
MD5 7847ab5dcad1c59f6589caaf41d1f6bb
BLAKE2b-256 1ba1aca8763d7dab13280254554f9052d5f7b611ee87dae281966bf61ff18ad6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blis-0.7.3-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.53.0 CPython/3.7.9

File hashes

Hashes for blis-0.7.3-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 221eef1b351063b0eb6682c7af2916884ce6c5015d95f6a28b7e45bea35e493c
MD5 78e000a8ef9600f7bfe09ddb0f73573b
BLAKE2b-256 272f0e41a4886dae27261ee45341f28d3fba5746173a751da22482f999bddc41

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blis-0.7.3-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.53.0 CPython/3.7.9

File hashes

Hashes for blis-0.7.3-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 ae53b880a1bca8115f1edccfa6e8800661c71347f9b75ed3f1af8549f080dd6b
MD5 7e7fba3e30be25e4a00cd13a8caf55ba
BLAKE2b-256 436236b3894ae5f0eba562fc7e7f1a00e84d823b1f413de69c694c363e6c01a3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blis-0.7.3-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.53.0 CPython/3.7.9

File hashes

Hashes for blis-0.7.3-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 b0fa63e4ca21a189698ca764367ae91ccba2274d885563c81205c1ac09f36fa6
MD5 448ba48f67ac5812aa8e1eb2cd459bcc
BLAKE2b-256 cd50395b6efef3dd963b134256ab1849602a523c9c7eef33303379455d7fefaf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blis-0.7.3-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.53.0 CPython/3.7.9

File hashes

Hashes for blis-0.7.3-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6e65ef84205fadc1c41e59bd9d0d67fca8c41d463761b2dfe447003840172062
MD5 24eaf387575309b1dd007d5247170baa
BLAKE2b-256 6eeeeec9aafcc65083ee0762edf968b5f2fe3165ce690c6f41ceb490ae98ad02

See more details on using hashes here.

File details

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

File metadata

  • Download URL: blis-0.7.3-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.53.0 CPython/3.7.9

File hashes

Hashes for blis-0.7.3-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 3917491f366467a7339997dcfe501a282409cc50f461c6e1491d342a424442f1
MD5 6b8b84f32a12861d5bf7d03d4c5e9136
BLAKE2b-256 71ca20002769fa698a9f5528ac62f097ca0608bdf8b7caab72201d67f79c47bf

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