Skip to content

BUG: einsum all zero for float16 #20305

@joergdietrich

Description

@joergdietrich

Describe the issue:

Starting with numpy-1.21.0 (at least some) einsum operations for arrays with dtype=np.float16 yield all zero results.

Reproduce the code example:

import numpy as np

a = (np.linspace(0, 301, 300).reshape(10, 10, 3) / 301).astype(np.float16)
mat = np.array([[0.39, 0.54, 0.0089], [0.07, 0.96, 0.001], [0.02, 0.13, 0.94]], dtype=np.float16)
assert np.all((a @ mat.T) != 0)
assert np.all(np.einsum("ij, ...j", mat.astype(np.float32), a.astype(np.float32)) != 0)
assert np.all(np.einsum("ij, ...j", mat, a) != 0)

Error message:

No response

NumPy/Python version information:

1.21.2 3.8.12 (default, Oct 12 2021, 13:49:34)
[GCC 7.5.0]

Metadata

Metadata

Assignees

No one assigned

    Labels

    00 - BugPriority: highHigh priority, also add milestones for urgent issues

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions