Skip to content

Implementation of permute_dims function #786

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

Closed

Conversation

vlad-perevezentsev
Copy link
Collaborator

@vlad-perevezentsev vlad-perevezentsev commented Mar 2, 2022

This PR adds permute_dims functions according to Python array API standard for usm_ndarray

@coveralls
Copy link
Collaborator

coveralls commented Mar 2, 2022

Coverage Status

Coverage increased (+0.09%) to 81.723% when pulling 30e98fe on vlad-perevezentsev:permute_dims into 3007b26 on IntelPython:master.



def permute_dims(X, axes):
if type(X) is not dpt.usm_ndarray:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if type(X) is not dpt.usm_ndarray:
if not isinstance(X, dpt.usm_ndarray):


def permute_dims(X, axes):
"""
permute_dims(X: usm_ndarray, axes: tuple or list) -> usm_ndarray
Copy link
Contributor

Choose a reason for hiding this comment

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

Since your branch does not build documentation we do not see how this comes out in docs. Please create a branch in the main repo and push there to see the rendered docs,

"The length of the passed axes does not match "
"to the number of usm_ndarray dimensions."
)
if axes not in permutations(range(0, X.ndim), X.ndim):
Copy link
Contributor

Choose a reason for hiding this comment

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

This has horrible computational and space complexity in the dimensionality of the array d, specifically O(d!).

More efficient way:

  • Length of the tuple must be d
  • Minimum element must be 0, maximum d-1.
  • Array should have no duplicates.

@vlad-perevezentsev
Copy link
Collaborator Author

Moved to #787

@vlad-perevezentsev vlad-perevezentsev deleted the permute_dims branch June 20, 2023 10:53
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