Implementation of squeeze function#790
Merged
oleksandr-pavlyk merged 2 commits intomasterfrom Mar 16, 2022
Merged
Conversation
| ) | ||
| else: | ||
| new_shape = [axis for axis in X_shape if axis != 1] | ||
| if new_shape == X.shape: |
Contributor
There was a problem hiding this comment.
since new_shape is of type list, and X.shape is of type tuple the comparison is always going to return False:
In [1]: x = (1,2,3)
In [2]: y = list(x)
In [3]: y == x
Out[3]: False
|
View rendered docs @ https://intelpython.github.io/dpctl/pulls/790/index.html |
| "which has size not equal to one." | ||
| ) | ||
| else: | ||
| new_shape = [axis for axis in X_shape if axis != 1] |
Contributor
There was a problem hiding this comment.
Suggested change
| new_shape = [axis for axis in X_shape if axis != 1] | |
| new_shape = tuple(axis for axis in X_shape if axis != 1) |
| raise ValueError( | ||
| "Cannot select an axis to squeeze out " | ||
| "which has size not equal to one." | ||
| ) |
Contributor
There was a problem hiding this comment.
At the conclusion of iteration, add the line new_shape = tuple(new_shape).
| if new_shape == X.shape: | ||
| return X | ||
| else: | ||
| return dpt.reshape(X, tuple(new_shape)) |
Contributor
There was a problem hiding this comment.
Assuming the earlier changes to ensure new_shape has type of tuple, the tuple(new_shape) becomes redundant, and can be replaced with value new_shape to avoid extra copy.
Collaborator
0183179 to
31a960b
Compare
oleksandr-pavlyk
approved these changes
Mar 14, 2022
|
Deleted rendered PR docs from intelpython.github.com/dpctl, latest should be updated shortly. 🤞 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds
squeezefunctions according to Python array API standard for usm_ndarray.