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.

np.divide.accumulate gives incorrect results for float64 on Numpy 1.15.0 using Intel compiler

See original GitHub issue

I have a unit test failing on np.divide.accumulate with numpy 1.15.0 compiled with the Intel compiler. The same code is fine with a local build of GCC.

Perhaps this is related to ENH: umath: don’t make temporary copies for in-place accumulation (https://github.com/numpy/numpy/pull/10665) where @juliantaylor fixed numpy/core/src/umath/loops.c.src for GCC’s ivdep pragma. That was reviewed by @eric-wieser .

Reproducing code example

Source code was 1.15.0 compiled with the Intel compiler 2018.1.163. where np.divide.accumulate fails in the numpy unit tests.

I can reproduce with this Python 2.7 test case for float64 dtype. It runs correctly for float32 and float128 on the Intel compiler. It also runs correctly for float64 using GCC instead of Intel.

$ python -c "import numpy as np; acc = np.divide.accumulate;  
  a = np.ones(8, dtype=np.float64);  
  print acc(a, out=2*np.ones_like(a)); print acc(a); print acc(a); print acc(a); 
  print acc(a, out=2*np.ones_like(a))"
[1. 1. 2. 2. 2. 2. 2. 2.]
[1. 1. 1. 1. 2. 2. 2. 2.]
[1. 1. 1. 1. 1. 1. 2. 2.]
[1. 1. 1. 1. 1. 1. 1. 1.]
[1. 1. 2. 2. 2. 2. 2. 2.]

Notice how only the next two elements are set each time np.divide.accumulate runs. That suggests the float64s are being processed in pairs. Then in the final line, specifying the output array again returns to the first line’s incorrect behavior.

Numpy/Python version information:

numpy 1.15.0 build with ICC 2018.1.163.
python 2.7.11 built with GCC 4.9.3.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:26 (19 by maintainers)

github_iconTop GitHub Comments

1reaction
sebergcommented, May 23, 2019

Thanks @svenevs just in case, one thing that would be nice is to ensure that our test suits finds these errors (if possible). Probably that is already the case, but if not it would be good to add them. After that anyone using these compilers will know that something is off.

1reaction
sebergcommented, Feb 18, 2019

@svenevs you should probably start with doing modifications here:

https://github.com/numpy/numpy/blob/1dfb0ab7358b0cae068b41b3d07452713594ef6b/numpy/core/src/umath/loops.c.src#L1820

which are the loops that get executed for the typical floating point types. Note that “kind” in that code bunch can be divide

Read more comments on GitHub >

github_iconTop Results From Across the Web

Numpy integer division sometimes yields wrong results when ...
I am very confused because with some numbers it gives the same results and with some it doesn't. >>> import numpy as np...
Read more >
Release Notes — NumPy v1.15 Manual
This is a bugfix release for bugs and regressions reported following the 1.15.3 release. The Python versions supported by this release are 2.7, ......
Read more >
Release Notes — NumPy v1.16 Manual
This NumPy release is the last one to support Python 2.7 and will be maintained as a long term release with bug fixes...
Read more >
Diff - xinyu7030/numpy - Gitiles - GerritHub.io
Currently, the most robust -option is to use the Intel compilers, or alternatively MSVC (the same version -as used to build Python itself)...
Read more >
Release 1.15.0
It will work on machines with and without Nvidia GPUs. tensorflow-gpu will still be available, and CPU-only packages can be downloaded at tensorflow-cpu...
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