Skip to content

Commit

Permalink
Merge pull request #13 from liwuhen/feat-dev
Browse files Browse the repository at this point in the history
chore: add clang-format
  • Loading branch information
liwuhen authored Nov 21, 2024
2 parents 8c952b4 + 7eae87e commit 892bcf0
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 27 deletions.
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ ci:

repos:

# # Clang format the codebase automatically
# - repo: https://github.com/pre-commit/mirrors-clang-format
# rev: "v14.0.6"
# hooks:
# - id: clang-format
# types_or: [c++, c, cuda]
# Clang format the codebase automatically
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: "v14.0.6"
hooks:
- id: clang-format
types_or: [c++, c, cuda]

# Check static types with mypy
- repo: https://github.com/pre-commit/mirrors-mypy
Expand Down
4 changes: 2 additions & 2 deletions modules/app_yolo/architecture/cuda/gpu_decode.cu
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ static __global__ void fast_nms_kernel(float* bboxes, int max_objects, float thr
// 如果测mAP的性能的时候, 只能采用cpu nms
// 如果是日常推理, 则可以使用这个gpu nms
int position = (blockDim.x * blockIdx.x + threadIdx.x);
int count =
min(static_cast<int>(*bboxes), max_objects); // *bboxes表示首地址的第一个元素。 count是bbox的数量。
int count = min(static_cast<int>(*bboxes),
max_objects); // *bboxes表示首地址的第一个元素。 count是bbox的数量。
if (position >= count) return;

// left, top, right, bottom, confidence, class, keepflag
Expand Down
2 changes: 1 addition & 1 deletion modules/app_yolo/architecture/postprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void PostProcessor::Inference() {
* @description: Visualization.
*/
void PostProcessor::Visualization(bool real_time, cv::Mat& img, int64_t timestamp,
vector<Box>& results) {
vector<Box>& results) {
for (auto& box : results) {
cv::rectangle(img, cv::Point(box.left, box.top), cv::Point(box.right, box.bottom),
cv::Scalar(0, 255, 0), 2);
Expand Down
15 changes: 6 additions & 9 deletions modules/app_yolo/architecture/preprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ bool PreProcessor::DataResourceRelease() {}
* @description: Inference.
*/
bool PreProcessor::Inference(InfertMsg& input_msg, float* dstimg, DeviceMode inferMode,
cudaStream_t stream) {
cudaStream_t stream) {
CalAffineMatrix(input_msg);

switch (inferMode) {
Expand All @@ -91,8 +91,9 @@ bool PreProcessor::Inference(InfertMsg& input_msg, float* dstimg, DeviceMode inf
}
break;
case DeviceMode::CPU_MODE:
if (!CpuPreprocessor(input_msg.image, input_msg.timestamp, dstimg, stream))
{ return false; }
if (!CpuPreprocessor(input_msg.image, input_msg.timestamp, dstimg, stream)) {
return false;
}
break;
default:
break;
Expand Down Expand Up @@ -125,12 +126,8 @@ bool PreProcessor::GpuPreprocessor(InfertMsg& input_msg, float* dstimg, cudaStre
/**
* @description: Cpu preprocessor.
*/
bool PreProcessor::CpuPreprocessor(
cv::Mat& srcimg,
uint64_t timestamp,
float* input_device_gpu,
cudaStream_t stream) {

bool PreProcessor::CpuPreprocessor(cv::Mat& srcimg, uint64_t timestamp, float* input_device_gpu,
cudaStream_t stream) {
checkRuntime(cudaMallocHost(&input_data_host_, sizeof(float) * parsemsgs_->dstimg_size_));

float scale_x = parsemsgs_->dst_img_w_ / static_cast<float>(parsemsgs_->src_img_w_);
Expand Down
3 changes: 2 additions & 1 deletion modules/app_yolo/architecture/trt_infer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ bool TrtInfer::Inference(float* output_img_device) {
output_img_device, parsemsgs_->dstimg_size_ * sizeof(uint8_t),
cudaMemcpyDeviceToDevice));

bool success = execution_context_->enqueueV2(reinterpret_cast<void**>(gpu_buffers_), stream_, nullptr);
bool success =
execution_context_->enqueueV2(reinterpret_cast<void**>(gpu_buffers_), stream_, nullptr);
if (!success) {
LOG(ERROR) << " Inference failed ";
return false;
Expand Down
3 changes: 1 addition & 2 deletions modules/common/msg_img/dataset.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ static const char* cocolabels[] = {"person", "bicycle", "car",
"oven", "toaster", "sink",
"refrigerator", "book", "clock",
"vase", "scissors", "teddy bear",
"hair drier", "toothbrush"
};
"hair drier", "toothbrush"};

// hsv 转 bgr
static std::tuple<uint8_t, uint8_t, uint8_t> hsv2bgr(float h, float s, float v) {
Expand Down
4 changes: 2 additions & 2 deletions modules/common/msg_struct/task_struct.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ struct CVImage {
std::vector<uint8_t> data; // 存储连续的像素值

CVImage();
CVImage(int width, int height, int channel) : img_width(width), \
img_height(height), img_channel(channel), img_size(0) {}
CVImage(int width, int height, int channel)
: img_width(width), img_height(height), img_channel(channel), img_size(0) {}

~CVImage() {}

Expand Down
6 changes: 3 additions & 3 deletions modules/common/utils/std_cmake.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace common {

#define MODEL_FLAG "yolov5"

} //namespace common
} //namespace hpc
} // namespace common
} // namespace hpc

#endif // APP_COMMON_STD_CMAKE_H_IN__
#endif // APP_COMMON_STD_CMAKE_H_IN__
3 changes: 2 additions & 1 deletion modules/common/utils/std_time.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ namespace common {

static time_t GetSystmeTime() {
return static_cast<int64_t>(std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now().time_since_epoch()).count());
std::chrono::system_clock::now().time_since_epoch())
.count());
}

} // namespace common
Expand Down

0 comments on commit 892bcf0

Please sign in to comment.