Skip to content

dpnp.einsumdiffers with numpy in the memory layout #3056

Description

@abagusetty

For a contraction over C-contiguous operands, dpnp.einsum returns a strided array while numpy.einsum returns a C-contiguous. computed output is correct

Reproducer

import numpy as np
import dpnp

ha = np.random.random((4, 5))
hb = np.random.random((5, 6))

n_out = np.einsum("ij,jk->ik", ha, hb)
d_out = dpnp.einsum("ij,jk->ik", dpnp.asarray(ha), dpnp.asarray(hb))

print(n_out.flags.c_contiguous, n_out.strides)  # True  (48, 8)
print(d_out.flags.c_contiguous, d_out.strides)  # False (8, 32)
print(np.abs(dpnp.asnumpy(d_out) - n_out).max())  # ~2e-16, values agree

output:

True (48, 8)
False (8, 32)
2.220446049250313e-16

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions