Skip to content
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

On the applicability of quantile_function and nx.searchsorted on tensors wider than 2D #518

Open
kachayev opened this issue Aug 28, 2023 · 3 comments

Comments

@kachayev
Copy link
Collaborator

kachayev commented Aug 28, 2023

Describe the bug

Pre-story to this question is the following operation within quantile_function helper for 1d solvers: link. Transpose is only well-defined for 2D PyTorch tensors: for 1D it basically does nothing and for 3D and higher it's deprecated (will be removed in future). Would it be fair to restrict quantile_function to work only for 1D and 2D tensors (e.g. raising ValueError). In tests it's never called with wider tensors.

Same question goes for searchsorted implementation in the backend.py module for backends other than Torch and TF: for example this one. Seems like implementation only supports 1D or 2D use case, should we throw ValueError if something else is given?

Also, maybe it makes sense to define quantile as a backend function with default implementation so we can provide different implementation for Torch to avoid ad-hoc conditioning on the name of the backend?

Happy to make PR if this is the right course of action.

@rflamary
Copy link
Collaborator

rflamary commented Mar 4, 2024

Yes @kachayev this makes sens

@cedricvincentcuaz
Copy link
Collaborator

We could also change .T to nx.transpose to keep the same API.

@kachayev
Copy link
Collaborator Author

kachayev commented Mar 4, 2024

Cool, I will work on the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants