{"id":19523850,"url":"https://github.com/lxxue/frnn","last_synced_at":"2026-03-17T05:46:54.993Z","repository":{"id":42574784,"uuid":"278703875","full_name":"lxxue/FRNN","owner":"lxxue","description":"Fixed Radius Nearest Neighbor Search on GPU","archived":false,"fork":false,"pushed_at":"2024-03-06T11:00:13.000Z","size":81401,"stargazers_count":182,"open_issues_count":5,"forks_count":25,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-24T08:09:16.996Z","etag":null,"topics":["cuda","nearest-neighbor-search","pytorch"],"latest_commit_sha":null,"homepage":"","language":"Cuda","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lxxue.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-10T18:17:34.000Z","updated_at":"2025-03-14T04:10:45.000Z","dependencies_parsed_at":"2025-01-10T06:44:19.621Z","dependency_job_id":null,"html_url":"https://github.com/lxxue/FRNN","commit_stats":{"total_commits":105,"total_committers":6,"mean_commits":17.5,"dds":0.09523809523809523,"last_synced_commit":"efc6b378d45000c5de6234098b5092464eb92a24"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lxxue%2FFRNN","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lxxue%2FFRNN/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lxxue%2FFRNN/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lxxue%2FFRNN/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lxxue","download_url":"https://codeload.github.com/lxxue/FRNN/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246927835,"owners_count":20856198,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cuda","nearest-neighbor-search","pytorch"],"created_at":"2024-11-11T00:44:57.903Z","updated_at":"2026-03-17T05:46:49.972Z","avatar_url":"https://github.com/lxxue.png","language":"Cuda","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FRNN\n\nA Fixed Radius Nearest Neighbors Search implemented on CUDA with similar interface as [pytorch3d.ops.knn_points](https://pytorch3d.readthedocs.io/en/latest/modules/ops.html#pytorch3d.ops.knn_points).\n\n## Performance\n\n![Performance](./images/teaser.png)\n\n## Algorithm Walkthrough \u0026 Experiment Results\n\n[FRNN Presentation](./frnn_pre.pdf)\n\n## Depenency\n\nTested with cuda 10.2, python 3.8 and pytorch 1.6.0 on ubuntu 18.04.\n\nShould be also fine other versions of cuda/python/pytorch.\n\n## Install\n\n```\ngit clone --recursive https://github.com/lxxue/FRNN.git\n# install a prefix_sum routine first\ncd FRNN/external/prefix_sum\npip install .\n\n# install FRNN\ncd ../../ # back to the {FRNN} directory\n# this might take a while since I instantiate all combinations of D and K\npip install -e .\n# might need to restart the bash to make importing this package work\n```\n\n## Usage\n\nFor fixed nearest neighbors search:\n[doc](https://github.com/lxxue/FRNN/blob/59a4c8fdc786c64afd991919af39f1a65d4ec2ff/frnn/frnn.py#L154-L224)\n\n```\n  # first time there is no cached grid\n  dists, idxs, nn, grid = frnn.frnn_grid_points(\n        points1, points2, lengths1, lengths2, K, r, grid=None, return_nn=False, return_sorted=True\n  )\n  # if points2 and r don't change, we can reuse the grid\n  dists, idxs, nn, grid = frnn.frnn_grid_points(\n        points1, points2, lengths1, lengths2, K, r, grid=grid, return_nn=False, return_sorted=True\n  )\n```\n\nFor manually gather nearest neighbors from idxs generated via frnn_grid_points:\n[doc](https://github.com/lxxue/FRNN/blob/59a4c8fdc786c64afd991919af39f1a65d4ec2ff/frnn/frnn.py#L268-L292)\n\n```\n  nn = frnn.frnn_gather(points2, idxs, lengths2)\n```\n\n## Note\n\nFor small point clouds (e.g. \u003c 10,000 points), the bruteforce way (e.g. pytorch3d's KNN) might be faster.\n\n## TODO\n\n- [x] support large D (not fully optimized yet)\n- [x] support large K (not fully optimized yet)\n- [ ] try use z-order for the grid cell indices\n- [ ] speedup and interface for the same query and reference point cloud\n- [ ] collect all points within radius\n- [ ] cpp standalone implementation\n\nIf you want a new feature, just open an issue or send me an email about it.\n\n## Acknowledgement\n\nThe code is build on the [algorithm](https://on-demand.gputechconf.com/gtc/2014/presentations/S4117-fast-fixed-radius-nearest-neighbor-gpu.pdf) introduced by Rama C. Hoetzlein. I use the [parallel prefix_sum](https://github.com/lxxue/prefix_sum) routines implemented by [mattdean1](https://github.com/mattdean1/cuda). I also learn (copy \u0026 paste) a lot from [Pytorch3D's KNN](https://github.com/facebookresearch/pytorch3d/blob/master/pytorch3d/csrc/knn/knn.cu) implementations.\n\n\u003c!--\n## TODO\n\n1. Fix the problem of error for long thin objects\n2. Support dimensions for arbitrary D\n3. Support K \u003e 32\n4. KNN grid implementations\n--\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flxxue%2Ffrnn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flxxue%2Ffrnn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flxxue%2Ffrnn/lists"}