Skip to content

Commit

Permalink
style(pre-commit): autofix
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Oct 28, 2024
1 parent 4445c4c commit a344c07
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 32 deletions.
2 changes: 1 addition & 1 deletion perception/autoware_bytetrack/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
<buildtool_export_depend>cudnn_cmake_module</buildtool_export_depend>
<buildtool_export_depend>tensorrt_cmake_module</buildtool_export_depend>

<depend>autoware_cuda_utils</depend>
<depend>autoware_kalman_filter</depend>
<depend>autoware_perception_msgs</depend>
<depend>autoware_tensorrt_common</depend>
<depend>autoware_cuda_utils</depend>
<depend>cv_bridge</depend>
<depend>eigen</depend>
<depend>image_transport</depend>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
#include "autoware/lidar_apollo_instance_segmentation/feature_generator.hpp"
#include "autoware/lidar_apollo_instance_segmentation/node.hpp"

#include <autoware/tensorrt_common/tensorrt_common.hpp>
#include <autoware/universe_utils/transform/transforms.hpp>
#include <autoware/cuda_utils/cuda_unique_ptr.hpp>
#include <autoware/cuda_utils/stream_unique_ptr.hpp>
#include <autoware/tensorrt_common/tensorrt_common.hpp>
#include <autoware/universe_utils/transform/transforms.hpp>
#include <tf2_eigen/tf2_eigen.hpp>

#include <tf2_ros/buffer_interface.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@

<buildtool_depend>ament_cmake</buildtool_depend>

<depend>autoware_cuda_utils</depend>
<depend>autoware_perception_msgs</depend>
<depend>autoware_tensorrt_common</depend>
<depend>autoware_universe_utils</depend>
<depend>autoware_cuda_utils</depend>
<depend>libpcl-all-dev</depend>
<depend>pcl_conversions</depend>
<depend>rclcpp</depend>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
#ifndef AUTOWARE__SHAPE_ESTIMATION__TENSORRT_SHAPE_ESTIMATOR_HPP_
#define AUTOWARE__SHAPE_ESTIMATION__TENSORRT_SHAPE_ESTIMATOR_HPP_

#include <autoware/tensorrt_common/tensorrt_common.hpp>
#include <autoware/cuda_utils/cuda_check_error.hpp>
#include <autoware/cuda_utils/cuda_unique_ptr.hpp>
#include <autoware/cuda_utils/stream_unique_ptr.hpp>
#include <autoware/tensorrt_common/tensorrt_common.hpp>
#include <pcl_ros/transforms.hpp>

#include <autoware_perception_msgs/msg/detected_objects.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ TrtShapeEstimator::TrtShapeEstimator(
const auto one_hot_input_size = std::accumulate(
one_hot_input_dims.d + 1, one_hot_input_dims.d + one_hot_input_dims.nbDims, 1,
std::multiplies<int>());
input_one_hot_d_ = autoware::cuda_utils::make_unique<float[]>(one_hot_input_size * batch_config[2]);
input_one_hot_d_ =
autoware::cuda_utils::make_unique<float[]>(one_hot_input_size * batch_config[2]);

