-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: Should we allow querying certain implementation details #499
Comments
Should this be a query on the namespace or on an array object? |
I was thinking of namespace, but maybe immutability would need to be array object specific and not namespace... I suppose we can probably close this for now though, I think it may be useful to "bag" details, but right now I am not sure if users actually have a need for any information :). |
@seberg Can you think of any practical use cases where an array API consumer would/should branch based on the implementation info you mention in the OP? E.g., what would be an example of when an array API consumer should be concerned with whether an array library supports mutation? You mention determining whether a copy is needed; any practical examples of where this would be applicable and a downstream library responsibility rather than in the array library itself? |
The thing why I was wondering was the discussion about esuring you have a copy:
|
In the meeting there were a few other things that came up and may be interesting:
|
I assume the second line was supposed to be For the other things, that seems like potentially useful info when using a single library. But when you're using the standard API, I'm wondering what you are going to do with something like "yes, supports non-native byte order". Because it doesn't come back anywhere else in the API, so it seems more like an FYI. The actual dtypes and devices I can imagine using; they can be passed on to |
I was reminded of this issue because of gh-609. It's still a pain that we have data-dependent features in the API that are optional to implement. So for writing portable and performant code across those libraries that do and don't perform it, we need something like: if xp.supports_dynamic_shapes:
y = x[mask]
z = xp.nonzero(x)
...
else:
# longer workarounds
... This is the most concrete case that needs library-specific querying I think. Unless we can avoid any optional features at all in the standard, those should be introspectable somehow. |
Another reason to support querying supported dtypes: JAX may or may not support double-precision dtypes, depending if they're enabled. In practice the respective dtype objects ( >>> from jax import numpy as jnp
>>> jnp.int64
>>> jnp.asarray(1, dtype=jnp.int64)
UserWarning: Explicitly requested dtype <class 'jax.numpy.int64'> requested in asarray is not available, and will be truncated to dtype int32. To enable more dtypes, set the jax_enable_x64 configuration option or the JAX_ENABLE_X64 shell environment variable. See https://github.com/google/jax#current-gotchas for more.
Array(1, dtype=int32) Currently in Hypothesis and Just like with
|
Maybe we should standardize libraries being able to not support a subset of the dtypes. Right now all dtypes are required, and libraries like PyTorch and JAX are strictly out of compliance by not including them. |
JAX does include all dtypes – just run the tests with |
Right, and this could just be fine for practical applications of using JAX + Array API. My concern is downstream libraries need to know they're dealing with JAX so they can enable this (or avoid double-precision dtypes), which hurts the use case a bit using this spec. |
I am wondering if it would make sense to standardize a bit of information about the exported namespace. For example
I somewhat suspect that such information will be useful eventually, but not sure that we have anything explicit right now that would be.
The text was updated successfully, but these errors were encountered: