Type annotations not working for DeviceArray
See original GitHub issueMyPy says that jax.interpreters.xla.DeviceArray
has no attribute “shape”, is not indexable, etc. It seems that it points to DeviceArrayBase
—not DeviceArray
, which has the annotations.
I know that type annotations are a work-in-progress. This is just a placeholder issue 😃
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Type Annotation Roadmap for JAX - JAX documentation
This doc attempts to summarize those issues and generate a roadmap for the goals and non-goals of type annotations in JAX. Why do...
Read more >Why does Mypy think adding two Jax arrays returns a numpy ...
numpy.ndarray s returns a NumPy array of bools. Am I doing something wrong? Or is this a bug in MyPy, or Jax's type...
Read more >Troubleshooting and tips — Numba 0.50.1 documentation
My code has an untyped list problem¶. As noted previously the first part of Numba compiling your code involves working out what the...
Read more >TF_JAX_tutorials - Part 4 (JAX and DeviceArray) | Kaggle
What types of array are these? print(f"array_numpy is of type ... for DeviceArray is the time taken to dispatch the work, not the...
Read more >Placing Device Array - Bentley - Product Documentation
The recent type is set as default array for ceiling and floor diffusers and for vertical sprinklers. Left click/snap data point to select...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Okay, that makes sense. Thanks for explaining it. I’ll just block the MyPy errors!
I think there’s a distinction here between “DeviceArray as xla operand” and “DeviceArray as duck type for numpy arrays”. The former should not have numpy-like attributes, the latter should.
This might argue that we need another base class in the hierarchy that defines the interface to the two DeviceArray implementations; I think the reason we haven’t done that is that the two implementations are temporary; somewhere there’s a TODO to unify them again.
Would it serve your purposes to locally disable mypy type checking, and only use the
DeviceArray
annotation for dispatch?