// Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include #include #include "paddle/include/experimental/ext_all.h" std::vector postprocess_gpu( const std::vector &hm, const std::vector ®, const std::vector &height, const std::vector &dim, const std::vector &vel, const std::vector &rot, const std::vector &voxel_size, const std::vector &point_cloud_range, const std::vector &post_center_range, const std::vector &num_classes, const int down_ratio, const float score_threshold, const float nms_iou_threshold, const int nms_pre_max_size, const int nms_post_max_size, const bool with_velocity); std::vector centerpoint_postprocess( const std::vector &hm, const std::vector ®, const std::vector &height, const std::vector &dim, const std::vector &vel, const std::vector &rot, const std::vector &voxel_size, const std::vector &point_cloud_range, const std::vector &post_center_range, const std::vector &num_classes, const int down_ratio, const float score_threshold, const float nms_iou_threshold, const int nms_pre_max_size, const int nms_post_max_size, const bool with_velocity) { if (hm[0].is_gpu()) { return postprocess_gpu(hm, reg, height, dim, vel, rot, voxel_size, point_cloud_range, post_center_range, num_classes, down_ratio, score_threshold, nms_iou_threshold, nms_pre_max_size, nms_post_max_size, with_velocity); } else { PD_THROW( "Unsupported device type for centerpoint postprocess " "operator."); } } std::vector> PostProcessInferShape( const std::vector> &hm_shape, const std::vector> ®_shape, const std::vector> &height_shape, const std::vector> &dim_shape, const std::vector> &vel_shape, const std::vector> &rot_shape, const std::vector &voxel_size, const std::vector &point_cloud_range, const std::vector &post_center_range, const std::vector &num_classes, const int down_ratio, const float score_threshold, const float nms_iou_threshold, const int nms_pre_max_size, const int nms_post_max_size, const bool with_velocity) { if (with_velocity) { return {{-1, 9}, {-1}, {-1}}; } else { return {{-1, 7}, {-1}, {-1}}; } } std::vector PostProcessInferDtype( const std::vector &hm_dtype, const std::vector ®_dtype, const std::vector &height_dtype, const std::vector &dim_dtype, const std::vector &vel_dtype, const std::vector &rot_dtype) { return {reg_dtype[0], hm_dtype[0], paddle::DataType::INT64}; } PD_BUILD_OP(centerpoint_postprocess) .Inputs({paddle::Vec("HM"), paddle::Vec("REG"), paddle::Vec("HEIGHT"), paddle::Vec("DIM"), paddle::Vec("VEL"), paddle::Vec("ROT")}) .Outputs({"BBOXES", "SCORES", "LABELS"}) .SetKernelFn(PD_KERNEL(centerpoint_postprocess)) .Attrs({"voxel_size: std::vector", "point_cloud_range: std::vector", "post_center_range: std::vector", "num_classes: std::vector", "down_ratio: int", "score_threshold: float", "nms_iou_threshold: float", "nms_pre_max_size: int", "nms_post_max_size: int", "with_velocity: bool"}) .SetInferShapeFn(PD_INFER_SHAPE(PostProcessInferShape)) .SetInferDtypeFn(PD_INFER_DTYPE(PostProcessInferDtype));