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

[WIP] Faster backend compatible ot.dist #701

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

rflamary
Copy link
Collaborator

@rflamary rflamary commented Nov 27, 2024

Types of changes

The current implementation of ot.dist uses the cdist foncton form sipy on non euclidean costs which makes it very slow. This PR is an attempt at making it faster by implementing the most common distances using the backend.

For the moeme,t backend computation are ot always faster

for instanec on a 1024x200 matrix X we have

cdist (scipy) dist 0.9.5 ot.dist (numpy) dist (torch) dist (tf)
euclidean 0.28965 0.167823 0.107717 0.109713 0.128567
sqeuclidean 0.291672 0.0587267 0.0522944 0.117674 0.0469176
cityblock 0.493404 0.491282 4.61321 1.94563 1.11516
cosine 0.333358 0.333065 0.0471443 0.11068 0.0519573
minkowski 0.294308 0.29352 11.2307 3.10716 11.9075
correlation 0.534073 0.529115 0.0896005 0.123845 0.0723958

Motivation and context / Related issue

How has this been tested (if it applies)

PR checklist

  • I have read the CONTRIBUTING document.
  • The documentation is up-to-date with the changes I made (check build artifacts).
  • All tests passed, and additional code has been covered with new tests.
  • I have added the PR and Issue fix to the RELEASES.md file.

Copy link

codecov bot commented Nov 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.07%. Comparing base (7019709) to head (677c48a).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #701   +/-   ##
=======================================
  Coverage   97.06%   97.07%           
=======================================
  Files          98       98           
  Lines       19955    19985   +30     
=======================================
+ Hits        19370    19400   +30     
  Misses        585      585           

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.

1 participant