From a3753aae50f890b1bae296d50ca3b3adc5ebb4ba Mon Sep 17 00:00:00 2001 From: littletomatodonkey Date: Fri, 13 May 2022 14:28:35 +0000 Subject: [PATCH 1/4] fix rec prediction for trt7 --- tools/infer/utility.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/infer/utility.py b/tools/infer/utility.py index 74ec42ec84..67a0317734 100644 --- a/tools/infer/utility.py +++ b/tools/infer/utility.py @@ -272,9 +272,10 @@ def create_predictor(args, mode, logger): if args.rec_algorithm not in ["CRNN", "SVTR_LCNet"]: use_dynamic_shape = False imgH = int(args.rec_image_shape.split(',')[-2]) - min_input_shape = {"x": [1, 3, imgH, 10]} - max_input_shape = {"x": [args.rec_batch_num, 3, imgH, 2304]} - opt_input_shape = {"x": [args.rec_batch_num, 3, imgH, 320]} + min_input_shape = {"x": [1, 3, imgH, 10], } + max_input_shape = {"x": [args.rec_batch_num, 3, imgH, 2304], } + opt_input_shape = {"x": [args.rec_batch_num, 3, imgH, 320], } + config.exp_disable_tensorrt_ops(["elementwise_add"]) elif mode == "cls": min_input_shape = {"x": [1, 3, 48, 10]} max_input_shape = {"x": [args.rec_batch_num, 3, 48, 1024]} From c425ba9b852fe9100abeeb295ffb6b4fe146f1e6 Mon Sep 17 00:00:00 2001 From: littletomatodonkey Date: Fri, 13 May 2022 14:45:06 +0000 Subject: [PATCH 2/4] fix --- tools/infer/utility.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tools/infer/utility.py b/tools/infer/utility.py index 67a0317734..db28af5f43 100644 --- a/tools/infer/utility.py +++ b/tools/infer/utility.py @@ -272,10 +272,10 @@ def create_predictor(args, mode, logger): if args.rec_algorithm not in ["CRNN", "SVTR_LCNet"]: use_dynamic_shape = False imgH = int(args.rec_image_shape.split(',')[-2]) - min_input_shape = {"x": [1, 3, imgH, 10], } - max_input_shape = {"x": [args.rec_batch_num, 3, imgH, 2304], } - opt_input_shape = {"x": [args.rec_batch_num, 3, imgH, 320], } - config.exp_disable_tensorrt_ops(["elementwise_add"]) + min_input_shape = {"x": [1, 3, imgH, 10]} + max_input_shape = {"x": [args.rec_batch_num, 3, imgH, 2304]} + opt_input_shape = {"x": [args.rec_batch_num, 3, imgH, 320]} + config.exp_disable_tensorrt_ops(["transpose2"]) elif mode == "cls": min_input_shape = {"x": [1, 3, 48, 10]} max_input_shape = {"x": [args.rec_batch_num, 3, 48, 1024]} @@ -283,6 +283,9 @@ def create_predictor(args, mode, logger): else: use_dynamic_shape = False if use_dynamic_shape: + print("min_input_shape: ", min_input_shape) + print("max_input_shape: ", max_input_shape) + print("opt_input_shape: ", opt_input_shape) config.set_trt_dynamic_shape_info( min_input_shape, max_input_shape, opt_input_shape) @@ -301,7 +304,7 @@ def create_predictor(args, mode, logger): config.enable_mkldnn_bfloat16() # enable memory optim config.enable_memory_optim() - config.disable_glog_info() + # config.disable_glog_info() config.delete_pass("conv_transpose_eltwiseadd_bn_fuse_pass") config.delete_pass("matmul_transpose_reshape_fuse_pass") if mode == 'table': From 85cfc51ece35abcc0886323c2f9978fa4b741c96 Mon Sep 17 00:00:00 2001 From: littletomatodonkey Date: Fri, 13 May 2022 14:45:40 +0000 Subject: [PATCH 3/4] fix --- tools/infer/utility.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/tools/infer/utility.py b/tools/infer/utility.py index db28af5f43..57fdc1e28c 100644 --- a/tools/infer/utility.py +++ b/tools/infer/utility.py @@ -283,9 +283,6 @@ def create_predictor(args, mode, logger): else: use_dynamic_shape = False if use_dynamic_shape: - print("min_input_shape: ", min_input_shape) - print("max_input_shape: ", max_input_shape) - print("opt_input_shape: ", opt_input_shape) config.set_trt_dynamic_shape_info( min_input_shape, max_input_shape, opt_input_shape) From 265cd32bd5b9f76ce3a1ed03bc6eb835e56d16af Mon Sep 17 00:00:00 2001 From: littletomatodonkey Date: Fri, 13 May 2022 14:46:02 +0000 Subject: [PATCH 4/4] fix --- tools/infer/utility.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/infer/utility.py b/tools/infer/utility.py index 57fdc1e28c..48b16db4a0 100644 --- a/tools/infer/utility.py +++ b/tools/infer/utility.py @@ -301,7 +301,7 @@ def create_predictor(args, mode, logger): config.enable_mkldnn_bfloat16() # enable memory optim config.enable_memory_optim() - # config.disable_glog_info() + config.disable_glog_info() config.delete_pass("conv_transpose_eltwiseadd_bn_fuse_pass") config.delete_pass("matmul_transpose_reshape_fuse_pass") if mode == 'table':