Skip to main content

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-py is the intended User Interface that provides a numpy-like layer to execute math and array operations with ArrayFire.
  • arrayfire-binary-python-wrapper is 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 Libraries are 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

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

Metadata

Release files for arrayfire-py 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for arrayfire-py 0.1.0
File Size Uploaded
arrayfire_py-0.1.0.tar.gz 78.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for arrayfire-py 0.1.0
File Interpreter ABI Platform
arrayfire_py-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 165.6 kB

Release files / arrayfire_py-0.1.0.tar.gz

Download URL arrayfire_py-0.1.0.tar.gz
Size 78.6 kB
Tags Source
SHA-256 checksum
How to use checksums
8a5aa6ef7a5b614573f151ab3f193d578f737177cddba813aa3500c681131bd1
BLAKE2b-256 checksum
How to use checksums
d73ac404d582c70ac23c85967b0425e7df40d19871cc9787f73cb67e660c1ae9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.0

Release files / arrayfire_py-0.1.0-py3-none-any.whl

Download URL arrayfire_py-0.1.0-py3-none-any.whl
Size 87.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d9332a9b9899ed059d10b70c2a3684911c1233714e3baaedbbe3358c7e18fc26
BLAKE2b-256 checksum
How to use checksums
9f33387d87116780ae87eb65b241f2d7eee6894496b93b8490e02b79de3975fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.0

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page