Skip to content
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

Allow negative axes in tensordot #625

Merged
merged 2 commits into from Sep 20, 2023
Merged

Conversation

asmeurer
Copy link
Member

Both NumPy and PyTorch allow this, and there should be no ambiguity or difficulty in doing so, as long as the specified axes remain unique.

Both NumPy and PyTorch allow this, and there should be no ambiguity or
difficulty in doing so, as long as the specified axes remain unique.
@kgryte kgryte added this to the v2023 milestone Apr 23, 2023
@kgryte kgryte added API change Changes to existing functions or objects in the API. topic: Linear Algebra Linear algebra. labels Apr 23, 2023
This follows precedent elsewhere (e.g., `moveaxis`).
Copy link
Contributor

@kgryte kgryte left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks, @asmeurer!

@kgryte
Copy link
Contributor

kgryte commented Sep 20, 2023

As this PR introduces changes which are consistent with guidance elsewhere in the specification (namely, a valid axis index may be negative, resolving to a positive index according to N + i) and libraries within the ecosystem already support negative indices in tensordot, will go ahead and merge.

For reference, the original PR makes no mention regarding the original guidance of nonnegative integers. That the guidance required nonnegative integers and not negative integers was likely an omission/mistake.

@kgryte kgryte merged commit 8c42f02 into data-apis:main Sep 20, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API change Changes to existing functions or objects in the API. topic: Linear Algebra Linear algebra.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants