Skip to content

Add support for DeviceArray from JAX - #695

Open
gtca wants to merge 1 commit into
scverse:mainfrom
gtca:jax-device-array
Open

gtca wants to merge 1 commit into
scverse:mainfrom
gtca:jax-device-array

Conversation

@gtca

@gtca gtca commented Jan 31, 2022

Copy link
Copy Markdown

Allow AnnData objects have .X as a DeviceArray. Layer support should also be there but seems to currently fail just as it does e.g. for DaskArray, as mentioned in #693.

from jax import random
from anndata import AnnData

x = random.normal(random.PRNGKey(1), (100,10))
adata = AnnData(x)

adata.write("demojax.h5ad")

As mentioned in #659, it would be nice to also get DeviceArray on read in future if possible, currently it is a NumPy Array:

adata = anndata.read("demojax.h5ad")
type(adata.X)
# => numpy.ndarray

@codecov

codecov Bot commented Jan 31, 2022

Copy link
Copy Markdown

Codecov Report

Merging #695 (5eca06f) into master (555f546) will increase coverage by 0.00%.
The diff coverage is 87.50%.

@@           Coverage Diff           @@
##           master     #695   +/-   ##
=======================================
  Coverage   83.14%   83.15%           
=======================================
  Files          34       34           
  Lines        4403     4411    +8     
=======================================
+ Hits         3661     3668    +7     
- Misses        742      743    +1     
Impacted Files Coverage Δ
anndata/compat/__init__.py 83.15% <85.71%> (+0.10%) ⬆️
anndata/_core/anndata.py 83.43% <100.00%> (+0.02%) ⬆️

@ivirshup

Copy link
Copy Markdown
Member

I would support JAX as another backend.

Would probably be worth opening another issue for tracking JAX as a backend. For IO, I was thinking that could be done with #659

@gtca gtca mentioned this pull request Jan 31, 2022

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants