Skip to content

Commit d8fba09

Browse files
authored
ncnn2tengine deconv (#945)
* Update ncnn2tengine.cpp * apply code-format changes Co-authored-by: nihui <[email protected]>
1 parent 6a13dcc commit d8fba09

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

examples/tm_scrfd_trt_fp16.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,8 @@ static void draw_objects(const cv::Mat& bgr, const std::vector<FaceObject>& obje
270270
void show_usage()
271271
{
272272
fprintf(
273-
stderr,
274-
"[Usage]: [-h]\n [-m model_file] [-i image_file] [-r repeat_count] [-t thread_count]\n");
273+
stderr,
274+
"[Usage]: [-h]\n [-m model_file] [-i image_file] [-r repeat_count] [-t thread_count]\n");
275275
}
276276

277277
void get_input_data_scrfd(const char* image_file, float* input_data, int letterbox_rows, int letterbox_cols, const float* mean, const float* scale)
@@ -334,8 +334,8 @@ int main(int argc, char* argv[])
334334
const char* image_file = nullptr;
335335

336336
int img_c = 3;
337-
const float mean[3] = { 127.5f, 127.5f, 127.5f };
338-
const float scale[3] = { 1 / 128.f, 1 / 128.f, 1 / 128.f };
337+
const float mean[3] = {127.5f, 127.5f, 127.5f};
338+
const float scale[3] = {1 / 128.f, 1 / 128.f, 1 / 128.f};
339339

340340
// allow none square letterbox, set default letterbox size
341341
int letterbox_rows = 320;
@@ -409,9 +409,8 @@ int main(int argc, char* argv[])
409409
}
410410
fprintf(stderr, "tengine-lite library version: %s\n", get_tengine_version());
411411

412-
413412
/* create NVIDIA TensorRT backend */
414-
trt_option trt_opt = { 0 };
413+
trt_option trt_opt = {0};
415414
trt_opt.dev_name = "TensorRT";
416415
trt_opt.dla_index = 0;
417416
trt_opt.gpu_index = 0;
@@ -424,7 +423,6 @@ int main(int argc, char* argv[])
424423
return -1;
425424
}
426425

427-
428426
/* create graph, load tengine model xxx.tmfile */
429427
graph_t graph = create_graph(trt_context, "tengine", model_file);
430428
if (graph == nullptr)
@@ -434,7 +432,7 @@ int main(int argc, char* argv[])
434432
}
435433

436434
int img_size = letterbox_rows * letterbox_cols * img_c;
437-
int dims[] = { 1, 3, letterbox_rows, letterbox_cols };
435+
int dims[] = {1, 3, letterbox_rows, letterbox_cols};
438436
std::vector<float> input_data(img_size);
439437

440438
tensor_t input_tensor = get_graph_input_tensor(graph, 0, 0);
@@ -485,15 +483,15 @@ int main(int argc, char* argv[])
485483
max_time = (std::max)(max_time, cur);
486484
}
487485
fprintf(stderr, "Repeat %d times, thread %d, avg time %.2f ms, max_time %.2f ms, min_time %.2f ms\n", repeat_count, num_thread,
488-
total_time / repeat_count, max_time, min_time);
486+
total_time / repeat_count, max_time, min_time);
489487
fprintf(stderr, "--------------------------------------\n");
490488

491489
/* postprocess */
492490
const float prob_threshold = 0.3f;
493491
const float nms_threshold = 0.45f;
494492

495493
std::vector<FaceObject> proposals, objects;
496-
int strides[] = { 8, 16, 32 };
494+
int strides[] = {8, 16, 32};
497495
for (int stride_index = 0; stride_index < 3; stride_index++)
498496
{
499497
tensor_t score_tensor = get_graph_tensor(graph, score_pred_name[stride_index]);

tools/convert_tool/ncnn/ncnn2tengine.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,6 +1498,7 @@ void ncnn_serializer::register_op_load()
14981498
op_load_map["Slice"] = std::pair<int, op_load_t>(OP_SLICE, load_slice);
14991499
op_load_map["Sigmoid"] = std::pair<int, op_load_t>(OP_SIGMOID, load_no_param);
15001500
op_load_map["UnaryOp"] = std::pair<int, op_load_t>(OP_UNARY, load_unary);
1501+
op_load_map["Deconvolution"] = std::pair<int, op_load_t>(OP_DECONV, load_deconv);
15011502
op_load_map["DeconvolutionDepthWise"] = std::pair<int, op_load_t>(OP_DECONV, load_deconv);
15021503
}
15031504
/*

0 commit comments

Comments
 (0)