const auto stage1_center_out_dims = trt_common_->getBindingDimensions(2);
out_s1center_elem_num_ = std::accumulate(
Expand Down
2 changes: 1 addition & 1 deletion perception/autoware_shape_estimation/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
<buildtool_export_depend>cudnn_cmake_module</buildtool_export_depend>
<buildtool_export_depend>tensorrt_cmake_module</buildtool_export_depend>

<depend>autoware_cuda_utils</depend>
<depend>autoware_perception_msgs</depend>
<depend>autoware_tensorrt_common</depend>
<depend>autoware_universe_utils</depend>
<depend>autoware_cuda_utils</depend>
<depend>eigen</depend>
<depend>libopencv-dev</depend>
<depend>libpcl-all-dev</depend>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
#ifndef AUTOWARE__TENSORRT_CLASSIFIER__TENSORRT_CLASSIFIER_HPP_
#define AUTOWARE__TENSORRT_CLASSIFIER__TENSORRT_CLASSIFIER_HPP_

#include <autoware/tensorrt_common/tensorrt_common.hpp>
#include <autoware/cuda_utils/cuda_check_error.hpp>
#include <autoware/cuda_utils/cuda_unique_ptr.hpp>
#include <autoware/cuda_utils/stream_unique_ptr.hpp>
#include <autoware/tensorrt_common/tensorrt_common.hpp>
#include <opencv2/opencv.hpp>

#include <memory>
Expand Down
2 changes: 1 addition & 1 deletion perception/autoware_tensorrt_classifier/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

<build_depend>autoware_cmake</build_depend>

<depend>autoware_tensorrt_common</depend>
<depend>autoware_cuda_utils</depend>
<depend>autoware_tensorrt_common</depend>
<depend>libopencv-dev</depend>
<depend>rclcpp</depend>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ TrtClassifier::TrtClassifier(
out_elem_num_ = out_elem_num_ * batch_config[2];
out_elem_num_per_batch_ = static_cast<int>(out_elem_num_ / batch_config[2]);
out_prob_d_ = autoware::cuda_utils::make_unique<float[]>(out_elem_num_);
out_prob_h_ = autoware::cuda_utils::make_unique_host<float[]>(out_elem_num_, cudaHostAllocPortable);
out_prob_h_ =
autoware::cuda_utils::make_unique_host<float[]>(out_elem_num_, cudaHostAllocPortable);

Check warning on line 180 in perception/autoware_tensorrt_classifier/src/tensorrt_classifier.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ Getting worse: Complex Method

TrtClassifier::TrtClassifier already has high cyclomatic complexity, and now it increases in Lines of Code from 83 to 84. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.

if (cuda) {
m_cuda = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
#ifndef AUTOWARE__TENSORRT_YOLOX__TENSORRT_YOLOX_HPP_
#define AUTOWARE__TENSORRT_YOLOX__TENSORRT_YOLOX_HPP_

#include <autoware/tensorrt_common/tensorrt_common.hpp>
#include <autoware/tensorrt_yolox/preprocess.hpp>
#include <autoware/cuda_utils/cuda_unique_ptr.hpp>
#include <autoware/cuda_utils/stream_unique_ptr.hpp>
#include <autoware/tensorrt_common/tensorrt_common.hpp>
#include <autoware/tensorrt_yolox/preprocess.hpp>
#include <opencv2/opencv.hpp>

#include <memory>
Expand Down
2 changes: 1 addition & 1 deletion perception/autoware_tensorrt_yolox/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
<buildtool_export_depend>cudnn_cmake_module</buildtool_export_depend>
<buildtool_export_depend>tensorrt_cmake_module</buildtool_export_depend>

<depend>autoware_cuda_utils</depend>
<depend>autoware_object_recognition_utils</depend>
<depend>autoware_perception_msgs</depend>
<depend>autoware_tensorrt_common</depend>
<depend>autoware_cuda_utils</depend>
<depend>cv_bridge</depend>
<depend>image_transport</depend>
<depend>libopencv-dev</depend>
Expand Down
38 changes: 22 additions & 16 deletions perception/autoware_tensorrt_yolox/src/tensorrt_yolox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,8 @@ TrtYoloX::TrtYoloX(
out_elem_num_ = out_elem_num_ * batch_config[2];
out_elem_num_per_batch_ = static_cast<int>(out_elem_num_ / batch_config[2]);
out_prob_d_ = autoware::cuda_utils::make_unique<float[]>(out_elem_num_);
out_prob_h_ = autoware::cuda_utils::make_unique_host<float[]>(out_elem_num_, cudaHostAllocPortable);
out_prob_h_ =
autoware::cuda_utils::make_unique_host<float[]>(out_elem_num_, cudaHostAllocPortable);
int w = input_dims.d[3];
int h = input_dims.d[2];
int sum_tensors = (w / 8) * (h / 8) + (w / 16) * (h / 16) + (w / 32) * (h / 32);
Expand All @@ -300,9 +301,11 @@ TrtYoloX::TrtYoloX(
max_detections_ = out_scores_dims.d[1];
input_d_ = autoware::cuda_utils::make_unique<float[]>(batch_config[2] * input_size);
out_num_detections_d_ = autoware::cuda_utils::make_unique<int32_t[]>(batch_config[2]);
out_boxes_d_ = autoware::cuda_utils::make_unique<float[]>(batch_config[2] * max_detections_ * 4);
out_boxes_d_ =
autoware::cuda_utils::make_unique<float[]>(batch_config[2] * max_detections_ * 4);
out_scores_d_ = autoware::cuda_utils::make_unique<float[]>(batch_config[2] * max_detections_);
out_classes_d_ = autoware::cuda_utils::make_unique<int32_t[]>(batch_config[2] * max_detections_);
out_classes_d_ =
autoware::cuda_utils::make_unique<int32_t[]>(batch_config[2] * max_detections_);
}
if (multitask_) {
// Allocate buffer for segmentation
Expand All @@ -317,9 +320,10 @@ TrtYoloX::TrtYoloX(
}
segmentation_out_elem_num_per_batch_ =
static_cast<int>(segmentation_out_elem_num_ / batch_config[2]);
segmentation_out_prob_d_ = autoware::cuda_utils::make_unique<float[]>(segmentation_out_elem_num_);
segmentation_out_prob_h_ =
autoware::cuda_utils::make_unique_host<float[]>(segmentation_out_elem_num_, cudaHostAllocPortable);
segmentation_out_prob_d_ =
autoware::cuda_utils::make_unique<float[]>(segmentation_out_elem_num_);
segmentation_out_prob_h_ = autoware::cuda_utils::make_unique_host<float[]>(
segmentation_out_elem_num_, cudaHostAllocPortable);

Check warning on line 326 in perception/autoware_tensorrt_yolox/src/tensorrt_yolox.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ Getting worse: Complex Method

TrtYoloX::TrtYoloX already has high cyclomatic complexity, and now it increases in Lines of Code from 151 to 155. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.
}
if (use_gpu_preprocess) {
use_gpu_preprocess_ = true;
Expand Down Expand Up @@ -396,7 +400,8 @@ void TrtYoloX::initPreprocessBuffer(int width, int height)
}
image_buf_h_ = autoware::cuda_utils::make_unique_host<unsigned char[]>(
width * height * 3 * batch_size_, cudaHostAllocWriteCombined);
image_buf_d_ = autoware::cuda_utils::make_unique<unsigned char[]>(width * height * 3 * batch_size_);
image_buf_d_ =
autoware::cuda_utils::make_unique<unsigned char[]>(width * height * 3 * batch_size_);
}
if (multitask_) {
size_t argmax_out_elem_num = 0;
Expand All @@ -414,8 +419,8 @@ void TrtYoloX::initPreprocessBuffer(int width, int height)
size_t out_elem_num = out_w * out_h * batch_size_;
argmax_out_elem_num += out_elem_num;
}
argmax_buf_h_ =
autoware::cuda_utils::make_unique_host<unsigned char[]>(argmax_out_elem_num, cudaHostAllocPortable);
argmax_buf_h_ = autoware::cuda_utils::make_unique_host<unsigned char[]>(
argmax_out_elem_num, cudaHostAllocPortable);
argmax_buf_d_ = autoware::cuda_utils::make_unique<unsigned char[]>(argmax_out_elem_num);
}
}
Expand Down Expand Up @@ -470,8 +475,8 @@ void TrtYoloX::preprocessGpu(const std::vector<cv::Mat> & images)
scales_.emplace_back(scale);
image_buf_h_ = autoware::cuda_utils::make_unique_host<unsigned char[]>(
image.cols * image.rows * 3 * batch_size, cudaHostAllocWriteCombined);
image_buf_d_ =
autoware::cuda_utils::make_unique<unsigned char[]>(image.cols * image.rows * 3 * batch_size);
image_buf_d_ = autoware::cuda_utils::make_unique<unsigned char[]>(
image.cols * image.rows * 3 * batch_size);
}
int index = b * image.cols * image.rows * 3;
// Copy into pinned memory
Expand All @@ -496,8 +501,8 @@ void TrtYoloX::preprocessGpu(const std::vector<cv::Mat> & images)

