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.

__array__ and __array_wrap__

See original GitHub issue

A question about the Numpy array interface. cupy.ndarray implements __array__, but it doesn’t work since np.asarray(cupy_array) raises an exception:

ValueError: object __array__ method not producing an array

So unless you have other plans for this method, it should be changed to return a Numpy array.

Do you want a PR? I’d also like to have the __array_wrap_ method, so I’d implement that one as well.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:10 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
okutacommented, May 10, 2018

CuPy uses asynchronous CPU to GPU memory copy by default mode. This is very easy feature because CUDA supports asynchronous execution (kernel launch). But, CuPy does not use asynchronous GPU to CPU memory copy by default. NumPy only supports synchronous execution. So, Python code waits to finish GPU to CPU memory copy. This causes hard to find performance problems.

It seems I understood your comment wrong. A config option handling as it is done in Chainer would be perfectly fine.

It is good if the user can select whether to use __array_wrap__ or not by environment variable or global configure flag.

0reactions
asi1024commented, Jun 16, 2020

We have no plan for it currently, but we will reopen if someone continues the discussion to support it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ruby's Array() and Array.wrap (Example) - GoRails
Learn how to remove conditionals and make your code simpler and more reliable using Ruby and ActiveSupport's Array wrap methods.
Read more >
wrap (Array) - APIdock
Wraps its argument in an array unless it is already an array (or array-like). Specifically: ... Otherwise, returns an array with the argument...
Read more >
Array.wrap — Documentation for rails (3.1.1) - RubyDoc.info
Wraps its argument in an array unless it is already an array (or array-like). Specifically: ... Otherwise, returns an array with the argument...
Read more >
Array - Rails API
Wraps its argument in an array unless it is already an array (or array-like). Specifically: If the argument is nil an empty list...
Read more >
Array.wrap vs Kernel#array - Lucas Mendelowski
Both methods allow to convert an argument into an array but Kernel#Array has additional behavior: It tries to call to_ary and then to_a...
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