Skip to main content

A fast math and neural network library for Python and C++

Project description

Build Status Documentation Status PyPI version fury.io PyPI license PyPI pyversions Downloads per month Discord

Credits

Thanks to @Windoof-Colourblindoof for his help on the library

How it Works

LibRapid is a fully templated header-only C++ library, which can be found at ./librapid/. The C++ library is then interfaced with Python using the amazing PyBind11 library, meaning very little performance is lost between the C++ and Python versions of the library.

LibRapid also aims to provide a consistent interface between the C++ and Python libraries, allowing you to use the library comprehensively in both language.

Additionally, the Python interface has been adjusted slightly from the C++ interface, providing a more "pythonic" feel, while not reducing the functionality in the slightest.

Installing LibRapid

To install LibRapid as a Python library, simply run pip install librapid in the command line. Hopefully, there will be precompiled wheels available for your operating system and python version, meaning you will not need a C++ compiler to install it (if this is not the case, a modern C++ compiler will be required)

To use the library for C++ use, a modern C++ compiler will definitely be required. To use the library simply add the directory of this file to your extra include paths, and include the library using #include<librapid/librapid.hpp>

Documentation

Unfortunately, the documentation cannot currently be built by ReadTheDocs due to a bug in the version of Doxygen they are using. It would seem that the systems will be getting an upgrade in the near future, hopefully moving to a newer version of Doxygen, though this is still not certain.

If you would like to view the documentation, you will have to build it yourself. This is very simple once you have the correct software installed, most of which can be installed via pip.

pip install sphinx
pip install breathe
pip install exhale
pip install furo

You will also need to install a recent version of Doxygen, which you can find here

To build the documentation, open a command line window in the docs directory and run make html. You can then open the file docs/build/html/index.html in a web-browser to view the documentation.

Hopefully, the documentation will be available online in the near future, so you will not have to build it yourself...

Performance

LibRapid has highly optimized functions and routines, meaning your code will be faster as a result. Many of the functions can match or even exceed the performance of NumPy

Both the C++ and Python libraries are designed to work with any CBLAS compatible library, such as ATLAS or OpenBLAS, though will be fully functional without one, using built-in, but slower, routines.

To use BLAS in C++, simply allow LibRapid to find the cblas.h file by adding its directory to the additional include paths, and link the required library, such as libopenblas.lib on Windows. Finally, before you #include<librapid/librapid.hpp>, you'll have to #define LIBRAPID_CBLAS to let LibRapid know it should use the provided BLAS library.

For the Python API to LibRapid, things are much simpler. If you install the library via pip, it should come precompiled with OpenBLAS, so you don't have to do anything yourself.

Unfortunately, when building OpenBLAS for the Python wheels, they are designed to be optimal on the build system, which is often use very different hardware to normal users. For this reason, the BLAS installs are often not optimal, and may lead to strange and inconsistent speeds while running. To mitigate this slightly, we recommend you install a BLAS library on your machine and then build LibRapid from source if you want to get the most out of it.

LibRapid will automatically search some specific directories for OpenBLAS, though if you have it installed in a differnet place, or you have a different library installed alltogether, you can specify where LibRapid should search for the files when you build it from the command line.

The following command line options are available
They should be used as follows:
e.g. --blas-dir=c:/opt/openblas

Options:
--no-blas	   << Do not attempt to link against any BLAS library
				   Use only the pre-installed routines (which are slower)
--blas-dir	  << Set the directory where LibRapid can find a CBlas
				   compatible library. LibRapid will expect the directory
				   to contain a file structure like this (Windows example):

				   blas-dir
                   ├── bin
                   |   └── libopenblas.dll
                   ├── include
                   |   └── cblas.h
                   └── lib
                       └── libopenblas.lib
--blas-include  << Set the BLAS include directory. LibRapid will expect
				   cblas.h to be in this directory
--blas-lib	  << Set the BLAS library directory. LibRapid will expect
				   a library file to be here, such as libopenblas.lib
				   or openblas.a
--blas-bin	  << Set the directory of the BLAS binaries on Windows.
				   LibRapid will search for a DLL file

To build LibRapid from source and specify commands, use the following commands:

git clone https://github.com/Pencilcaseman/librapid.git
cd librapid
python setup.py sdist --blas-dir=C:/opt/openblas
#					 ^~~~~~~~~~~~~~~~~~~~~~~~~~
#					 Change this to your arguments
pip install .

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

librapid-0.1.5.tar.gz (1.8 MB view hashes)

Uploaded Source

Built Distributions

librapid-0.1.5-cp39-cp39-win_amd64.whl (856.4 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

librapid-0.1.5-cp39-cp39-win32.whl (672.9 kB view hashes)

Uploaded CPython 3.9 Windows x86

librapid-0.1.5-cp39-cp39-manylinux2010_x86_64.whl (2.1 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.12+ x86-64

librapid-0.1.5-cp39-cp39-manylinux2010_i686.whl (296.9 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.12+ i686

librapid-0.1.5-cp39-cp39-macosx_10_9_x86_64.whl (1.5 MB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

librapid-0.1.5-cp38-cp38-win_amd64.whl (860.8 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

librapid-0.1.5-cp38-cp38-win32.whl (672.7 kB view hashes)

Uploaded CPython 3.8 Windows x86

librapid-0.1.5-cp38-cp38-manylinux2010_x86_64.whl (2.1 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

librapid-0.1.5-cp38-cp38-manylinux2010_i686.whl (296.7 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.12+ i686

librapid-0.1.5-cp38-cp38-macosx_10_9_x86_64.whl (1.5 MB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

librapid-0.1.5-cp37-cp37m-win_amd64.whl (860.1 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

librapid-0.1.5-cp37-cp37m-win32.whl (672.3 kB view hashes)

Uploaded CPython 3.7m Windows x86

librapid-0.1.5-cp37-cp37m-manylinux2010_x86_64.whl (2.1 MB view hashes)

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

librapid-0.1.5-cp37-cp37m-manylinux2010_i686.whl (299.8 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.12+ i686

librapid-0.1.5-cp37-cp37m-macosx_10_9_x86_64.whl (1.5 MB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

librapid-0.1.5-cp36-cp36m-win_amd64.whl (860.1 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

librapid-0.1.5-cp36-cp36m-win32.whl (672.3 kB view hashes)

Uploaded CPython 3.6m Windows x86

librapid-0.1.5-cp36-cp36m-manylinux2010_x86_64.whl (2.1 MB view hashes)

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

librapid-0.1.5-cp36-cp36m-manylinux2010_i686.whl (299.7 kB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.12+ i686

librapid-0.1.5-cp36-cp36m-macosx_10_9_x86_64.whl (1.5 MB view hashes)

Uploaded CPython 3.6m macOS 10.9+ x86-64

Supported by

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