GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - 34j/array-api-jit: JIT decorator supporting multiple array API compatible libraries

BranchesTags
Open more actions menu

Latest commit

 

History

461 Commits
461 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
docs
docs
 
 
src/array_api_jit
src/array_api_jit
 
 
tests
tests
 
 
.copier-answers.yml
.copier-answers.yml
 
 
.gitignore
.gitignore
 
 
.pre-commit-config.yaml
.pre-commit-config.yaml
 
 
.readthedocs.yml
.readthedocs.yml
 
 
CHANGELOG.md
CHANGELOG.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
pyproject.toml
pyproject.toml
 
 
renovate.json
renovate.json
 
 
uv.lock
uv.lock
 
 

Repository files navigation

array API JIT

CI Status Documentation Status

Test coverage percentage uv Ruff prek

PyPI Version Supported Python versions License


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 typing import Any

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

About

JIT decorator supporting multiple array API compatible libraries

Topics

array-apicupyjaxjitnumbapytorch

Resources

Readme
MIT license

Code of conduct

Code of conduct
Activity

Stars

2 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.