1. 24 Apr, 2020 1 commit
    • Nikhila Ravi's avatar
      Cuda updates · c3d636dc
      Nikhila Ravi authored
      Summary:
      Updates to:
      - enable cuda kernel launches on any GPU (not just the default)
      - cuda and contiguous checks for all kernels
      - checks to ensure all tensors are on the same device
      - error reporting in the cuda kernels
      - cuda tests now run on a random device not just the default
      
      Reviewed By: jcjohnson, gkioxari
      
      Differential Revision: D21215280
      
      fbshipit-source-id: 1bedc9fe6c35e9e920bdc4d78ed12865b1005519
      c3d636dc
  2. 22 Apr, 2020 1 commit
    • Justin Johnson's avatar
      Expose knn_check_version in python · 9f31a4fd
      Justin Johnson authored
      Summary:
      We have multiple KNN CUDA implementations. From python, users can currently request a particular implementation via the `version` flag, but they have no way of knowing which implementations can be used for a given problem.
      
      This diff exposes a function `pytorch3d._C.knn_check_version(version, D, K)` that returns whether a particular version can be used.
      
      Reviewed By: nikhilaravi
      
      Differential Revision: D21162573
      
      fbshipit-source-id: 6061960bdcecba454fd920b00036f4e9ff3fdbc0
      9f31a4fd
  3. 15 Apr, 2020 1 commit
    • Georgia Gkioxari's avatar
      knn autograd · b2b0c5a4
      Georgia Gkioxari authored
      Summary:
      Adds knn backward to return `grad_pts1` and `grad_pts2`. Adds `knn_gather` to return the nearest neighbors in pts2.
      
      The BM tests include backward pass and are ran on an M40.
      ```
      Benchmark                               Avg Time(μs)      Peak Time(μs) Iterations
      --------------------------------------------------------------------------------
      KNN_SQUARE_32_256_128_3_24_cpu              39558           43485             13
      KNN_SQUARE_32_256_128_3_24_cuda:0            1080            1404            463
      KNN_SQUARE_32_256_512_3_24_cpu              81950           85781              7
      KNN_SQUARE_32_256_512_3_24_cuda:0            1519            1641            330
      --------------------------------------------------------------------------------
      
      Benchmark                               Avg Time(μs)      Peak Time(μs) Iterations
      --------------------------------------------------------------------------------
      KNN_RAGGED_32_256_128_3_24_cpu              13798           14650             37
      KNN_RAGGED_32_256_128_3_24_cuda:0            1576            1713            318
      KNN_RAGGED_32_256_512_3_24_cpu              31255           32210             16
      KNN_RAGGED_32_256_512_3_24_cuda:0            2024            2162            248
      --------------------------------------------------------------------------------
      ```
      
      Reviewed By: jcjohnson
      
      Differential Revision: D20945556
      
      fbshipit-source-id: a16f616029c6b5f8c2afceb5f2bc12c5c20d2f3c
      b2b0c5a4
  4. 07 Apr, 2020 1 commit
    • Jeremy Reizenstein's avatar
      heterogenous KNN · 01b5f7b2
      Jeremy Reizenstein authored
      Summary: Interface and working implementation of ragged KNN. Benchmarks (which aren't ragged) haven't slowed. New benchmark shows that ragged is faster than non-ragged of the same shape.
      
      Reviewed By: jcjohnson
      
      Differential Revision: D20696507
      
      fbshipit-source-id: 21b80f71343a3475c8d3ee0ce2680f92f0fae4de
      01b5f7b2
  5. 29 Mar, 2020 2 commits
    • Patrick Labatut's avatar
      Address black + isort fbsource linter warnings · d57daa6f
      Patrick Labatut authored
      Summary: Address black + isort fbsource linter warnings from D20558374 (previous diff)
      
      Reviewed By: nikhilaravi
      
      Differential Revision: D20558373
      
      fbshipit-source-id: d3607de4a01fb24c0d5269634563a7914bddf1c8
      d57daa6f
    • Jeremy Reizenstein's avatar
      Linter, deprecated type() · 37c5c8e0
      Jeremy Reizenstein authored
      Summary: Run linter after recent changes. Fix long comment in knn.h which clang-format has reflowed badly. Add crude test that code doesn't call deprecated `.type()` or `.data()`.
      
      Reviewed By: nikhilaravi
      
      Differential Revision: D20692935
      
      fbshipit-source-id: 28ce0308adae79a870cb41a810b7cf8744f41ab8
      37c5c8e0
  6. 26 Mar, 2020 1 commit
    • Justin Johnson's avatar
      Implement K-Nearest Neighbors · 870290df
      Justin Johnson authored
      Summary:
      Implements K-Nearest Neighbors with C++ and CUDA versions.
      
      KNN in CUDA is highly nontrivial. I've implemented a few different versions of the kernel, and we heuristically dispatch to different kernels based on the problem size. Some of the kernels rely on template specialization on either D or K, so we use template metaprogramming to compile specialized versions for ranges of D and K.
      
      These kernels are up to 3x faster than our existing 1-nearest-neighbor kernels, so we should also consider swapping out `nn_points_idx` to use these kernels in the backend.
      
      I've been working mostly on the CUDA kernels, and haven't converged on the correct Python API.
      
      I still want to benchmark against FAISS to see how far away we are from their performance.
      
      Reviewed By: bottler
      
      Differential Revision: D19729286
      
      fbshipit-source-id: 608ffbb7030c21fe4008f330522f4890f0c3c21a
      870290df