Repository navigation
BUG: test, fix matmul, dot for vector array with stride[i]=0 - #12494
Conversation
| assert_equal(func(edf.T, edf), edtdf) | ||
|
|
||
| @pytest.mark.parametrize('func', (np.dot, np.matmul)) | ||
| def test_no_dgemv(self, func): |
There was a problem hiding this comment.
Any reason to just check doubles?
There was a problem hiding this comment.
I'm thinking f, d, c, z, maybe separately for the two inputs. That way can also test the promotion. The advantage is that if the code gets refactored and introduces new code paths. Maybe those cases are already tested somewhere for the usual case?
There was a problem hiding this comment.
It is difficult to test blas functionality
- we have no external indication whether blas is used or not
- we do not get a warning/error if blas is called incorrectly (the
xerblasmechanism is not working correctly). Perhaps it is worthwhile opening an issue for this but the working assumption is we cannot call blas incorrectly.
I determined that my fix works by manually setting a breakpoint at the blas calls and verifying, via runtests.py -vv and manually examining dimensions and strides that the calls were correct, and by noticing that xerblas error messages do not appear on stderr.
While it would be simple to add the other blas-able cases, what would the expected error vs. non-error output be? It is not clear to me there is added value in quadrupling the test.
There was a problem hiding this comment.
Since I was expanding the tests anyway I added the other BLAS dtypes and int as well for good measure.
There was a problem hiding this comment.
I added the other BLAS dtypes and
intas well for good measure
I see you requested combinations of dtypes. This is covered in other tests of the ufunc machinery, that it promotes and copies input where needed.
There was a problem hiding this comment.
Do we need this condition for matmul too? Or does the ufunc machinery ensure this?
There was a problem hiding this comment.
I added the check for "non-zero dimension but stride==0" to matmul as well, see changes to matmul.c.src. Or did I not understand the comment?
There was a problem hiding this comment.
I mean specifically the ((npy_intp)(PyArray_DATA(ap)) % itemsize) != 0 condition - ie. check the alignment of the pointers themselves.
There was a problem hiding this comment.
The ufunc flag NPY_ITER_ALIGNED handles this for us. I added a test and checked that
- the unaligned ndarrays are copied in
nditer_const.c:2914and - when entering
@typ@_matmulpointers are always aligned
1598f2a to
7e04869
Compare
|
Windows Python 3.7 32 bit build is failing when using |
|
I'm rerunning the azure tests, that warning has turned up (once) before and I was thinking something wasn't properly suppressing warnings and they were slipping through from some other spot. We will see if it is repeatable. EDIT: I suppose it could also be in the library. |
|
Here is the other test failure: https://dev.azure.com/numpy/numpy/_build/results?buildId=1133. Different test, Same error, 32 bits, matmul. Are we testing matmul with invalid values anywhere? |
|
The other failure cited is Python 3.6 vs. 3.7 reported here, but both indeed involve matmul with both operands 32-bit Linux Azure is likely using an older openblas backend for now, since it uses apt-get to install the libs (until I sync that with wheels approach), so that may explain Linux vs. Win here. |
|
I'm going to put this in as I suspect that the problem isn't directly due to matmul and looks difficult to pin down. Note that the 32 bit code is likely compiled for a different FPU than the 64 bit code. The warning itself looks harmless, if annoying. Thanks Matti. |
Fixes #12156.
@typ@_gemvto checks before calling `@typ@_gemvgemvis used where possible inmatmul, and that copying is done as necessary indot