Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(lidar_centerpoint,image_projection_based_fusion): add guard to avoid exceeding max voxel size #1065

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ cudaError_t generateVoxels_random_launch(
cudaStream_t stream);

cudaError_t generateBaseFeatures_launch(
unsigned int * mask, float * voxels, int grid_y_size, int grid_x_size, unsigned int * pillar_num,
float * voxel_features, float * voxel_num, int * voxel_idxs, cudaStream_t stream);
unsigned int * mask, float * voxels, int grid_y_size, int grid_x_size, int max_voxel_size,
unsigned int * pillar_num, float * voxel_features, float * voxel_num, int * voxel_idxs,
cudaStream_t stream);

cudaError_t generateFeatures_launch(
const float * voxel_features, const float * voxel_num_points, const int * coords,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ bool PointPaintingTRT::preprocess(

CHECK_CUDA_ERROR(image_projection_based_fusion::generateBaseFeatures_launch(
mask_d_.get(), voxels_buffer_d_.get(), config_.grid_size_y_, config_.grid_size_x_,
num_voxels_d_.get(), voxels_d_.get(), num_points_per_voxel_d_.get(), coordinates_d_.get(),
stream_));
config_.max_voxel_size_, num_voxels_d_.get(), voxels_d_.get(), num_points_per_voxel_d_.get(),
coordinates_d_.get(), stream_));

CHECK_CUDA_ERROR(image_projection_based_fusion::generateFeatures_launch(
voxels_d_.get(), num_points_per_voxel_d_.get(), coordinates_d_.get(), num_voxels_d_.get(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ cudaError_t generateVoxels_random_launch(
}

__global__ void generateBaseFeatures_kernel(
unsigned int * mask, float * voxels, int grid_y_size, int grid_x_size, unsigned int * pillar_num,
float * voxel_features, float * voxel_num, int * voxel_idxs)
unsigned int * mask, float * voxels, int grid_y_size, int grid_x_size, int max_voxel_size,
unsigned int * pillar_num, float * voxel_features, float * voxel_num, int * voxel_idxs)
{
unsigned int voxel_idx = blockIdx.x * blockDim.x + threadIdx.x;
unsigned int voxel_idy = blockIdx.y * blockDim.y + threadIdx.y;
Expand All @@ -120,6 +120,7 @@ __global__ void generateBaseFeatures_kernel(

unsigned int current_pillarId = 0;
current_pillarId = atomicAdd(pillar_num, 1);
if (current_pillarId > max_voxel_size - 1) return;

voxel_num[current_pillarId] = count;

Expand All @@ -140,15 +141,17 @@ __global__ void generateBaseFeatures_kernel(

// create 4 channels
cudaError_t generateBaseFeatures_launch(
unsigned int * mask, float * voxels, int grid_y_size, int grid_x_size, unsigned int * pillar_num,
float * voxel_features, float * voxel_num, int * voxel_idxs, cudaStream_t stream)
unsigned int * mask, float * voxels, int grid_y_size, int grid_x_size, int max_voxel_size,
unsigned int * pillar_num, float * voxel_features, float * voxel_num, int * voxel_idxs,
cudaStream_t stream)
{
dim3 threads = {32, 32};
dim3 blocks = {
(grid_x_size + threads.x - 1) / threads.x, (grid_y_size + threads.y - 1) / threads.y};

generateBaseFeatures_kernel<<<blocks, threads, 0, stream>>>(
mask, voxels, grid_y_size, grid_x_size, pillar_num, voxel_features, voxel_num, voxel_idxs);
mask, voxels, grid_y_size, grid_x_size, max_voxel_size, pillar_num, voxel_features, voxel_num,
voxel_idxs);
cudaError_t err = cudaGetLastError();
return err;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ cudaError_t generateVoxels_random_launch(
cudaStream_t stream);

cudaError_t generateBaseFeatures_launch(
unsigned int * mask, float * voxels, int grid_y_size, int grid_x_size, unsigned int * pillar_num,
float * voxel_features, float * voxel_num, int * voxel_idxs, cudaStream_t stream);
unsigned int * mask, float * voxels, int grid_y_size, int grid_x_size, int max_voxel_size,
unsigned int * pillar_num, float * voxel_features, float * voxel_num, int * voxel_idxs,
cudaStream_t stream);

cudaError_t generateFeatures_launch(
const float * voxel_features, const float * voxel_num_points, const int * coords,
Expand Down
4 changes: 2 additions & 2 deletions perception/lidar_centerpoint/lib/centerpoint_trt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ bool CenterPointTRT::preprocess(

CHECK_CUDA_ERROR(generateBaseFeatures_launch(
mask_d_.get(), voxels_buffer_d_.get(), config_.grid_size_y_, config_.grid_size_x_,
num_voxels_d_.get(), voxels_d_.get(), num_points_per_voxel_d_.get(), coordinates_d_.get(),
stream_));
config_.max_voxel_size_, num_voxels_d_.get(), voxels_d_.get(), num_points_per_voxel_d_.get(),
coordinates_d_.get(), stream_));

CHECK_CUDA_ERROR(generateFeatures_launch(
voxels_d_.get(), num_points_per_voxel_d_.get(), coordinates_d_.get(), num_voxels_d_.get(),
Expand Down
13 changes: 8 additions & 5 deletions perception/lidar_centerpoint/lib/preprocess/preprocess_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ cudaError_t generateVoxels_random_launch(
}

__global__ void generateBaseFeatures_kernel(
unsigned int * mask, float * voxels, int grid_y_size, int grid_x_size, unsigned int * pillar_num,
float * voxel_features, float * voxel_num, int * voxel_idxs)
unsigned int * mask, float * voxels, int grid_y_size, int grid_x_size, int max_voxel_size,
unsigned int * pillar_num, float * voxel_features, float * voxel_num, int * voxel_idxs)
{
unsigned int voxel_idx = blockIdx.x * blockDim.x + threadIdx.x;
unsigned int voxel_idy = blockIdx.y * blockDim.y + threadIdx.y;
Expand All @@ -102,6 +102,7 @@ __global__ void generateBaseFeatures_kernel(

unsigned int current_pillarId = 0;
current_pillarId = atomicAdd(pillar_num, 1);
if (current_pillarId > max_voxel_size - 1) return;

voxel_num[current_pillarId] = count;

Expand All @@ -120,15 +121,17 @@ __global__ void generateBaseFeatures_kernel(

// create 4 channels
cudaError_t generateBaseFeatures_launch(
unsigned int * mask, float * voxels, int grid_y_size, int grid_x_size, unsigned int * pillar_num,
float * voxel_features, float * voxel_num, int * voxel_idxs, cudaStream_t stream)
unsigned int * mask, float * voxels, int grid_y_size, int grid_x_size, int max_voxel_size,
unsigned int * pillar_num, float * voxel_features, float * voxel_num, int * voxel_idxs,
cudaStream_t stream)
{
dim3 threads = {32, 32};
dim3 blocks = {
(grid_x_size + threads.x - 1) / threads.x, (grid_y_size + threads.y - 1) / threads.y};

generateBaseFeatures_kernel<<<blocks, threads, 0, stream>>>(
mask, voxels, grid_y_size, grid_x_size, pillar_num, voxel_features, voxel_num, voxel_idxs);
mask, voxels, grid_y_size, grid_x_size, max_voxel_size, pillar_num, voxel_features, voxel_num,
voxel_idxs);
cudaError_t err = cudaGetLastError();
return err;
}
Expand Down
Loading