BUG: Fix np.einsum errors on Power9 Linux and z/Linux#14693
BUG: Fix np.einsum errors on Power9 Linux and z/Linux#14693mattip merged 7 commits intonumpy:masterfrom jwoehr:einsum_c_buglet
np.einsum errors on Power9 Linux and z/Linux#14693Conversation
|
So clang-tidy warns about: |
I will explore this tomorrow. Thank you for all your help! |
np.einsum errors on Power9 Linux and z/Linux
| * need it to be signed here. | ||
| */ | ||
| label = (signed char)labels[idim]; | ||
| label = labels[idim]; |
| * need it to be signed here. | ||
| */ | ||
| int label = (signed char)labels[idim]; | ||
| int label = labels[idim]; |
There was a problem hiding this comment.
@mattip we did that because it made it work on s390x and power9.
Of course it broke x86_64!
I thought I had reverted to a clean copy of master and made your change.
Now I think I made a MisTeAk :)
I will look at what I did and push again.
If it passes testing, I'll add that, thanks, @mattip |
Hmm, this does not work: |
|
Are you sure you used my code? It looks different to me. |
|
The documented developer workflow is to add tests as part of the development process. I find it helpful to:
This makes sure your fix is correct and prevents unneeded CI runs. In this case, I needed to dive in with gdb to find out exactly what was going wrong so a test was critical to find the missing cast. |
aha :) Lots of parentheses |
|
w/r/t the test case, does it have to test some kind of result, or is it enough that the failure is that an exception is thrown? |
| # Bug with signed vs unsigned char errored on power9 and s390x Linux | ||
| tensor = np.random.random_sample((10, 10, 10, 10)) | ||
| print(np.einsum('ijij->', tensor)) | ||
|
|
There was a problem hiding this comment.
Maybe (please check locally before pushing)
x = np.einsum('ijij->', tensor)
y = tensor.trace(axis1=0, axis2=2).trace()
assert_equal(x, y)
There was a problem hiding this comment.
With floating point, you can't be sure that x and y will be exactly equal. Use assert_allclose with an appropriately small tolerance, or use an integer array for tensor (assuming the test doesn't actually depend on the data type of the array).
There was a problem hiding this comment.
Done; tested on x86_64, power9, and s390x; and pushed.
|
Thanks @jwoehr |
Backport of numpy#14693. Fixes numpy#14692 on Power 9 and z/Linux
Backport of numpy#14693. Fixes numpy#14692 on Power 9 and z/Linux
BUG: fixes #14692 on Power 9 and z/Linux