-
Within sparsified-functions, does a In my use case: @jit
@sparse.sparsify
def my_func(a: jnp.ndarray | sparse.BCOO) -> jnp.ndarray:
# Section that works with or without sparse arrays
# ...
# result: jnp.ndarray | sparse.BCOO = ...
# ...
result: jnp.ndarray = result.todense()
# If result is:
# - dense -> return itself (no operation)
# - sparse -> convert to dense
# Section that only works with dense arrays
# ...
# ...
return result I suppose it's like putting if isinstance(result, sparse.BCOO):
result = result.todense() However, I don't think this works. |
Beta Was this translation helpful? Give feedback.
Answered by
jakevdp
May 26, 2023
Replies: 1 comment 1 reply
-
You can use |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
edavisau
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can use
sparse.todense
for this