Skip to content

Fix dpnp.einsum memory-layout - #3058

Open
abagusetty wants to merge 3 commits into
IntelPython:masterfrom
abagusetty:fix-einsum-order-k-contiguity
Open

Fix dpnp.einsum memory-layout#3058
abagusetty wants to merge 3 commits into
IntelPython:masterfrom
abagusetty:fix-einsum-order-k-contiguity

Conversation

@abagusetty

Copy link
Copy Markdown
Contributor

One more minor layout issue detected during an app-testing in comparison to numpy behavior:

Fixes: #3056

  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to an issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • Have you checked performance impact of proposed changes?
  • Have you added documentation for your changes, if necessary?
  • Have you added your changes to the changelog?

@intel-python-devops

Copy link
Copy Markdown

Can one of the admins verify this patch?

@coveralls

coveralls commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

Coverage Status

coverage: 78.498% (+0.007%) from 78.491% — abagusetty:fix-einsum-order-k-contiguity into IntelPython:master

Comment thread dpnp/tests/test_linalg.py
Comment thread dpnp/dpnp_utils/dpnp_utils_einsum.py
Comment thread dpnp/dpnp_utils/dpnp_utils_einsum.py Outdated
@antonwolfy antonwolfy added this to the 0.21.0 release milestone Sep 5, 2026
Comment thread CHANGELOG.md
* Fixed `dpnp.insert` silently ignoring out-of-bounds negative indices in a multi-element `obj`, so a mix of in-bounds and out-of-bounds indices now consistently raises `IndexError` [#3041](https://github.com/IntelPython/dpnp/pull/3041)
* Fixed a per-call `sycl::queue` leak in `usm_ndarray::get_queue()`/`get_device()` [#3042](https://github.com/IntelPython/dpnp/pull/3042)
* Fixed `dpnp.linspace` returning `nan` for equal infinite endpoints [#3043](https://github.com/IntelPython/dpnp/pull/3043)
* Fixed `dpnp.einsum` returns a result whose memory layout differs from NumPy for the default `order="K"`, and ignores `out` and `order` for a contraction over a size-0 dimension [#3058](https://github.com/IntelPython/dpnp/pull/3058)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Fixed `dpnp.einsum` returns a result whose memory layout differs from NumPy for the default `order="K"`, and ignores `out` and `order` for a contraction over a size-0 dimension [#3058](https://github.com/IntelPython/dpnp/pull/3058)
* Fixed `dpnp.einsum` returning a result whose memory layout differs from NumPy for the default `order="K"`, and ignoring `out` and `order` for a contraction over a size-0 dimension [#3058](https://github.com/IntelPython/dpnp/pull/3058)

# a unary einsum without summation returns a view, as NumPy does for every
# `order`
if not returns_view:
if order == "K" and not all_f_contiguous:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optimize=True now forces the result to C-contiguous, which

  • changes behavior that previously matched NumPy on that path
  • adds a copy for no functional benefit

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dpnp.einsumdiffers with numpy in the memory layout

4 participants