Skip to content

Commit a68ffed

Browse files
author
Wish
committed
fix lesson.cpp hz
1 parent 1ae18d2 commit a68ffed

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

src/application/app_lesson.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,32 +33,32 @@ using namespace std;
3333
static void test_tensor2(){
3434

3535
///////////////////////////////////////////////////////////////////
36-
// 内存的自动复制,依靠head属性标记数据最新的位置
37-
// 若访问的数据不是最新的,则会自动发生复制操作
36+
/* 内存的自动复制,依靠head属性标记数据最新的位置
37+
若访问的数据不是最新的,则会自动发生复制操作 */
3838
TRT::Tensor tensor({1, 3, 5, 5}, TRT::DataType::Float);
39-
INFO("tensor.head = %s", TRT::data_head_string(tensor.head())); // 输出 Init,内存没有分配
39+
INFO("tensor.head = %s", TRT::data_head_string(tensor.head())); /* 输出 Init,内存没有分配 */
4040

41-
tensor.cpu<float>()[0] = 512; // 访问cpu时,分配cpu内存
42-
INFO("tensor.head = %s", TRT::data_head_string(tensor.head())); // 输出 Host
41+
tensor.cpu<float>()[0] = 512; /* 访问cpu时,分配cpu内存 */
42+
INFO("tensor.head = %s", TRT::data_head_string(tensor.head())); /* 输出 Host */
4343

44-
float* device_ptr = tensor.gpu<float>(); // 访问gpu时,最新数据在Host,发生复制动作并标记最新数据在Device
45-
INFO("tensor.head = %s", TRT::data_head_string(tensor.head())); // 输出 Device
46-
INFO("device_ptr[0] = %f", device_ptr[0]); // 输出 512.00000
44+
float* device_ptr = tensor.gpu<float>(); /* 访问gpu时,最新数据在Host,发生复制动作并标记最新数据在Device */
45+
INFO("tensor.head = %s", TRT::data_head_string(tensor.head())); /* 输出 Device */
46+
INFO("device_ptr[0] = %f", device_ptr[0]); /* 输出 512.00000 */
4747
}
4848

4949
static void test_tensor3(){
5050

5151
///////////////////////////////////////////////////////////////////
52-
// 计算维度的偏移量
52+
/* 计算维度的偏移量 */
5353
TRT::Tensor tensor({1, 3, 5, 5, 2, 5}, TRT::DataType::Float);
5454
auto ptr_origin = tensor.cpu<float>();
5555
auto ptr_channel2 = tensor.cpu<float>(0, 2, 3, 2, 1, 3);
5656

57-
INFO("Offset = %d", ptr_channel2 - ptr_origin); // 输出678
58-
INFO("Offset = %d", tensor.offset(0, 2, 3, 2, 1, 3)); // 输出678
57+
INFO("Offset = %d", ptr_channel2 - ptr_origin); /* 输出678 */
58+
INFO("Offset = %d", tensor.offset(0, 2, 3, 2, 1, 3)); /* 输出678 */
5959

6060
int offset_compute = ((((0 * 3 + 2) * 5 + 3) * 5 + 2) * 2 + 1) * 5 + 3;
61-
INFO("Compute = %d", offset_compute); // 输出678
61+
INFO("Compute = %d", offset_compute); /* 输出678 */
6262
}
6363

6464
static void lesson1(){

src/application/app_yolo.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ static void test(Yolo::Type type, TRT::Mode mode, const string& model){
169169
forward_engine(model_file, type);
170170
}
171171

172-
void my_test(){
172+
static void my_yolov5_test(){
173173

174174
TRT::compile(
175175
TRT::Mode::FP32,
@@ -206,7 +206,6 @@ void my_test(){
206206

207207
int app_yolo(){
208208

209-
// my_test();
210209
//iLogger::set_log_level(iLogger::LogLevel::Info);
211210
test(Yolo::Type::X, TRT::Mode::FP32, "yolox_m");
212211
// test(Yolo::Type::V5, TRT::Mode::FP32, "yolov5s");

workspace/my-yoloxs-car.jpg

403 KB
Loading

0 commit comments

Comments
 (0)