Skip to content

einsum error for mixed subscripts on s390x #12689

@mbanck

Description

@mbanck

Reproducing code example:

import numpy as np
tensor = np.random.rand(10, 10, 10, 10)
np.einsum('ijij->', tensor)

Error message:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/numpy/core/einsumfunc.py", line 1346, in einsum
    return c_einsum(*operands, **kwargs)
ValueError: dimensions in operand 0 for collapsing index 'þ' don't match (19228356 != 10)

Numpy/Python version information:

Debian unstable on s390x

1.16.0rc2 3.7.2 (default, Jan  3 2019, 02:55:40) 
[GCC 8.2.0]

I could not reproduce this on Debian stable (numpy 1.12.1), but 1.15 seems to be affected as well.

So if I add print(tensor[0][0][0]) before the np.einsum it runs fine:

>>> import numpy as np
>>> tensor = np.random.rand(10, 10, 10, 10)
>>> print(tensor[0][0][0])
[0.56143868 0.22681118 0.47354192 0.27676805 0.09566204 0.63877983
 0.4243805  0.91690097 0.2695863  0.28861963]
>>> np.einsum('ijij->', tensor)
51.05293277361482

Also see psi4/psi4#1465 where this bug originated for some more debugging output that might be helpful.

Note that on s390x, a char is unsigned char unless specified otherwise, contrary to x86 architectures.

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