if (multitask_) {
if (!argmax_buf_h_) {
argmax_buf_h_ =
autoware::cuda_utils::make_unique_host<unsigned char[]>(argmax_out_elem_num, cudaHostAllocPortable);
argmax_buf_h_ = autoware::cuda_utils::make_unique_host<unsigned char[]>(
argmax_out_elem_num, cudaHostAllocPortable);
}
if (!argmax_buf_d_) {
argmax_buf_d_ = autoware::cuda_utils::make_unique<unsigned char[]>(argmax_out_elem_num);
Expand Down Expand Up @@ -618,8 +623,8 @@ void TrtYoloX::preprocessWithRoiGpu(
if (!image_buf_h_) {
image_buf_h_ = autoware::cuda_utils::make_unique_host<unsigned char[]>(
image.cols * image.rows * 3 * batch_size, cudaHostAllocWriteCombined);
image_buf_d_ =
autoware::cuda_utils::make_unique<unsigned char[]>(image.cols * image.rows * 3 * batch_size);
image_buf_d_ = autoware::cuda_utils::make_unique<unsigned char[]>(
image.cols * image.rows * 3 * batch_size);
}
int index = b * image.cols * image.rows * 3;
// Copy into pinned memory
Expand Down Expand Up @@ -735,7 +740,8 @@ void TrtYoloX::multiScalePreprocessGpu(const cv::Mat & image, const std::vector<
if (!image_buf_h_) {
image_buf_h_ = autoware::cuda_utils::make_unique_host<unsigned char[]>(
image.cols * image.rows * 3 * 1, cudaHostAllocWriteCombined);
image_buf_d_ = autoware::cuda_utils::make_unique<unsigned char[]>(image.cols * image.rows * 3 * 1);
image_buf_d_ =
autoware::cuda_utils::make_unique<unsigned char[]>(image.cols * image.rows * 3 * 1);
}
int index = 0 * image.cols * image.rows * 3;
// Copy into pinned memory
Expand Down
2 changes: 1 addition & 1 deletion perception/autoware_traffic_light_classifier/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

<build_depend>autoware_cmake</build_depend>

<depend>autoware_cuda_utils</depend>
<depend>autoware_tensorrt_classifier</depend>
<depend>autoware_tensorrt_common</depend>
<depend>autoware_cuda_utils</depend>
<depend>cv_bridge</depend>
<depend>image_transport</depend>
<depend>libboost-filesystem-dev</depend>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

#include "classifier_interface.hpp"

#include <autoware/tensorrt_classifier/tensorrt_classifier.hpp>
#include <autoware/tensorrt_common/tensorrt_common.hpp>
#include <autoware/cuda_utils/cuda_unique_ptr.hpp>
#include <autoware/cuda_utils/stream_unique_ptr.hpp>
#include <autoware/tensorrt_classifier/tensorrt_classifier.hpp>
#include <autoware/tensorrt_common/tensorrt_common.hpp>
#include <image_transport/image_transport.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
Expand Down

0 comments on commit a344c07

Please sign in to comment.