Skip to content

wrap more functions to complete a minimal viable feature set #65

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

Merged
merged 16 commits into from
Feb 27, 2023
Merged

Conversation

ev-br
Copy link
Collaborator

@ev-br ev-br commented Feb 23, 2023

Only

  • unique
  • dot
  • where
  • searchsorted

are left for a tentative minimum viable functionality set.

@ev-br ev-br marked this pull request as draft February 23, 2023 21:06
@ev-br ev-br changed the title WIP: numpy api coverage WIP: wrap more functions Feb 23, 2023
@ev-br ev-br force-pushed the where_et_al branch 3 times, most recently from 00d78c4 to 6ba8cfb Compare February 24, 2023 19:06
@ev-br ev-br marked this pull request as ready for review February 25, 2023 20:09
@ev-br ev-br changed the title WIP: wrap more functions wrap more functions to complete a minimal viable feature set Feb 25, 2023
@ev-br ev-br requested a review from lezcano February 25, 2023 20:17
@ev-br
Copy link
Collaborator Author

ev-br commented Feb 25, 2023

No longer WIP, ready for review.

Copy link
Collaborator

@lezcano lezcano left a comment

Choose a reason for hiding this comment

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

All the complex max/min/argmax/argmin... we may be able to implement them via casting the complex tensor to a real one via view_as_real. Now, I think it's pretty low prio, as IMO, these should not even work.

# For more than d=2, the strided formula is only valid for arrays with
# all dimensions equal, so we check first.
s = tensor.shape
if s[1:] != s[:-1]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rather slick ngl.

@ev-br
Copy link
Collaborator Author

ev-br commented Feb 27, 2023

Review comments addressed, other than those I'd rather do in a sequel

Comment on lines +179 to +183
def diagonal(tensor, offset=0, axis1=0, axis2=1):
axis1 = _util.normalize_axis_index(axis1, tensor.ndim)
axis2 = _util.normalize_axis_index(axis2, tensor.ndim)
result = torch.diagonal(tensor, offset, axis1, axis2)
return result
Copy link
Collaborator

Choose a reason for hiding this comment

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

My point was that this could simply be

Suggested change
def diagonal(tensor, offset=0, axis1=0, axis2=1):
axis1 = _util.normalize_axis_index(axis1, tensor.ndim)
axis2 = _util.normalize_axis_index(axis2, tensor.ndim)
result = torch.diagonal(tensor, offset, axis1, axis2)
return result
def diagonal(tensor, offset=0, axis1=0, axis2=1):
return torch.diagonal(tensor, offset, axis1, axis2)

No need to change it really.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah, great. Made a note to self to go through normalize_axis_index invocations across the codebase.

@ev-br
Copy link
Collaborator Author

ev-br commented Feb 27, 2023

Thanks Mario for the review!

@ev-br ev-br merged commit 9df7b54 into main Feb 27, 2023
@ev-br ev-br deleted the where_et_al branch February 27, 2023 17:21
This was referenced Feb 28, 2023
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.

2 participants