Skip to content

Commit 266ebda

Browse files
committed
Correct logic for cuda; Not compiling
1 parent ec2c4c7 commit 266ebda

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

include/yolo_onnx_ros/yolo_inference.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#include <opencv2/opencv.hpp>
99
#include "onnxruntime_cxx_api.h"
1010

11+
#include <yolo_onnx_ros/config.hpp>
12+
1113
#ifdef YOLO_ONNX_ROS_CUDA_ENABLED
1214
#include <cuda_fp16.h>
1315
#endif

src/detection.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#include "yolo_onnx_ros/detection.hpp"
2+
#include <yolo_onnx_ros/config.hpp>
3+
24
#include <fstream>
35
#include <iomanip>
46
#include <iostream>

src/yolo_inference.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ const char* YOLO_V8::RunSession(const cv::Mat& iImg, std::vector<DL_RESULT>& oRe
199199
#ifdef YOLO_ONNX_ROS_CUDA_ENABLED
200200
half* blob = new half[processedImg.total() * 3];
201201
BlobFromImage(processedImg, blob);
202-
std::vector<int64_t> inputNodeDims = { 1, 3, imgSize.at(1), imgSize.at(0) };
202+
std::vector<int64_t> inputNodeDims = { 1, 3, imgSize_.at(1), imgSize_.at(0) };
203203
TensorProcess(starttime_1, iImg, blob, inputNodeDims, oResult);
204204
#endif
205205
}
@@ -372,13 +372,13 @@ char* YOLO_V8::WarmUpSession() {
372372
#ifdef YOLO_ONNX_ROS_CUDA_ENABLED
373373
half* blob = new half[iImg.total() * 3];
374374
BlobFromImage(processedImg, blob);
375-
std::vector<int64_t> YOLO_input_node_dims = { 1, 3, imgSize.at(1), imgSize.at(0) };
376-
Ort::Value input_tensor = Ort::Value::CreateTensor<half>(Ort::MemoryInfo::CreateCpu(OrtDeviceAllocator, OrtMemTypeCPU), blob, 3 * imgSize.at(0) * imgSize.at(1), YOLO_input_node_dims.data(), YOLO_input_node_dims.size());
377-
auto output_tensors = session->Run(options, inputNodeNames.data(), &input_tensor, 1, outputNodeNames.data(), outputNodeNames.size());
375+
std::vector<int64_t> YOLO_input_node_dims = { 1, 3, imgSize_.at(1), imgSize_.at(0) };
376+
Ort::Value input_tensor = Ort::Value::CreateTensor<half>(Ort::MemoryInfo::CreateCpu(OrtDeviceAllocator, OrtMemTypeCPU), blob, 3 * imgSize_.at(0) * imgSize_.at(1), YOLO_input_node_dims.data(), YOLO_input_node_dims.size());
377+
auto output_tensors = session_->Run(options, inputNodeNames_.data(), &input_tensor, 1, outputNodeNames_.data(), outputNodeNames_.size());
378378
delete[] blob;
379379
clock_t starttime_4 = clock();
380380
double post_process_time = (double)(starttime_4 - starttime_1) / CLOCKS_PER_SEC * 1000;
381-
if (cudaEnable)
381+
if (cudaEnable_)
382382
{
383383
std::cout << "[YOLO_V8(CUDA)]: " << "Cuda warm-up cost " << post_process_time << " ms. " << std::endl;
384384
}

0 commit comments

Comments
 (0)