ArrayFire Python
Project description
arrayfire-py
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, oneAPI and CPU devices.
This project is meant is meant to provide an easy to use 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:
import arrayfire as af
# Set any backend and device (optional: 'cuda', 'opencl', 'oneapi', 'cpu')
af.set_backend(af.BackendType.cuda)
af.set_device(0)
# Monte Carlo estimation of pi
def calc_pi_device(samples):
# Simple, array based API
# Generate uniformly distributed random numers
x = af.randu(samples)
y = af.randu(samples)
# Supports Just In Time Compilation
# The following line generates a single kernel
within_unit_circle = (x * x + y * y) < 1
# Intuitive function names
return 4 * af.count(within_unit_circle) / samples
Find out more in our examples directory or just read the documentation.
Prequisites and Installing
This project provides the python interface to ArrayFire, however it requires access to the ArrayFire binaries as a prequisite. The dependency chain can be separated into 3 different parts as follows:
arrayfire-py -> arrayfire-binary-python-wrapper -> ArrayFire C Libraries
To run arrayfire with python each of these parts is needed:
arrayfire-pyis the intended User Interface that provides a numpy-like layer to execute math and array operations with ArrayFire.arrayfire-binary-python-wrapperis a thin wrapper that provides Python direct access to the ArrayFire functions in the C library. This package must have access to ArrayFire binaries, either through a system-wide install, or through a pre-bundled wheel that includes binaries.ArrayFire C Librariesare the binaries obtained from compiling the ArrayFire C/C++ Project or more simply by downloading installers in the ArrayFire download page. Binaries can also be obtained as part of a pre-packaged arrayfire-binary-python-wrapper wheel.
Install the python wrapper with existing ArrayFire install:
# install required binary wrapper, assumes ArrayFire binaries will be installed on the system
pip install arrayfire-binary-python-wrapper
pip install arrayfire-py # install arrayfire python interface library
Install wrapper with a pre-built wheel:
# will grab a binary wrapper with included pre-built binaries
pip install arrayfire-binary-python-wrapper -f https://repo.arrayfire.com/python/wheels/3.10.0/
pip install arrayfire-py
Running Tests
Tests are located in folder tests.
To run the tests, use:
python -m pytest tests/
Building
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
Experimental Array API support
This wrapper is exploring an experimental implementation of the DataAPIs array API standard in this directory with the goal of allowing ArrayFire to seamlessly interoperate with the broader Python landscape. Some portions of the standard are still unimplemented however some simpler examples are working.
Contributing
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.
Citations and Acknowledgements
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.
Support and Contact Info
- Slack Chat
- Google Groups
- ArrayFire Services: Consulting | Support | Training
Trademark Policy
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
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file arrayfire_py-0.1.0.tar.gz.
File metadata
- Download URL: arrayfire_py-0.1.0.tar.gz
- Upload date:
- Size: 78.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a5aa6ef7a5b614573f151ab3f193d578f737177cddba813aa3500c681131bd1
|
|
| MD5 |
ed628950f5f3f1374a6ecd06b5229c5f
|
|
| BLAKE2b-256 |
d73ac404d582c70ac23c85967b0425e7df40d19871cc9787f73cb67e660c1ae9
|
File details
Details for the file arrayfire_py-0.1.0-py3-none-any.whl.
File metadata
- Download URL: arrayfire_py-0.1.0-py3-none-any.whl
- Upload date:
- Size: 87.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d9332a9b9899ed059d10b70c2a3684911c1233714e3baaedbbe3358c7e18fc26
|
|
| MD5 |
8ceafa75fe73180fe88eb3ee5f8cca4e
|
|
| BLAKE2b-256 |
9f33387d87116780ae87eb65b241f2d7eee6894496b93b8490e02b79de3975fc
|