@@ -105,8 +105,8 @@ cudaError_t generateVoxels_random_launch(
105
105
}
106
106
107
107
__global__ void generateBaseFeatures_kernel (
108
- unsigned int * mask, float * voxels, int grid_y_size, int grid_x_size, unsigned int * pillar_num ,
109
- float * voxel_features, float * voxel_num, int * voxel_idxs)
108
+ unsigned int * mask, float * voxels, int grid_y_size, int grid_x_size, int max_voxel_size ,
109
+ unsigned int * pillar_num, float * voxel_features, float * voxel_num, int * voxel_idxs)
110
110
{
111
111
unsigned int voxel_idx = blockIdx .x * blockDim .x + threadIdx .x ;
112
112
unsigned int voxel_idy = blockIdx .y * blockDim .y + threadIdx .y ;
@@ -120,6 +120,7 @@ __global__ void generateBaseFeatures_kernel(
120
120
121
121
unsigned int current_pillarId = 0 ;
122
122
current_pillarId = atomicAdd (pillar_num, 1 );
123
+ if (current_pillarId > max_voxel_size - 1 ) return ;
123
124
124
125
voxel_num[current_pillarId] = count;
125
126
@@ -140,15 +141,17 @@ __global__ void generateBaseFeatures_kernel(
140
141
141
142
// create 4 channels
142
143
cudaError_t generateBaseFeatures_launch (
143
- unsigned int * mask, float * voxels, int grid_y_size, int grid_x_size, unsigned int * pillar_num,
144
- float * voxel_features, float * voxel_num, int * voxel_idxs, cudaStream_t stream)
144
+ unsigned int * mask, float * voxels, int grid_y_size, int grid_x_size, int max_voxel_size,
145
+ unsigned int * pillar_num, float * voxel_features, float * voxel_num, int * voxel_idxs,
146
+ cudaStream_t stream)
145
147
{
146
148
dim3 threads = {32 , 32 };
147
149
dim3 blocks = {
148
150
(grid_x_size + threads.x - 1 ) / threads.x , (grid_y_size + threads.y - 1 ) / threads.y };
149
151
150
152
generateBaseFeatures_kernel<<<blocks, threads, 0 , stream>>> (
151
- mask, voxels, grid_y_size, grid_x_size, pillar_num, voxel_features, voxel_num, voxel_idxs);
153
+ mask, voxels, grid_y_size, grid_x_size, max_voxel_size, pillar_num, voxel_features, voxel_num,
154
+ voxel_idxs);
152
155
cudaError_t err = cudaGetLastError ();
153
156
return err;
154
157
}
0 commit comments