question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Type annotations not working for DeviceArray

See original GitHub issue

MyPy 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:closed
  • Created 2 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
NeilGirdharcommented, May 14, 2021

Okay, that makes sense. Thanks for explaining it. I’ll just block the MyPy errors!

0reactions
jakevdpcommented, May 13, 2021

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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found