Skip to content

Add dpnp.tensor.broadcast_shapes to align with the 2025.12 Python array API - #3009

Open
antonwolfy wants to merge 7 commits into
masterfrom
add-broadcast_shapes-to-dpnp.tensor
Open

Add dpnp.tensor.broadcast_shapes to align with the 2025.12 Python array API#3009
antonwolfy wants to merge 7 commits into
masterfrom
add-broadcast_shapes-to-dpnp.tensor

Conversation

@antonwolfy

@antonwolfy antonwolfy commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

The 2025.12 revision of the Python array API standard adds a standalone broadcast_shapes function that broadcasts one or more shapes (as opposed to arrays) against one another.

The function was already present in the top-level dpnp namespace but missing from dpnp.tensor. This PR closes that gap.

  • 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?

@antonwolfy antonwolfy added this to the 0.21.0 release milestone Jul 29, 2026
@antonwolfy antonwolfy self-assigned this Jul 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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

@github-actions

Copy link
Copy Markdown
Contributor

Array API standard conformance tests for dpnp=0.21.0dev3=py314h509198e_22 ran successfully.
Passed: 1375
Failed: 2
Skipped: 5

@coveralls

Copy link
Copy Markdown
Collaborator

Coverage Status

coverage: 78.414% (+0.008%) from 78.406% — add-broadcast_shapes-to-dpnp.tensor into master

@antonwolfy
antonwolfy marked this pull request as ready for review July 29, 2026 16:46
if len(shapes) == 0:
return ()

normalized = [tuple(operator.index(dim) for dim in sh) for sh in shapes]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
normalized = [tuple(operator.index(dim) for dim in sh) for sh in shapes]
normalized = [tuple(map(operator.index, sh)) for sh in shapes]

map is often a bit more efficient than a generator expression from my understanding

@ndgrigorian ndgrigorian left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

other than efficiency point LGTM

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.

3 participants