dgasmith / opt_einsum

⚡️Optimizing einsum functions in NumPy, Tensorflow, Dask, and more with contraction order optimization.
https://dgasmith.github.io/opt_einsum/
MIT License
863 stars 68 forks source link

Support for Python array API standard #197

Open IsaacBreen opened 2 years ago

IsaacBreen commented 2 years ago

Description

This PR adds support for libraries that conform to the Python array API standard. It discovers complying modules upon import of opt_einsum.

Eventually (and hopefully soon), once the array API standard becomes ubiquitous, this should largely eliminate the need for backend-specific code.

Note that to test this you'll need a version of an array library which implements the API. Right now AFAIK closest thing to this is latest (dev) Numpy which you can install using

pip install --upgrade git+https://github.com/numpy/numpy

Todos

Status

codecov[bot] commented 2 years ago

Codecov Report

Merging #197 (13ec280) into master (3824e4f) will decrease coverage by 0.03%. The diff coverage is 94.59%.

dgasmith commented 2 years ago

Looks like plenty of errors for Py3.6 where importlib.metadata is not yet extant.

IsaacBreen commented 2 years ago

Thanks Daniel! The errors for Python <= 3.7 should be fixed. I've set it to bypass array API backend discovery altogether in such cases. Numpy doesn't support <= 3.7 as-is, so I don't think this will be missed.

I've fixed up the formatting too.

dgasmith commented 6 months ago

@IsaacBreen I'm looking to push out another release in the next month or so. Is this a PR which you would like to support?