From fdf1ba692014ac17c704e6cc561bfd52e6b3d3a8 Mon Sep 17 00:00:00 2001 From: wenbin Date: Fri, 14 Jan 2022 13:24:40 +0000 Subject: [PATCH 1/4] develop test --- .../tests/unittests/ir/inference/test_trt_convert_conv2d.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_conv2d.py b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_conv2d.py index 4726524523552..3e4fc86825fc0 100644 --- a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_conv2d.py +++ b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_conv2d.py @@ -33,7 +33,7 @@ def is_program_valid(self, program_config: ProgramConfig) -> bool: if inputs['input_data'].shape[1] != weights['conv2d_weight'].shape[ 1] * attrs[0]['groups']: return False - + print('my log') return True def sample_program_configs(self): From 409eecfcc7a11f0f89927326eb370c4d92e06554 Mon Sep 17 00:00:00 2001 From: wenbin Date: Mon, 17 Jan 2022 02:39:34 +0000 Subject: [PATCH 2/4] throw --- paddle/fluid/inference/tensorrt/engine.h | 5 +++++ .../tests/unittests/ir/inference/test_trt_convert_conv2d.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/paddle/fluid/inference/tensorrt/engine.h b/paddle/fluid/inference/tensorrt/engine.h index 663534feda1a8..3f99f7efc5091 100644 --- a/paddle/fluid/inference/tensorrt/engine.h +++ b/paddle/fluid/inference/tensorrt/engine.h @@ -128,6 +128,11 @@ nvinfer1::Dims Vec2TRT_Dims(const std::vector& shape, std::string input, dims.d[0] = shape[1]; return dims; } + // static shape doesn't support these shapes so far. + PADDLE_THROW(platform::errors::InvalidArgument( + "The input [%s] shape of trt subgraph is %s." + "it's not supported by trt so far", + input, ShapeStr(shape))); return nvinfer1::Dims3(shape[1], 1, 1); } else { if (shape.size() == 4UL) { diff --git a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_conv2d.py b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_conv2d.py index 3e4fc86825fc0..4726524523552 100644 --- a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_conv2d.py +++ b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_conv2d.py @@ -33,7 +33,7 @@ def is_program_valid(self, program_config: ProgramConfig) -> bool: if inputs['input_data'].shape[1] != weights['conv2d_weight'].shape[ 1] * attrs[0]['groups']: return False - print('my log') + return True def sample_program_configs(self): From 33b9d655cb2b551dee6f5568332be2a0bb4d56b2 Mon Sep 17 00:00:00 2001 From: wenbin Date: Mon, 17 Jan 2022 05:31:47 +0000 Subject: [PATCH 3/4] ne --- paddle/fluid/inference/tensorrt/engine.h | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/paddle/fluid/inference/tensorrt/engine.h b/paddle/fluid/inference/tensorrt/engine.h index 3f99f7efc5091..c0cabf350c906 100644 --- a/paddle/fluid/inference/tensorrt/engine.h +++ b/paddle/fluid/inference/tensorrt/engine.h @@ -128,12 +128,19 @@ nvinfer1::Dims Vec2TRT_Dims(const std::vector& shape, std::string input, dims.d[0] = shape[1]; return dims; } - // static shape doesn't support these shapes so far. - PADDLE_THROW(platform::errors::InvalidArgument( - "The input [%s] shape of trt subgraph is %s." - "it's not supported by trt so far", - input, ShapeStr(shape))); - return nvinfer1::Dims3(shape[1], 1, 1); + // static shape doesn't support 1D op so far. + PADDLE_ENFORCE_NE(shape.size(), 1UL, + platform::errors::InvalidArgument( + "The input [%s] shape of trt subgraph is %s." + "it's not supported by trt so far", + input, ShapeStr(shape))); + + nvinfer1::Dims dims; + dims.nbDims = shape.size() - 1; + for (size_t i = 1; i < shape.size(); i++) { + dims.d[i] = shape[i]; + } + return dims; } else { if (shape.size() == 4UL) { return nvinfer1::Dims4(shape[0], shape[1], shape[2], shape[3]); From fea90456716d2c9d0694c0c7c0384d9243a3c7ac Mon Sep 17 00:00:00 2001 From: wenbin Date: Mon, 17 Jan 2022 08:51:41 +0000 Subject: [PATCH 4/4] wrong cnt --- paddle/fluid/inference/tensorrt/engine.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paddle/fluid/inference/tensorrt/engine.h b/paddle/fluid/inference/tensorrt/engine.h index c0cabf350c906..849ec07d07ed7 100644 --- a/paddle/fluid/inference/tensorrt/engine.h +++ b/paddle/fluid/inference/tensorrt/engine.h @@ -138,7 +138,7 @@ nvinfer1::Dims Vec2TRT_Dims(const std::vector& shape, std::string input, nvinfer1::Dims dims; dims.nbDims = shape.size() - 1; for (size_t i = 1; i < shape.size(); i++) { - dims.d[i] = shape[i]; + dims.d[i - 1] = shape[i]; } return dims; } else {