ub360_utils.cpp 600 B

1234567891011121314151617181920
  1. #include <torch/extension.h>
  2. #include <vector>
  3. torch::Tensor cumdist_thres_cuda(torch::Tensor dist, float thres);
  4. #define CHECK_CUDA(x) TORCH_CHECK(x.type().is_cuda(), #x " must be a CUDA tensor")
  5. #define CHECK_CONTIGUOUS(x) TORCH_CHECK(x.is_contiguous(), #x " must be contiguous")
  6. #define CHECK_INPUT(x) CHECK_CUDA(x); CHECK_CONTIGUOUS(x)
  7. torch::Tensor cumdist_thres(torch::Tensor dist, float thres) {
  8. CHECK_INPUT(dist);
  9. return cumdist_thres_cuda(dist, thres);
  10. }
  11. PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
  12. m.def("cumdist_thres", &cumdist_thres, "Generate mask for cumulative dist.");
  13. }