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

Add Tensor-based implementation of FarthestPointDownSample #6948

Merged
merged 2 commits into from
Oct 9, 2024

Conversation

manuelvogel12
Copy link
Contributor

This PR adds a FarthestPointDownSample implementation for tensor-based point clouds. This enables GPU-acceleration for a performance increase of up to 8x. Before, point clouds were copied to the legacy format and then being downsampled on the CPU before being copied back.

  • Bug fix (non-breaking change which fixes an issue): Fixes #
  • New feature (non-breaking change which adds functionality). Resolves #
  • Breaking change (fix or feature that would cause existing functionality to not work as expected) Resolves #

Motivation and Context

FarthestPointDownSample is an important downsampling method, however it's performance render this implementation inapplicable for certain scenarios. This PR is trying to increase the performance

Checklist:

  • I have run python util/check_style.py --apply to apply Open3D code style
    to my code.
  • This PR changes Open3D behavior or adds new functionality.
    • Both C++ (Doxygen) and Python (Sphinx / Google style) documentation is
      updated accordingly.
    • I have added or updated C++ and / or Python unit tests OR included test
      results
      (e.g. screenshots or numbers) here.
  • I will follow up and update the code if CI fails.
  • For fork PRs, I have selected Allow edits from maintainers.

Description

Copy link

update-docs bot commented Sep 4, 2024

Thanks for submitting this pull request! The maintainers of this repository would appreciate if you could update the CHANGELOG.md based on your changes.

@ssheorey ssheorey requested a review from benjaminum September 4, 2024 15:17
@manuelvogel12
Copy link
Contributor Author

I use the legacy method when dealing with CPU-Pointclouds, because my tensor-based implementation is roughly 10x slower on the CPU than the legacy version.

However, with PR #6989, the performance is only 4 times slower (compared to the legacy implementation).

It can be further sped up to 2.5 times slower (compared to the legacy implementation) by replacing

core::Tensor diff = GetPointPositions() - selected;
core::Tensor distances_to_selected = (diff * diff).Sum({1});

with

core::Tensor diff = GetPointPositions() - selected;
diff *= diff;
core::Tensor distances_to_selected = diff.IndexExtract(1,0) + diff.IndexExtract(1,1) + diff.IndexExtract(1,2);

Therefore, I think it makes sense to remove the if (IsCUDA()) condition and also run this version for CPU-Pointclouds, because with the legacy version, properties such as the intensity are lost, and the dtype of other properties might be changed.

@benjaminum
Copy link
Contributor

Thanks @manuelvogel12 for the update!

@benjaminum
Copy link
Contributor

image Looks good

@benjaminum benjaminum merged commit 3975044 into isl-org:main Oct 9, 2024
34 of 39 checks passed
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