Skip to content

Update dpnp.einsum to align with NEP-50 #2120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 24, 2024
Merged

Update dpnp.einsum to align with NEP-50 #2120

merged 1 commit into from
Oct 24, 2024

Conversation

vtavana
Copy link
Collaborator

@vtavana vtavana commented Oct 21, 2024

In NumPy 2.0 and above, numpy.einsum function follows NEP-50 while in previous version it was not followed.

dpnp.einsum is updated to behave similarly.

New behavior in NumPy and update dpnp on this branch:

import numpy as np
np.__version__
# 2.1.1
a=np.ones(2, dtype=np.float32)
np.einsum(",i->", 3., a)
# np.float64(6.0)

import dpnp
a_dp=dpnp.ones(2, dtype=dpnp.float32)
dpnp.einsum(",i->", 3., a_dp).dtype # on a device with support for double precision
# dtype('float64')

Old behavior in NumPy and dpnp:

import numpy as np
np.__version__
# 1.26.4
a=np.ones(2, dtype=np.float32)
np.einsum(",i->", 3., a).dtype
# dtype('float32')

import dpnp
a_dp=dpnp.ones(2, dtype=dpnp.float32)
dpnp.einsum(",i->", 3., a_dp).dtype
# dtype('float32')
  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to 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?
  • If this PR is a work in progress, are you filing the PR as a draft?

@vtavana vtavana self-assigned this Oct 21, 2024
Copy link
Contributor

github-actions bot commented Oct 21, 2024

View rendered docs @ https://intelpython.github.io/dpnp/index.html

@vtavana vtavana changed the title following NEP-50 for dpnp.einsum Update dpnp.einsum to align with NEP-50 Oct 21, 2024
@vtavana vtavana marked this pull request as ready for review October 21, 2024 20:44
Copy link
Contributor

@antonwolfy antonwolfy left a comment

Choose a reason for hiding this comment

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

Thank you @vtavana

@vtavana vtavana merged commit 0fbf329 into master Oct 24, 2024
46 checks passed
@vtavana vtavana deleted the update_einsum branch October 24, 2024 14:08
github-actions bot added a commit that referenced this pull request Oct 24, 2024
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.

2 participants