From a41c2cd22808861f0d4986b2825875c10bb661e5 Mon Sep 17 00:00:00 2001 From: lijiang Date: Wed, 10 Jun 2020 00:48:56 +0800 Subject: [PATCH] make pointgroup_ops compatible with pytorch 1.5 --- lib/pointgroup_ops/functions/pointgroup_ops.py | 6 +++--- lib/pointgroup_ops/src/bfs_cluster/bfs_cluster.cpp | 12 +----------- lib/pointgroup_ops/src/cuda_utils.h | 4 ---- lib/pointgroup_ops/src/get_iou/get_iou.cpp | 6 ------ 4 files changed, 4 insertions(+), 24 deletions(-) diff --git a/lib/pointgroup_ops/functions/pointgroup_ops.py b/lib/pointgroup_ops/functions/pointgroup_ops.py index d071b87..0e424ad 100644 --- a/lib/pointgroup_ops/functions/pointgroup_ops.py +++ b/lib/pointgroup_ops/functions/pointgroup_ops.py @@ -128,9 +128,9 @@ def forward(ctx, coords, batch_idxs, batch_offsets, radius, meanActive): n = coords.size(0) - assert coords.is_contiguous() - assert batch_idxs.is_contiguous() - assert batch_offsets.is_contiguous() + assert coords.is_contiguous() and coords.is_cuda + assert batch_idxs.is_contiguous() and batch_idxs.is_cuda + assert batch_offsets.is_contiguous() and batch_offsets.is_cuda while True: idx = torch.cuda.IntTensor(n * meanActive).zero_() diff --git a/lib/pointgroup_ops/src/bfs_cluster/bfs_cluster.cpp b/lib/pointgroup_ops/src/bfs_cluster/bfs_cluster.cpp index dc2f346..cf6a26e 100644 --- a/lib/pointgroup_ops/src/bfs_cluster/bfs_cluster.cpp +++ b/lib/pointgroup_ops/src/bfs_cluster/bfs_cluster.cpp @@ -6,12 +6,6 @@ All Rights Reserved 2020. #include "bfs_cluster.h" -#define CHECK_CUDA(x) AT_CHECK(x.type().is_cuda(), #x, " must be a CUDAtensor ") -#define CHECK_CONTIGUOUS(x) AT_CHECK(x.is_contiguous(), #x, " must be contiguous ") -#define CHECK_INPUT(x) CHECK_CUDA(x);CHECK_CONTIGUOUS(x) - -extern THCState *state; - /* ================================== ballquery_batch_p ================================== */ // input xyz: (n, 3) float // input batch_idxs: (n) int @@ -19,17 +13,13 @@ extern THCState *state; // output idx: (n * meanActive) dim 0 for number of points in the ball, idx in n // output start_len: (n, 2), int int ballquery_batch_p(at::Tensor xyz_tensor, at::Tensor batch_idxs_tensor, at::Tensor batch_offsets_tensor, at::Tensor idx_tensor, at::Tensor start_len_tensor, int n, int meanActive, float radius){ - CHECK_INPUT(xyz_tensor); - CHECK_INPUT(batch_idxs_tensor); - CHECK_INPUT(batch_offsets_tensor); - const float *xyz = xyz_tensor.data(); const int *batch_idxs = batch_idxs_tensor.data(); const int *batch_offsets = batch_offsets_tensor.data(); int *idx = idx_tensor.data(); int *start_len = start_len_tensor.data(); - cudaStream_t stream = THCState_getCurrentStream(state); + cudaStream_t stream = at::cuda::getCurrentCUDAStream(); int cumsum = ballquery_batch_p_cuda(n, meanActive, radius, xyz, batch_idxs, batch_offsets, idx, start_len, stream); return cumsum; } diff --git a/lib/pointgroup_ops/src/cuda_utils.h b/lib/pointgroup_ops/src/cuda_utils.h index 780d51d..532fc62 100644 --- a/lib/pointgroup_ops/src/cuda_utils.h +++ b/lib/pointgroup_ops/src/cuda_utils.h @@ -5,10 +5,6 @@ #define TOTAL_THREADS 1024 -#define CHECK_CUDA(x) AT_CHECK(x.type().is_cuda(), #x, " must be a CUDAtensor ") -#define CHECK_CONTIGUOUS(x) AT_CHECK(x.is_contiguous(), #x, " must be contiguous ") -#define CHECK_INPUT(x) CHECK_CUDA(x);CHECK_CONTIGUOUS(x) - #define THREADS_PER_BLOCK 512 #define DIVUP(m,n) ((m) / (n) + ((m) % (n) > 0)) diff --git a/lib/pointgroup_ops/src/get_iou/get_iou.cpp b/lib/pointgroup_ops/src/get_iou/get_iou.cpp index 848e21b..3b1c1c6 100644 --- a/lib/pointgroup_ops/src/get_iou/get_iou.cpp +++ b/lib/pointgroup_ops/src/get_iou/get_iou.cpp @@ -6,12 +6,6 @@ All Rights Reserved 2020. #include "get_iou.h" -#define CHECK_CUDA(x) AT_CHECK(x.type().is_cuda(), #x, " must be a CUDAtensor ") -#define CHECK_CONTIGUOUS(x) AT_CHECK(x.is_contiguous(), #x, " must be contiguous ") -#define CHECK_INPUT(x) CHECK_CUDA(x);CHECK_CONTIGUOUS(x) - -extern THCState *state; - void get_iou(at::Tensor proposals_idx_tensor, at::Tensor proposals_offset_tensor, at::Tensor instance_labels_tensor, at::Tensor instance_pointnum_tensor, at::Tensor proposals_iou_tensor, int nInstance, int nProposal){ int *proposals_idx = proposals_idx_tensor.data(); int *proposals_offset = proposals_offset_tensor.data();