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.

Incorrect conversion of lists of 64bit integers to gpu arrays

See original GitHub issue

Bug Report - configuration

image

Running on Windows 10

The issue is that lists of 64bit integers are not converted correctly into cp.arrays

It can be reproduced as follows:

test = [2573020360226874006, 3380361604350789900, 4859923904345895640, 13687853399390180967, 16475680397989516969, 8413489444449950533, 4333554764184432370, 13215310408000716975, 15906314169209076444, 17387510412753931294, 6028071322898499234, 16651433382521050141, 11906124862927954832, 979032581609386549, 5383903860231400189, 16652641017451004624, 15871139766918146343, 4661974178869933332, 3322890582509810852, 17649772750313323333, 824394798278675654, 12857473083203380187, 16119292278949315428, 14648959056030599120, 10539519158706861807, 4366277000092173836, 14237082960957713612, 5623713326724130520, 9914768004517060519, 13826579745269136000, 6101004116528261025, 4458758065694168679, 11859919194022480483, 17537291372562664748, 16149246031423335313, 14355574868047584244, 14165223344939497507, 2973902102188211656, 16605421214039893230, 3459125478745811629, 921400222035455189, 14191305326974539603, 8994877222995548978, 2099139231298491946, 9560763749503338206, 16247150519901465084, 8197211126911646074, 16215376013475873186, 1096754051517406064, 17000571446302180434, 3228558886738455707, 12217908161957442404, 6562940879085228772, 15364267318039491253, 2379598766051150479, 6215650434422663905, 1293951399180503783, 16793136955401183251, 16529564886689430725, 16264789201698540098, 10463105180469592213, 18417394357193882546, 13581292426433423738, 12371948219843082147, 6536602567647166292, 6994100351257288730, 4288161508265335848, 3387912978422292827, 11742745234146627098, 3279093825843023262]
[[ 2573020360226873856  3380361604350790144  4859923904345895936]

z = cp.array([test]).astype(cp.uint64)
print(z)

On my machine, it produces the following output:

[[ 2573020360226873856 3380361604350790144 4859923904345895936 13687853399390181376 16475680397989517312 8413489444449950720 4333554764184432128 13215310408000716800 15906314169209075712 17387510412753932288 6028071322898499584 16651433382521051136 11906124862927953920 979032581609386496 5383903860231400448 16652641017451003904 15871139766918146048 4661974178869933056 3322890582509810688 17649772750313322496 824394798278675712 12857473083203379200 16119292278949314560 14648959056030599168 10539519158706862080 4366277000092173824 14237082960957714432 5623713326724130816 9914768004517060608 13826579745269135360 6101004116528261120 4458758065694168576 11859919194022479872 17537291372562665472 16149246031423334400 14355574868047583232 14165223344939497472 2973902102188211712 16605421214039894016 3459125478745811456 921400222035455232 14191305326974539776 8994877222995549184 2099139231298491904 9560763749503338496 16247150519901464576 8197211126911645696 16215376013475872768 1096754051517406080 17000571446302181376 3228558886738455552 12217908161957441536 6562940879085229056 15364267318039490560 2379598766051150336 6215650434422664192 1293951399180503808 16793136955401183232 16529564886689431552 16264789201698539520 10463105180469592064 18417394357193881600 13581292426433423360 12371948219843082240 6536602567647166464 6994100351257288704 4288161508265335808 3387912978422292992 11742745234146627584 3279093825843023360]]

As you can see, the numbers are similar but not exactly the same. However, if you do this on an individual number, it works correctly.

test = [2573020360226874006]
print(test)
z = cp.array([test]).astype(cp.uint64)
print(z)

you get the correct result: [[2573020360226874006]]

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
kmaehashicommented, Apr 28, 2020

In CuPy, basically we only document the difference from NumPy (as the NumPy spec itself is really really complicated, especially regarding dtypes). This behavior is documented in: https://numpy.org/doc/stable/reference/generated/numpy.array.html

dtype: data-type, optional The desired data-type for the array. If not given, then the type will be determined as the minimum type required to hold the objects in the sequence.

0reactions
leofangcommented, Apr 29, 2020

Would be nice to include a pointer: numpy/numpy#16030

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bits list to integer in Python - Stack Overflow
I have such list in Python: [1,0,0,0,0,0,0,0] . Can I convert it to integer like as I've typed 0b10000000 (i.e. convert to 128)?...
Read more >
JavaScript typed arrays - MDN Web Docs
JavaScript typed arrays are array-like objects that provide a mechanism for reading and writing raw binary data in memory buffers.
Read more >
64-bit signed integer arrays - MATLAB - MathWorks
If you have an array of a different type, such as double or single , then you can convert that array to an...
Read more >
CUDA C++ Programming Guide - NVIDIA Documentation Center
The Graphics Processing Unit (GPU)1 provides much higher instruction throughput and memory bandwidth than the CPU within a similar price and power envelope....
Read more >
Getting Started - ArrayFire
Most of these data types are supported on all modern GPUs; however, some older devices may lack support for double precision arrays.
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