-
Notifications
You must be signed in to change notification settings - Fork 52
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
Add specifications for returning upper (triu
) and lower (tril
) triangular matrices
#243
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @kgryte. I see two issues here:
- the
k
keyword is not namedk
in all libraries. E.g. PyTorch usesdiagonal=0
. - these aren't really creation functions - the input is already an array and this uses a subset of the data. So it looks to me like these don't quite belong in
creation_functions.md
nor should have adevice
keyword.
@rgommers NumPy classifies both |
Hmm. Yes a copy is likely needed, because the view on an upper or lower triangular would be ragged. I'm still not sure that that means a |
Re: copy. Agreed. I think that, in most cases, a copy would be required; although, I could imagine, for certain values of Re: device. We could change the default My sense is that a similar argument for the default device being |
We don't do that anywhere else I believe (unless there's an explicit
Hmm, isn't that a bit circular? I'm not quite seeing it as a creation function, and the most similar function (the one that also takes array input) in https://data-apis.org/array-api/latest/API_specification/creation_functions.html is
Did we do that on purpose? E.g. https://pytorch.org/docs/stable/generated/torch.ones_like.html uses |
As discussed during the consortium meeting held 09-02-2021, updated this PR to remove the |
As review comments have now been addressed, will merge. If further refinements are necessary, we can do so in a follow-up PR. |
This PR
tril
) and upper (triu
) triangular matrix for one or more matrices.Notes
tril
,triu
). The signatures across libraries are consistent, with the exception that PyTorch usesdiagonal
as the keyword argument, rather thank
as used in NumPy et al. This PR chosek
given its preponderance.tril
andtriu
APIs; however, these are included in the experimentalnumpy
namespace.tril
andtriu
were included in the list of potential APIs to standardize for v2 of the specification (see gh-187); however, these APIs were found to be needed in the current specification (see gh-226 and discussion gh-217).