Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
OpenPCDet
Commits
11a7e434
Commit
11a7e434
authored
Jul 29, 2020
by
Shaoshuai Shi
Browse files
update cuda codes to support PyTorch 1.5
parent
f3846870
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
127 additions
and
32 deletions
+127
-32
pcdet/ops/iou3d_nms/src/iou3d_cpu.cpp
pcdet/ops/iou3d_nms/src/iou3d_cpu.cpp
+13
-1
pcdet/ops/iou3d_nms/src/iou3d_nms.cpp
pcdet/ops/iou3d_nms/src/iou3d_nms.cpp
+12
-3
pcdet/ops/pointnet2/pointnet2_stack/src/ball_query.cpp
pcdet/ops/pointnet2/pointnet2_stack/src/ball_query.cpp
+12
-2
pcdet/ops/pointnet2/pointnet2_stack/src/group_points.cpp
pcdet/ops/pointnet2/pointnet2_stack/src/group_points.cpp
+12
-2
pcdet/ops/pointnet2/pointnet2_stack/src/interpolate.cpp
pcdet/ops/pointnet2/pointnet2_stack/src/interpolate.cpp
+28
-0
pcdet/ops/pointnet2/pointnet2_stack/src/sampling.cpp
pcdet/ops/pointnet2/pointnet2_stack/src/sampling.cpp
+17
-0
pcdet/ops/roiaware_pool3d/src/roiaware_pool3d.cpp
pcdet/ops/roiaware_pool3d/src/roiaware_pool3d.cpp
+19
-19
pcdet/ops/roipoint_pool3d/src/roipoint_pool3d.cpp
pcdet/ops/roipoint_pool3d/src/roipoint_pool3d.cpp
+12
-3
setup.py
setup.py
+2
-2
No files found.
pcdet/ops/iou3d_nms/src/iou3d_cpu.cpp
View file @
11a7e434
...
...
@@ -13,7 +13,19 @@ All Rights Reserved 2020.
#include <cuda_runtime_api.h>
#include "iou3d_cpu.h"
#define CHECK_CONTIGUOUS(x) AT_CHECK(x.is_contiguous(), #x, " must be contiguous ")
#define CHECK_CUDA(x) do { \
if (!x.type().is_cuda()) { \
fprintf(stderr, "%s must be CUDA tensor at %s:%d\n", #x, __FILE__, __LINE__); \
exit(-1); \
} \
} while (0)
#define CHECK_CONTIGUOUS(x) do { \
if (!x.is_contiguous()) { \
fprintf(stderr, "%s must be contiguous tensor at %s:%d\n", #x, __FILE__, __LINE__); \
exit(-1); \
} \
} while (0)
#define CHECK_INPUT(x) CHECK_CUDA(x);CHECK_CONTIGUOUS(x)
inline
float
min
(
float
a
,
float
b
){
return
a
>
b
?
b
:
a
;
...
...
pcdet/ops/iou3d_nms/src/iou3d_nms.cpp
View file @
11a7e434
...
...
@@ -11,8 +11,18 @@ All Rights Reserved 2019-2020.
#include <cuda_runtime_api.h>
#include "iou3d_nms.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_CUDA(x) do { \
if (!x.type().is_cuda()) { \
fprintf(stderr, "%s must be CUDA tensor at %s:%d\n", #x, __FILE__, __LINE__); \
exit(-1); \
} \
} while (0)
#define CHECK_CONTIGUOUS(x) do { \
if (!x.is_contiguous()) { \
fprintf(stderr, "%s must be contiguous tensor at %s:%d\n", #x, __FILE__, __LINE__); \
exit(-1); \
} \
} while (0)
#define CHECK_INPUT(x) CHECK_CUDA(x);CHECK_CONTIGUOUS(x)
#define DIVUP(m,n) ((m) / (n) + ((m) % (n) > 0))
...
...
@@ -80,7 +90,6 @@ int boxes_iou_bev_gpu(at::Tensor boxes_a, at::Tensor boxes_b, at::Tensor ans_iou
int
nms_gpu
(
at
::
Tensor
boxes
,
at
::
Tensor
keep
,
float
nms_overlap_thresh
){
// params boxes: (N, 7) [x, y, z, dx, dy, dz, heading]
// params keep: (N)
CHECK_INPUT
(
boxes
);
CHECK_CONTIGUOUS
(
keep
);
...
...
pcdet/ops/pointnet2/pointnet2_stack/src/ball_query.cpp
View file @
11a7e434
...
...
@@ -14,8 +14,18 @@ All Rights Reserved 2019-2020.
extern
THCState
*
state
;
#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_CUDA(x) do { \
if (!x.type().is_cuda()) { \
fprintf(stderr, "%s must be CUDA tensor at %s:%d\n", #x, __FILE__, __LINE__); \
exit(-1); \
} \
} while (0)
#define CHECK_CONTIGUOUS(x) do { \
if (!x.is_contiguous()) { \
fprintf(stderr, "%s must be contiguous tensor at %s:%d\n", #x, __FILE__, __LINE__); \
exit(-1); \
} \
} while (0)
#define CHECK_INPUT(x) CHECK_CUDA(x);CHECK_CONTIGUOUS(x)
int
ball_query_wrapper_stack
(
int
B
,
int
M
,
float
radius
,
int
nsample
,
...
...
pcdet/ops/pointnet2/pointnet2_stack/src/group_points.cpp
View file @
11a7e434
...
...
@@ -13,8 +13,18 @@ All Rights Reserved 2019-2020.
#include "group_points_gpu.h"
extern
THCState
*
state
;
#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_CUDA(x) do { \
if (!x.type().is_cuda()) { \
fprintf(stderr, "%s must be CUDA tensor at %s:%d\n", #x, __FILE__, __LINE__); \
exit(-1); \
} \
} while (0)
#define CHECK_CONTIGUOUS(x) do { \
if (!x.is_contiguous()) { \
fprintf(stderr, "%s must be contiguous tensor at %s:%d\n", #x, __FILE__, __LINE__); \
exit(-1); \
} \
} while (0)
#define CHECK_INPUT(x) CHECK_CUDA(x);CHECK_CONTIGUOUS(x)
...
...
pcdet/ops/pointnet2/pointnet2_stack/src/interpolate.cpp
View file @
11a7e434
...
...
@@ -17,6 +17,20 @@ All Rights Reserved 2019-2020.
extern
THCState
*
state
;
#define CHECK_CUDA(x) do { \
if (!x.type().is_cuda()) { \
fprintf(stderr, "%s must be CUDA tensor at %s:%d\n", #x, __FILE__, __LINE__); \
exit(-1); \
} \
} while (0)
#define CHECK_CONTIGUOUS(x) do { \
if (!x.is_contiguous()) { \
fprintf(stderr, "%s must be contiguous tensor at %s:%d\n", #x, __FILE__, __LINE__); \
exit(-1); \
} \
} while (0)
#define CHECK_INPUT(x) CHECK_CUDA(x);CHECK_CONTIGUOUS(x)
void
three_nn_wrapper_stack
(
at
::
Tensor
unknown_tensor
,
at
::
Tensor
unknown_batch_cnt_tensor
,
at
::
Tensor
known_tensor
,
...
...
@@ -28,6 +42,12 @@ void three_nn_wrapper_stack(at::Tensor unknown_tensor,
// Return:
// dist: (N1 + N2 ..., 3) l2 distance to the three nearest neighbors
// idx: (N1 + N2 ..., 3) index of the three nearest neighbors
CHECK_INPUT
(
unknown_tensor
);
CHECK_INPUT
(
unknown_batch_cnt_tensor
);
CHECK_INPUT
(
known_tensor
);
CHECK_INPUT
(
known_batch_cnt_tensor
);
CHECK_INPUT
(
dist2_tensor
);
CHECK_INPUT
(
idx_tensor
);
int
batch_size
=
unknown_batch_cnt_tensor
.
size
(
0
);
int
N
=
unknown_tensor
.
size
(
0
);
...
...
@@ -50,6 +70,10 @@ void three_interpolate_wrapper_stack(at::Tensor features_tensor,
// weight_tensor: [N1 + N2 ..., 3]
// Return:
// out_tensor: (N1 + N2 ..., C)
CHECK_INPUT
(
features_tensor
);
CHECK_INPUT
(
idx_tensor
);
CHECK_INPUT
(
weight_tensor
);
CHECK_INPUT
(
out_tensor
);
int
N
=
out_tensor
.
size
(
0
);
int
channels
=
features_tensor
.
size
(
1
);
...
...
@@ -69,6 +93,10 @@ void three_interpolate_grad_wrapper_stack(at::Tensor grad_out_tensor, at::Tensor
// weight_tensor: [N1 + N2 ..., 3]
// Return:
// grad_features_tensor: (M1 + M2 ..., C)
CHECK_INPUT
(
grad_out_tensor
);
CHECK_INPUT
(
idx_tensor
);
CHECK_INPUT
(
weight_tensor
);
CHECK_INPUT
(
grad_features_tensor
);
int
N
=
grad_out_tensor
.
size
(
0
);
int
channels
=
grad_out_tensor
.
size
(
1
);
...
...
pcdet/ops/pointnet2/pointnet2_stack/src/sampling.cpp
View file @
11a7e434
...
...
@@ -6,11 +6,28 @@
#include "sampling_gpu.h"
extern
THCState
*
state
;
#define CHECK_CUDA(x) do { \
if (!x.type().is_cuda()) { \
fprintf(stderr, "%s must be CUDA tensor at %s:%d\n", #x, __FILE__, __LINE__); \
exit(-1); \
} \
} while (0)
#define CHECK_CONTIGUOUS(x) do { \
if (!x.is_contiguous()) { \
fprintf(stderr, "%s must be contiguous tensor at %s:%d\n", #x, __FILE__, __LINE__); \
exit(-1); \
} \
} while (0)
#define CHECK_INPUT(x) CHECK_CUDA(x);CHECK_CONTIGUOUS(x)
int
furthest_point_sampling_wrapper
(
int
b
,
int
n
,
int
m
,
at
::
Tensor
points_tensor
,
at
::
Tensor
temp_tensor
,
at
::
Tensor
idx_tensor
)
{
CHECK_INPUT
(
points_tensor
);
CHECK_INPUT
(
temp_tensor
);
CHECK_INPUT
(
idx_tensor
);
const
float
*
points
=
points_tensor
.
data
<
float
>
();
float
*
temp
=
temp_tensor
.
data
<
float
>
();
int
*
idx
=
idx_tensor
.
data
<
int
>
();
...
...
pcdet/ops/roiaware_pool3d/src/roiaware_pool3d.cpp
View file @
11a7e434
...
...
@@ -11,9 +11,9 @@ All Rights Reserved 2019-2020.
#include <assert.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)
//
#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)
void
roiaware_pool3d_launcher
(
int
boxes_num
,
int
pts_num
,
int
channels
,
int
max_pts_each_voxel
,
...
...
@@ -36,12 +36,12 @@ int roiaware_pool3d_gpu(at::Tensor rois, at::Tensor pts, at::Tensor pts_feature,
// params pooled_features: (N, out_x, out_y, out_z, C)
// params pool_method: 0: max_pool 1: avg_pool
CHECK_INPUT
(
rois
);
CHECK_INPUT
(
pts
);
CHECK_INPUT
(
pts_feature
);
CHECK_INPUT
(
argmax
);
CHECK_INPUT
(
pts_idx_of_voxels
);
CHECK_INPUT
(
pooled_features
);
//
CHECK_INPUT(rois);
//
CHECK_INPUT(pts);
//
CHECK_INPUT(pts_feature);
//
CHECK_INPUT(argmax);
//
CHECK_INPUT(pts_idx_of_voxels);
//
CHECK_INPUT(pooled_features);
int
boxes_num
=
rois
.
size
(
0
);
int
pts_num
=
pts
.
size
(
0
);
...
...
@@ -72,10 +72,10 @@ int roiaware_pool3d_gpu_backward(at::Tensor pts_idx_of_voxels, at::Tensor argmax
// params grad_in: (npoints, C), return value
// params pool_method: 0: max_pool 1: avg_pool
CHECK_INPUT
(
pts_idx_of_voxels
);
CHECK_INPUT
(
argmax
);
CHECK_INPUT
(
grad_out
);
CHECK_INPUT
(
grad_in
);
//
CHECK_INPUT(pts_idx_of_voxels);
//
CHECK_INPUT(argmax);
//
CHECK_INPUT(grad_out);
//
CHECK_INPUT(grad_in);
int
boxes_num
=
pts_idx_of_voxels
.
size
(
0
);
int
out_x
=
pts_idx_of_voxels
.
size
(
1
);
...
...
@@ -100,9 +100,9 @@ int points_in_boxes_gpu(at::Tensor boxes_tensor, at::Tensor pts_tensor, at::Tens
// params pts: (B, npoints, 3) [x, y, z]
// params boxes_idx_of_points: (B, npoints), default -1
CHECK_INPUT
(
boxes_tensor
);
CHECK_INPUT
(
pts_tensor
);
CHECK_INPUT
(
box_idx_of_points_tensor
);
//
CHECK_INPUT(boxes_tensor);
//
CHECK_INPUT(pts_tensor);
//
CHECK_INPUT(box_idx_of_points_tensor);
int
batch_size
=
boxes_tensor
.
size
(
0
);
int
boxes_num
=
boxes_tensor
.
size
(
1
);
...
...
@@ -145,9 +145,9 @@ int points_in_boxes_cpu(at::Tensor boxes_tensor, at::Tensor pts_tensor, at::Tens
// params pts: (num_points, 3) [x, y, z]
// params pts_indices: (N, num_points)
CHECK_CONTIGUOUS
(
boxes_tensor
);
CHECK_CONTIGUOUS
(
pts_tensor
);
CHECK_CONTIGUOUS
(
pts_indices_tensor
);
//
CHECK_CONTIGUOUS(boxes_tensor);
//
CHECK_CONTIGUOUS(pts_tensor);
//
CHECK_CONTIGUOUS(pts_indices_tensor);
int
boxes_num
=
boxes_tensor
.
size
(
0
);
int
pts_num
=
pts_tensor
.
size
(
0
);
...
...
pcdet/ops/roipoint_pool3d/src/roipoint_pool3d.cpp
View file @
11a7e434
#include <torch/serialize/tensor.h>
#include <torch/extension.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_CUDA(x) do { \
if (!x.type().is_cuda()) { \
fprintf(stderr, "%s must be CUDA tensor at %s:%d\n", #x, __FILE__, __LINE__); \
exit(-1); \
} \
} while (0)
#define CHECK_CONTIGUOUS(x) do { \
if (!x.is_contiguous()) { \
fprintf(stderr, "%s must be contiguous tensor at %s:%d\n", #x, __FILE__, __LINE__); \
exit(-1); \
} \
} while (0)
#define CHECK_INPUT(x) CHECK_CUDA(x);CHECK_CONTIGUOUS(x)
...
...
setup.py
View file @
11a7e434
...
...
@@ -27,7 +27,7 @@ def write_version_to_file(version, target_file):
if
__name__
==
'__main__'
:
version
=
'0.
2
.0+%s'
%
get_git_commit_number
()
version
=
'0.
3
.0+%s'
%
get_git_commit_number
()
write_version_to_file
(
version
,
'pcdet/version.py'
)
setup
(
...
...
@@ -37,7 +37,7 @@ if __name__ == '__main__':
install_requires
=
[
'numpy'
,
'torch>=1.1'
,
'spconv
==1.0
'
,
'spconv'
,
'numba'
,
'tensorboardX'
,
'easydict'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment