Skip to content

Implementation of permute_dims function#786

Closed
vlad-perevezentsev wants to merge 2 commits intoIntelPython:masterfrom
vlad-perevezentsev:permute_dims
Closed

Implementation of permute_dims function#786
vlad-perevezentsev wants to merge 2 commits intoIntelPython:masterfrom
vlad-perevezentsev:permute_dims

Conversation

@vlad-perevezentsev
Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread dpctl/tensor/_permute_dims.py Outdated
Comment thread dpctl/tensor/_permute_dims.py Outdated
Comment thread dpctl/tests/test_usm_ndarray_manipulation.py Outdated
Comment thread dpctl/tensor/_permute_dims.py Outdated


def permute_dims(X, axes):
if type(X) is not dpt.usm_ndarray:
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
if type(X) is not dpt.usm_ndarray:
if not isinstance(X, dpt.usm_ndarray):

Comment thread dpctl/tensor/_permute_dims.py Outdated
Comment thread dpctl/tensor/_permute_dims.py Outdated

def permute_dims(X, axes):
"""
permute_dims(X: usm_ndarray, axes: tuple or list) -> usm_ndarray
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.

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,

Comment thread dpctl/tensor/_permute_dims.py Outdated
"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
Copy Markdown
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
Copy Markdown
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