ArrayFire is a high performance library for parallel computing with an easy-to-use API. It enables users to write scientific computing code that is portable across CUDA, OpenCL and CPU devices.
This project is a work in progress. It is meant to provide a numpy-like Python interface for the ArrayFire C library, i.e, it provides array functionality, math operations, printing, etc. This is the front-end python library for using ArrayFire. It is currently supported on Python 3.10+.
Here is an example of the library at work:
# Set backend and device (optional: 'cuda', 'opencl', 'oneapi', 'cpu')
af.setBackend(af.BackendType.cuda)
af.setDevice(0)
# Create two 5x5 arrays on the GPU
a = af.randu((5, 5))
b = af.randu((5, 5))
# Perform element-wise addition and matrix multiplication
c = a + b
d = af.matmul(a, b)
# Print the result
print(c, "Element-wise Sum")
print(d, "Matrix Product")
Requirement Details This project is separated into 3 different parts:
arrayfire-py -> arrayfire-binary-python-wrapper -> ArrayFire C Libraries
This means that arrayfire with python each of these parts is needed:
arrayfire-py
is the intended User Interface that provides a numpy-like layer to execute math and array operations with ArrayFire. *** This is the preferred Interface ***arrayfire-binary-python-wrapper
is the wrapper that provides Python direct access to the ArrayFire functions in the C library. This package must have access to ArrayFire binaries.ArrayFire C Libraries
are the binaries obtained from compiling the ArrayFire C/C++ Project. You obtain these easily through installers in the ArrayFire download page.
Install the last stable version of python wrapper:
pip install arrayfire_binary_python_wrapper-0.8.0+af3.10.0-py3-none-linux_x86_64.whl # install required binary wrapper with the 3.10 ArrayFire binaries included
pip install arrayfire-py # install arrayfire python interface library
Install a pre-built wheel:
pip install arrayfire-py -f https://repo.arrayfire.com/python/wheels/arrayfire-python/0.1.0
Building this interface is straight forward using scikit-build-core:
python -m pip install -r dev-requirements.txt
python -m build --wheel
Note: Building this project does not require the arrayfire-binary-python-wrapper package; however, the binary wrapper is needed to run any projects with it
Tests are located in folder tests.
To run the tests, use:
python -m pytest tests/
If you are interested in using ArrayFire through python, we would appreciate any feedback and contributions.
The community of ArrayFire developers invites you to build with us if you are interested and able to write top-performing tensor functions. Together we can fulfill The ArrayFire Mission for fast scientific computing for all.
Contributions of any kind are welcome! Please refer to the wiki and our Code of Conduct to learn more about how you can get involved with the ArrayFire Community through Sponsorship, Developer Commits, or Governance.
If you redistribute ArrayFire, please follow the terms established in the license.
ArrayFire development is funded by AccelerEyes LLC and several third parties, please see the list of acknowledgements for an expression of our gratitude.
- Slack Chat
- Google Groups
- ArrayFire Services: Consulting | Support | Training
The literal mark "ArrayFire" and ArrayFire logos are trademarks of AccelerEyes LLC (dba ArrayFire). If you wish to use either of these marks in your own project, please consult ArrayFire's Trademark Policy