Skip to content

Commit

Permalink
fix(autoware_lidar_centerpoint): place device vector in CUDA device s…
Browse files Browse the repository at this point in the history
…ystem (autowarefoundation#8272)

Signed-off-by: amadeuszsz <amadeusz.szymko.2@tier4.jp>
  • Loading branch information
amadeuszsz authored and esteve committed Aug 13, 2024
1 parent 2a82657 commit c0585c2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "autoware/lidar_centerpoint/utils.hpp"
#include "cuda.h"
#include "cuda_runtime_api.h"
#include "thrust/device_vector.h"

#include <vector>

Expand All @@ -37,8 +36,6 @@ class PostProcessCUDA

private:
CenterPointConfig config_;
thrust::device_vector<Box3D> boxes3d_d_;
thrust::device_vector<float> yaw_norm_thresholds_d_;
};

} // namespace autoware::lidar_centerpoint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,6 @@ __global__ void generateBoxes3D_kernel(

PostProcessCUDA::PostProcessCUDA(const CenterPointConfig & config) : config_(config)
{
const auto num_raw_boxes3d = config.down_grid_size_y_ * config.down_grid_size_x_;
boxes3d_d_ = thrust::device_vector<Box3D>(num_raw_boxes3d);
yaw_norm_thresholds_d_ = thrust::device_vector<float>(
config_.yaw_norm_thresholds_.begin(), config_.yaw_norm_thresholds_.end());
}

// cspell: ignore divup
Expand All @@ -153,23 +149,26 @@ cudaError_t PostProcessCUDA::generateDetectedBoxes3D_launch(
divup(config_.down_grid_size_y_, THREADS_PER_BLOCK),
divup(config_.down_grid_size_x_, THREADS_PER_BLOCK));
dim3 threads(THREADS_PER_BLOCK, THREADS_PER_BLOCK);
auto boxes3d_d =
thrust::device_vector<Box3D>(config_.down_grid_size_y_ * config_.down_grid_size_x_);
auto yaw_norm_thresholds_d = thrust::device_vector<float>(
config_.yaw_norm_thresholds_.begin(), config_.yaw_norm_thresholds_.end());
generateBoxes3D_kernel<<<blocks, threads, 0, stream>>>(
out_heatmap, out_offset, out_z, out_dim, out_rot, out_vel, config_.voxel_size_x_,
config_.voxel_size_y_, config_.range_min_x_, config_.range_min_y_, config_.down_grid_size_x_,
config_.down_grid_size_y_, config_.downsample_factor_, config_.class_size_,
config_.has_variance_, thrust::raw_pointer_cast(yaw_norm_thresholds_d_.data()),
thrust::raw_pointer_cast(boxes3d_d_.data()));
config_.has_variance_, thrust::raw_pointer_cast(yaw_norm_thresholds_d.data()),
thrust::raw_pointer_cast(boxes3d_d.data()));

// suppress by score
const auto num_det_boxes3d = thrust::count_if(
thrust::device, boxes3d_d_.begin(), boxes3d_d_.end(),
is_score_greater(config_.score_threshold_));
thrust::device, boxes3d_d.begin(), boxes3d_d.end(), is_score_greater(config_.score_threshold_));
if (num_det_boxes3d == 0) {
return cudaGetLastError();
}
thrust::device_vector<Box3D> det_boxes3d_d(num_det_boxes3d);
thrust::copy_if(
thrust::device, boxes3d_d_.begin(), boxes3d_d_.end(), det_boxes3d_d.begin(),
thrust::device, boxes3d_d.begin(), boxes3d_d.end(), det_boxes3d_d.begin(),
is_score_greater(config_.score_threshold_));

// sort by score
Expand Down

0 comments on commit c0585c2

Please sign in to comment.