JIT decorator supporting multiple array API compatible libraries
Project description
array API JIT
Documentation: https://array-api-jit.readthedocs.io
Source Code: https://github.com/34j/array-api-jit
JIT decorator supporting multiple array API compatible libraries
Installation
Install this via pip (or your favourite package manager):
pip install array-api-jit
Usage
Simply decorate your function with @jit():
from array_api_jit import jit
@jit()
def my_function(x: Any) -> Any:
xp = array_namespace(x)
return xp.sin(x) + xp.cos(x)
Advanced Usage
You can specify the decorator, arguments, and keyword arguments for each library.
from array_api_jit import jit
from array_api_compat import array_namespace
from typing import Any
import numba
@jit(
{"numpy": numba.jit()}, # numba.jit is not used by default because it may not succeed
decorator_kwargs={
"jax": {"static_argnames": ["n"]}
}, # jax requires for-loop variable to be "static_argnames"
# fail_on_error: bool = False, # do not raise an error if the decorator fails (Default)
# rerun_on_error: bool = True, # re-run the original function if the wrapped function fails (NOT Default)
)
def sin_n_times(x: Any, n: int) -> Any:
xp = array_namespace(x)
for i in range(n):
x = xp.sin(x)
return x
Contributors ✨
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
Credits
This package was created with Copier and the browniebroke/pypackage-template project template.
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 array_api_jit-1.0.0.tar.gz.
File metadata
- Download URL: array_api_jit-1.0.0.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a896153e17357f87c31f3fe24303917efe5ade8d61d901760fb12faf40889e93
|
|
| MD5 |
26cf5e86a9dd8bb8276c6c7f4dda5da7
|
|
| BLAKE2b-256 |
e7955bddfb7e45188c8e3ad8a1c7ebfae0f5f230cbf26539d171a63bd728e9ae
|
Provenance
The following attestation bundles were made for array_api_jit-1.0.0.tar.gz:
Publisher:
ci.yml on 34j/array-api-jit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
array_api_jit-1.0.0.tar.gz -
Subject digest:
a896153e17357f87c31f3fe24303917efe5ade8d61d901760fb12faf40889e93 - Sigstore transparency entry: 273206342
- Sigstore integration time:
-
Permalink:
34j/array-api-jit@cc6b5738027e0d2eb86e72015b70f79c3bb86bd3 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/34j
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@cc6b5738027e0d2eb86e72015b70f79c3bb86bd3 -
Trigger Event:
push
-
Statement type:
File details
Details for the file array_api_jit-1.0.0-py3-none-any.whl.
File metadata
- Download URL: array_api_jit-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a60dddcae6ed7f523b0d3cfcbfe3a850d75ec02f07c99ca96869e0ff27027ce9
|
|
| MD5 |
c77bca25dc20d851367c523abb741adf
|
|
| BLAKE2b-256 |
8fda7dda387073f2044e7e35327cbd89c77ae8e1546d85914a1058b5ca371d23
|
Provenance
The following attestation bundles were made for array_api_jit-1.0.0-py3-none-any.whl:
Publisher:
ci.yml on 34j/array-api-jit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
array_api_jit-1.0.0-py3-none-any.whl -
Subject digest:
a60dddcae6ed7f523b0d3cfcbfe3a850d75ec02f07c99ca96869e0ff27027ce9 - Sigstore transparency entry: 273206344
- Sigstore integration time:
-
Permalink:
34j/array-api-jit@cc6b5738027e0d2eb86e72015b70f79c3bb86bd3 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/34j
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@cc6b5738027e0d2eb86e72015b70f79c3bb86bd3 -
Trigger Event:
push
-
Statement type: