Skip to content

Numpy passes invalid arguments to DGEMV when stride = 0 #12156

Closed

Description

@roastduck

When performing a numpy.matmul with a vector, whose stride is 0, Numpy will pass an invalid argument to the LAPACK function DGEMV. More specifically, the incx argument of DGEMV cannot be 0.

Reproducing code example:

import numpy as np
a = np.array([[1., 1., 1., 1.], [1., 1., 1., 1.]])
b = np.broadcast_to(1., (4, 1))
np.matmul(a, b)

Error message:

I tested it on 2 platforms (see the version section below).

On 1.15.2 Linux:

Traceback (most recent call last):
  File "tmp.py", line 4, in <module>
    np.matmul(a, b)
ValueError: On entry to DGEMV parameter number 8 had an illegal value

On 1.13.3 Windows:

 ** On entry to DGEMV  parameter number  8 had an illegal value

Numpy/Python version information:

1.15.2 3.6.6 (default, Sep 12 2018, 18:26:19)
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]]

and

1.13.3 3.5.3 (v3.5.3:1880cb95a742, Jan 16 2017, 16:02:32) [MSC v.1900 64 bit (AMD64)]

Activity

  1. mattip commented on Oct 12, 2018

    @mattip
    Member

    This is something to look at when revisiting PR #11133 which will finally convert matmul to a ufunc. It seems add and einsum are not succeptible to this, but dot is.

  2. mattip commented on Nov 9, 2018

    @mattip
    Member

    PR #12219 has code that fixes this for matmul.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions