Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
0951bfd1
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
0951bfd1
编写于
10月 25, 2021
作者:
W
Wilber
提交者:
GitHub
10月 25, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[cherry-pick] enable trt test check and fix trt ut error (#36371) (#36654)
上级
cb33835c
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
204 addition
and
32 deletion
+204
-32
paddle/fluid/inference/tensorrt/op_teller.cc
paddle/fluid/inference/tensorrt/op_teller.cc
+97
-12
paddle/fluid/inference/tensorrt/plugin/hard_swish_op_plugin.h
...le/fluid/inference/tensorrt/plugin/hard_swish_op_plugin.h
+1
-1
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_anchor_generator.py
...ittests/ir/inference/test_trt_convert_anchor_generator.py
+5
-1
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_batch_norm.py
...sts/unittests/ir/inference/test_trt_convert_batch_norm.py
+13
-0
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_clip.py
...uid/tests/unittests/ir/inference/test_trt_convert_clip.py
+16
-2
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_concat.py
...d/tests/unittests/ir/inference/test_trt_convert_concat.py
+13
-0
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_dropout.py
.../tests/unittests/ir/inference/test_trt_convert_dropout.py
+7
-2
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_hard_sigmoid.py
...s/unittests/ir/inference/test_trt_convert_hard_sigmoid.py
+1
-0
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_reduce_sum.py
...sts/unittests/ir/inference/test_trt_convert_reduce_sum.py
+5
-5
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_roi_align.py
...ests/unittests/ir/inference/test_trt_convert_roi_align.py
+2
-0
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_skip_layernorm.py
...unittests/ir/inference/test_trt_convert_skip_layernorm.py
+1
-0
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_slice.py
...id/tests/unittests/ir/inference/test_trt_convert_slice.py
+5
-1
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_softmax.py
.../tests/unittests/ir/inference/test_trt_convert_softmax.py
+12
-1
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_split.py
...id/tests/unittests/ir/inference/test_trt_convert_split.py
+13
-0
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_stack.py
...id/tests/unittests/ir/inference/test_trt_convert_stack.py
+1
-0
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_tile.py
...uid/tests/unittests/ir/inference/test_trt_convert_tile.py
+7
-3
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_yolo_box.py
...tests/unittests/ir/inference/test_trt_convert_yolo_box.py
+1
-0
python/paddle/fluid/tests/unittests/ir/inference/trt_layer_auto_scan_test.py
.../tests/unittests/ir/inference/trt_layer_auto_scan_test.py
+4
-4
未找到文件。
paddle/fluid/inference/tensorrt/op_teller.cc
浏览文件 @
0951bfd1
...
@@ -173,6 +173,12 @@ bool OpTeller::Tell(const framework::ir::Node* node, bool use_no_calib_int8,
...
@@ -173,6 +173,12 @@ bool OpTeller::Tell(const framework::ir::Node* node, bool use_no_calib_int8,
<<
" op does not support input's dim is 1 in tensorrt."
;
<<
" op does not support input's dim is 1 in tensorrt."
;
return
false
;
return
false
;
}
}
// TODO(inference): fix
if
(
x_shape
.
size
()
==
2
&&
!
with_dynamic_shape
)
{
VLOG
(
3
)
<<
"activation op does not support input's dim is 2 in "
"tensorrt static shape, the output shape has diff."
;
return
false
;
}
}
}
if
(
op_type
==
"pool2d"
)
{
if
(
op_type
==
"pool2d"
)
{
...
@@ -345,6 +351,24 @@ bool OpTeller::Tell(const framework::ir::Node* node, bool use_no_calib_int8,
...
@@ -345,6 +351,24 @@ bool OpTeller::Tell(const framework::ir::Node* node, bool use_no_calib_int8,
}
}
}
}
}
}
if
(
op_type
==
"softmax"
)
{
auto
*
block
=
desc
.
Block
();
if
(
block
==
nullptr
)
{
VLOG
(
3
)
<<
"The block desc is nullptr, we can't continue to analyze. "
"Developers need to check whether block_desc is passed in "
"the pass."
;
return
false
;
}
auto
x_var_name
=
desc
.
Input
(
"X"
)[
0
];
auto
*
x_var_desc
=
block
->
FindVar
(
x_var_name
);
const
auto
x_shape
=
x_var_desc
->
GetShape
();
// TODO(inference): fix
if
(
x_shape
.
size
()
==
2
&&
!
with_dynamic_shape
)
{
VLOG
(
3
)
<<
"softmax op does not support input's dim is 2 in tensorrt "
"static shape, the output shape has diff."
;
return
false
;
}
}
if
(
op_type
==
"group_norm"
)
{
if
(
op_type
==
"group_norm"
)
{
if
(
!
with_dynamic_shape
)
return
false
;
if
(
!
with_dynamic_shape
)
return
false
;
bool
has_attrs
=
(
desc
.
HasAttr
(
"epsilon"
)
&&
desc
.
HasAttr
(
"groups"
));
bool
has_attrs
=
(
desc
.
HasAttr
(
"epsilon"
)
&&
desc
.
HasAttr
(
"groups"
));
...
@@ -356,20 +380,35 @@ bool OpTeller::Tell(const framework::ir::Node* node, bool use_no_calib_int8,
...
@@ -356,20 +380,35 @@ bool OpTeller::Tell(const framework::ir::Node* node, bool use_no_calib_int8,
if
(
op_type
==
"concat"
)
{
if
(
op_type
==
"concat"
)
{
if
(
!
desc
.
HasAttr
(
"axis"
))
{
if
(
!
desc
.
HasAttr
(
"axis"
))
{
return
false
;
return
false
;
}
int
axis
=
BOOST_GET_CONST
(
int
,
desc
.
GetAttr
(
"axis"
));
if
(
with_dynamic_shape
)
{
if
(
axis
<
0
)
return
false
;
}
else
{
}
else
{
int
axis
=
BOOST_GET_CONST
(
int
,
desc
.
GetAttr
(
"axis"
));
if
(
axis
<=
0
)
return
false
;
if
(
with_dynamic_shape
)
{
}
if
(
axis
<
0
)
return
false
;
auto
concat_inputs
=
desc
.
Inputs
();
}
else
{
if
(
concat_inputs
.
find
(
"AxisTensor"
)
!=
concat_inputs
.
end
())
{
if
(
axis
<=
0
)
return
false
;
if
(
desc
.
Input
(
"AxisTensor"
).
size
()
>=
1
)
{
}
return
false
;
auto
concat_inputs
=
desc
.
Inputs
();
if
(
concat_inputs
.
find
(
"AxisTensor"
)
!=
concat_inputs
.
end
())
{
if
(
desc
.
Input
(
"AxisTensor"
).
size
()
>=
1
)
{
return
false
;
}
}
}
}
}
auto
*
block
=
desc
.
Block
();
if
(
block
==
nullptr
)
{
VLOG
(
3
)
<<
"The block desc is nullptr, we can't continue to analyze. "
"Developers need to check whether block_desc is passed in "
"the pass."
;
return
false
;
}
auto
x_var_name
=
desc
.
Input
(
"X"
)[
0
];
auto
*
x_var_desc
=
block
->
FindVar
(
x_var_name
);
const
auto
x_shape
=
x_var_desc
->
GetShape
();
// TODO(inference): fix
if
(
x_shape
.
size
()
==
2
&&
!
with_dynamic_shape
)
{
VLOG
(
3
)
<<
"concat op does not support input's dim is 2 in tensorrt "
"static shape, the output shape has diff."
;
return
false
;
}
}
}
if
(
op_type
==
"transpose2"
||
op_type
==
"transpose"
)
{
if
(
op_type
==
"transpose2"
||
op_type
==
"transpose"
)
{
if
(
!
desc
.
HasAttr
(
"axis"
))
{
if
(
!
desc
.
HasAttr
(
"axis"
))
{
...
@@ -659,6 +698,22 @@ bool OpTeller::Tell(const framework::ir::Node* node, bool use_no_calib_int8,
...
@@ -659,6 +698,22 @@ bool OpTeller::Tell(const framework::ir::Node* node, bool use_no_calib_int8,
<<
desc
.
Output
(
"Y"
).
size
()
<<
"."
;
<<
desc
.
Output
(
"Y"
).
size
()
<<
"."
;
return
false
;
return
false
;
}
}
auto
*
block
=
desc
.
Block
();
if
(
block
==
nullptr
)
{
VLOG
(
3
)
<<
"The block desc is nullptr, we can't continue to analyze. "
"Developers need to check whether block_desc is passed in "
"the pass."
;
return
false
;
}
auto
x_var_name
=
desc
.
Input
(
"X"
)[
0
];
auto
*
x_var_desc
=
block
->
FindVar
(
x_var_name
);
const
auto
x_shape
=
x_var_desc
->
GetShape
();
// TODO(inference): fix
if
(
x_shape
.
size
()
==
2
&&
!
with_dynamic_shape
)
{
VLOG
(
3
)
<<
"batch_norm op does not support input's dim is 2 in "
"tensorrt static shape, the output shape has diff."
;
return
false
;
}
}
}
if
(
op_type
==
"split"
)
{
if
(
op_type
==
"split"
)
{
...
@@ -746,6 +801,12 @@ bool OpTeller::Tell(const framework::ir::Node* node, bool use_no_calib_int8,
...
@@ -746,6 +801,12 @@ bool OpTeller::Tell(const framework::ir::Node* node, bool use_no_calib_int8,
VLOG
(
3
)
<<
"The output_length should be equal to the output size."
;
VLOG
(
3
)
<<
"The output_length should be equal to the output size."
;
return
false
;
return
false
;
}
}
// TODO(inference): fix
if
(
x_shape
.
size
()
==
2
&&
!
with_dynamic_shape
)
{
VLOG
(
3
)
<<
"split op does not support input's dim is 2 in tensorrt "
"static shape. The output shape has diff."
;
return
false
;
}
}
}
if
(
op_type
==
"scale"
)
{
if
(
op_type
==
"scale"
)
{
auto
scale_inputs
=
desc
.
Inputs
();
auto
scale_inputs
=
desc
.
Inputs
();
...
@@ -898,6 +959,12 @@ bool OpTeller::Tell(const framework::ir::Node* node, bool use_no_calib_int8,
...
@@ -898,6 +959,12 @@ bool OpTeller::Tell(const framework::ir::Node* node, bool use_no_calib_int8,
VLOG
(
3
)
<<
"gelu op does not support input's dim is 1 in tensorrt."
;
VLOG
(
3
)
<<
"gelu op does not support input's dim is 1 in tensorrt."
;
return
false
;
return
false
;
}
}
// TODO(inference): fix
if
(
x_shape
.
size
()
==
2
&&
!
with_dynamic_shape
)
{
VLOG
(
3
)
<<
"gelu op does not support input's dim is 2 in tensorrt "
"static shape, the output shape has diff."
;
return
false
;
}
}
}
if
(
op_type
==
"layer_norm"
)
{
if
(
op_type
==
"layer_norm"
)
{
...
@@ -1013,7 +1080,13 @@ bool OpTeller::Tell(const framework::ir::Node* node, bool use_no_calib_int8,
...
@@ -1013,7 +1080,13 @@ bool OpTeller::Tell(const framework::ir::Node* node, bool use_no_calib_int8,
auto
*
x_var_desc
=
block
->
FindVar
(
x_var_name
);
auto
*
x_var_desc
=
block
->
FindVar
(
x_var_name
);
const
auto
x_shape
=
x_var_desc
->
GetShape
();
const
auto
x_shape
=
x_var_desc
->
GetShape
();
if
(
x_shape
.
size
()
==
1
)
{
if
(
x_shape
.
size
()
==
1
)
{
VLOG
(
3
)
<<
"dropout op does not support input's dim is 1 in tensorrt."
;
VLOG
(
3
)
<<
"scale op does not support input's dim is 1 in tensorrt."
;
return
false
;
}
// TODO(inference): fix
if
(
x_shape
.
size
()
==
2
&&
!
with_dynamic_shape
)
{
VLOG
(
3
)
<<
"scale op does not support input's dim is 2 in tensorrt "
"static shape, the output shape has diff."
;
return
false
;
return
false
;
}
}
}
}
...
@@ -1033,6 +1106,12 @@ bool OpTeller::Tell(const framework::ir::Node* node, bool use_no_calib_int8,
...
@@ -1033,6 +1106,12 @@ bool OpTeller::Tell(const framework::ir::Node* node, bool use_no_calib_int8,
VLOG
(
3
)
<<
"swish op does not support input's dim is 1 in tensorrt."
;
VLOG
(
3
)
<<
"swish op does not support input's dim is 1 in tensorrt."
;
return
false
;
return
false
;
}
}
// TODO(inference): fix
if
(
x_shape
.
size
()
==
2
&&
!
with_dynamic_shape
)
{
VLOG
(
3
)
<<
"swish op does not support input's dim is 2 in tensorrt "
"static shape, the output shape has diff."
;
return
false
;
}
}
}
if
(
op_type
==
"prelu"
)
{
if
(
op_type
==
"prelu"
)
{
...
@@ -1204,6 +1283,12 @@ bool OpTeller::Tell(const framework::ir::Node* node, bool use_no_calib_int8,
...
@@ -1204,6 +1283,12 @@ bool OpTeller::Tell(const framework::ir::Node* node, bool use_no_calib_int8,
VLOG
(
3
)
<<
"clip op does not support input's dim is 1 in tensorrt."
;
VLOG
(
3
)
<<
"clip op does not support input's dim is 1 in tensorrt."
;
return
false
;
return
false
;
}
}
// TODO(inference): fix
if
(
x_shape
.
size
()
==
2
&&
!
with_dynamic_shape
)
{
VLOG
(
3
)
<<
"clip op does not support input's dim is 2 in tensorrt "
"static shape, the output shape has diff."
;
return
false
;
}
}
}
if
(
op_type
==
"reduce_sum"
||
op_type
==
"reduce_mean"
)
{
if
(
op_type
==
"reduce_sum"
||
op_type
==
"reduce_mean"
)
{
...
...
paddle/fluid/inference/tensorrt/plugin/hard_swish_op_plugin.h
浏览文件 @
0951bfd1
...
@@ -161,7 +161,7 @@ class HardSwishPluginDynamicCreator : public nvinfer1::IPluginCreator {
...
@@ -161,7 +161,7 @@ class HardSwishPluginDynamicCreator : public nvinfer1::IPluginCreator {
public:
public:
HardSwishPluginDynamicCreator
()
{}
HardSwishPluginDynamicCreator
()
{}
const
char
*
getPluginName
()
const
TRT_NOEXCEPT
override
{
const
char
*
getPluginName
()
const
TRT_NOEXCEPT
override
{
return
"hardswish_plugin_dynamic"
;
return
"hard
_
swish_plugin_dynamic"
;
}
}
const
char
*
getPluginVersion
()
const
TRT_NOEXCEPT
override
{
return
"1"
;
}
const
char
*
getPluginVersion
()
const
TRT_NOEXCEPT
override
{
return
"1"
;
}
...
...
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_anchor_generator.py
浏览文件 @
0951bfd1
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
from
trt_layer_auto_scan_test
import
TrtLayerAutoScanTest
,
SkipReasons
from
trt_layer_auto_scan_test
import
TrtLayerAutoScanTest
,
SkipReasons
from
program_config
import
TensorConfig
,
ProgramConfig
from
program_config
import
TensorConfig
,
ProgramConfig
import
unittest
import
numpy
as
np
import
numpy
as
np
import
paddle.inference
as
paddle_infer
import
paddle.inference
as
paddle_infer
from
functools
import
partial
from
functools
import
partial
...
@@ -83,7 +84,10 @@ class TrtConvertAnchorGeneratorTest(TrtLayerAutoScanTest):
...
@@ -83,7 +84,10 @@ class TrtConvertAnchorGeneratorTest(TrtLayerAutoScanTest):
self
.
dynamic_shape
.
opt_input_shape
=
{}
self
.
dynamic_shape
.
opt_input_shape
=
{}
def
generate_trt_nodes_num
(
attrs
,
dynamic_shape
):
def
generate_trt_nodes_num
(
attrs
,
dynamic_shape
):
return
1
,
3
if
dynamic_shape
:
return
1
,
3
else
:
return
0
,
4
attrs
=
[
attrs
=
[
program_config
.
ops
[
i
].
attrs
program_config
.
ops
[
i
].
attrs
...
...
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_batch_norm.py
浏览文件 @
0951bfd1
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
from
trt_layer_auto_scan_test
import
TrtLayerAutoScanTest
,
SkipReasons
from
trt_layer_auto_scan_test
import
TrtLayerAutoScanTest
,
SkipReasons
from
program_config
import
TensorConfig
,
ProgramConfig
from
program_config
import
TensorConfig
,
ProgramConfig
import
unittest
import
numpy
as
np
import
numpy
as
np
import
paddle.inference
as
paddle_infer
import
paddle.inference
as
paddle_infer
from
functools
import
partial
from
functools
import
partial
...
@@ -211,6 +212,18 @@ class TrtConvertBatchNormTest(TrtLayerAutoScanTest):
...
@@ -211,6 +212,18 @@ class TrtConvertBatchNormTest(TrtLayerAutoScanTest):
self
.
add_skip_case
(
teller1
,
SkipReasons
.
TRT_NOT_SUPPORT
,
self
.
add_skip_case
(
teller1
,
SkipReasons
.
TRT_NOT_SUPPORT
,
"INPUT MomentumTensor NOT SUPPORT"
)
"INPUT MomentumTensor NOT SUPPORT"
)
def
teller2
(
program_config
,
predictor_config
):
if
len
(
program_config
.
inputs
[
'batch_norm_input'
].
shape
)
==
2
and
not
predictor_config
.
tensorrt_dynamic_shape_enabled
():
return
True
return
False
self
.
add_skip_case
(
teller2
,
SkipReasons
.
TRT_NOT_IMPLEMENTED
,
"The output shape has diff, but we can add shuffle layer to resolve it."
)
def
test
(
self
):
def
test
(
self
):
self
.
add_skip_trt_case
()
self
.
add_skip_trt_case
()
self
.
run_test
()
self
.
run_test
()
...
...
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_clip.py
浏览文件 @
0951bfd1
...
@@ -18,6 +18,7 @@ import numpy as np
...
@@ -18,6 +18,7 @@ import numpy as np
import
paddle.inference
as
paddle_infer
import
paddle.inference
as
paddle_infer
from
functools
import
partial
from
functools
import
partial
from
typing
import
Optional
,
List
,
Callable
,
Dict
,
Any
,
Set
from
typing
import
Optional
,
List
,
Callable
,
Dict
,
Any
,
Set
import
unittest
class
TrtConvertClipTest
(
TrtLayerAutoScanTest
):
class
TrtConvertClipTest
(
TrtLayerAutoScanTest
):
...
@@ -84,8 +85,7 @@ class TrtConvertClipTest(TrtLayerAutoScanTest):
...
@@ -84,8 +85,7 @@ class TrtConvertClipTest(TrtLayerAutoScanTest):
yield
program_config
yield
program_config
def
sample_predictor_configs
(
def
sample_predictor_configs
(
self
,
program_config
):
self
,
program_config
)
->
(
paddle_infer
.
Config
,
List
[
int
],
float
):
def
generate_dynamic_shape
(
attrs
):
def
generate_dynamic_shape
(
attrs
):
if
self
.
dims
==
1
:
if
self
.
dims
==
1
:
self
.
dynamic_shape
.
min_input_shape
=
{
"input_data"
:
[
1
]}
self
.
dynamic_shape
.
min_input_shape
=
{
"input_data"
:
[
1
]}
...
@@ -146,7 +146,21 @@ class TrtConvertClipTest(TrtLayerAutoScanTest):
...
@@ -146,7 +146,21 @@ class TrtConvertClipTest(TrtLayerAutoScanTest):
yield
self
.
create_inference_config
(),
generate_trt_nodes_num
(
attrs
,
yield
self
.
create_inference_config
(),
generate_trt_nodes_num
(
attrs
,
True
),
1e-5
True
),
1e-5
def
add_skip_trt_case
(
self
):
def
teller1
(
program_config
,
predictor_config
):
if
len
(
program_config
.
inputs
[
'input_data'
].
shape
)
==
2
and
not
predictor_config
.
tensorrt_dynamic_shape_enabled
():
return
True
return
False
self
.
add_skip_case
(
teller1
,
SkipReasons
.
TRT_NOT_IMPLEMENTED
,
"The output shape has diff, but we can add shuffle layer to resolve it."
)
def
test
(
self
):
def
test
(
self
):
self
.
add_skip_trt_case
()
self
.
run_test
()
self
.
run_test
()
...
...
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_concat.py
浏览文件 @
0951bfd1
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
from
trt_layer_auto_scan_test
import
TrtLayerAutoScanTest
,
SkipReasons
from
trt_layer_auto_scan_test
import
TrtLayerAutoScanTest
,
SkipReasons
from
program_config
import
TensorConfig
,
ProgramConfig
from
program_config
import
TensorConfig
,
ProgramConfig
import
unittest
import
numpy
as
np
import
numpy
as
np
import
paddle.inference
as
paddle_infer
import
paddle.inference
as
paddle_infer
from
functools
import
partial
from
functools
import
partial
...
@@ -317,6 +318,18 @@ class TrtConvertConcatTest(TrtLayerAutoScanTest):
...
@@ -317,6 +318,18 @@ class TrtConvertConcatTest(TrtLayerAutoScanTest):
self
.
add_skip_case
(
teller1
,
SkipReasons
.
TRT_NOT_SUPPORT
,
self
.
add_skip_case
(
teller1
,
SkipReasons
.
TRT_NOT_SUPPORT
,
"INPUT AxisTensor NOT SUPPORT"
)
"INPUT AxisTensor NOT SUPPORT"
)
def
teller2
(
program_config
,
predictor_config
):
if
len
(
program_config
.
inputs
[
'concat_input1'
].
shape
)
==
2
and
not
predictor_config
.
tensorrt_dynamic_shape_enabled
():
return
True
return
False
self
.
add_skip_case
(
teller2
,
SkipReasons
.
TRT_NOT_IMPLEMENTED
,
"The output shape has diff, but we can add shuffle layer to resolve it."
)
def
test
(
self
):
def
test
(
self
):
self
.
add_skip_trt_case
()
self
.
add_skip_trt_case
()
self
.
run_test
()
self
.
run_test
()
...
...
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_dropout.py
浏览文件 @
0951bfd1
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
from
trt_layer_auto_scan_test
import
TrtLayerAutoScanTest
,
SkipReasons
from
trt_layer_auto_scan_test
import
TrtLayerAutoScanTest
,
SkipReasons
from
program_config
import
TensorConfig
,
ProgramConfig
from
program_config
import
TensorConfig
,
ProgramConfig
import
unittest
import
numpy
as
np
import
numpy
as
np
import
paddle.inference
as
paddle_infer
import
paddle.inference
as
paddle_infer
from
functools
import
partial
from
functools
import
partial
...
@@ -141,15 +142,19 @@ class TrtConvertDropoutTest(TrtLayerAutoScanTest):
...
@@ -141,15 +142,19 @@ class TrtConvertDropoutTest(TrtLayerAutoScanTest):
def
add_skip_trt_case
(
self
):
def
add_skip_trt_case
(
self
):
def
teller1
(
program_config
,
predictor_config
):
def
teller1
(
program_config
,
predictor_config
):
if
self
.
dims
==
2
:
if
len
(
program_config
.
inputs
[
'input_data'
].
shape
)
==
2
and
not
predictor_config
.
tensorrt_dynamic_shape_enabled
():
return
True
return
True
return
False
return
False
self
.
add_skip_case
(
self
.
add_skip_case
(
teller1
,
SkipReasons
.
TRT_NOT_IMPLEMENTED
,
teller1
,
SkipReasons
.
TRT_NOT_IMPLEMENTED
,
"When input dims is 2, pulgin will product a 4 dims output."
)
"The output shape has diff, but we can add shuffle layer to resolve it."
)
def
test
(
self
):
def
test
(
self
):
self
.
add_skip_trt_case
()
self
.
run_test
()
self
.
run_test
()
...
...
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_hard_sigmoid.py
浏览文件 @
0951bfd1
...
@@ -18,6 +18,7 @@ import numpy as np
...
@@ -18,6 +18,7 @@ import numpy as np
import
paddle.inference
as
paddle_infer
import
paddle.inference
as
paddle_infer
from
functools
import
partial
from
functools
import
partial
from
typing
import
Optional
,
List
,
Callable
,
Dict
,
Any
,
Set
from
typing
import
Optional
,
List
,
Callable
,
Dict
,
Any
,
Set
import
unittest
class
TrtConvertHardSigmoidTest_dim_2
(
TrtLayerAutoScanTest
):
class
TrtConvertHardSigmoidTest_dim_2
(
TrtLayerAutoScanTest
):
...
...
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_reduce_sum.py
浏览文件 @
0951bfd1
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
from
trt_layer_auto_scan_test
import
TrtLayerAutoScanTest
,
SkipReasons
from
trt_layer_auto_scan_test
import
TrtLayerAutoScanTest
,
SkipReasons
from
program_config
import
TensorConfig
,
ProgramConfig
from
program_config
import
TensorConfig
,
ProgramConfig
import
unittest
import
numpy
as
np
import
numpy
as
np
import
paddle.inference
as
paddle_infer
import
paddle.inference
as
paddle_infer
from
functools
import
partial
from
functools
import
partial
...
@@ -84,8 +85,7 @@ class TrtConvertReduceSumTest(TrtLayerAutoScanTest):
...
@@ -84,8 +85,7 @@ class TrtConvertReduceSumTest(TrtLayerAutoScanTest):
yield
program_config
yield
program_config
def
sample_predictor_configs
(
def
sample_predictor_configs
(
self
,
program_config
):
self
,
program_config
)
->
(
paddle_infer
.
Config
,
List
[
int
],
float
):
def
generate_dynamic_shape
(
attrs
):
def
generate_dynamic_shape
(
attrs
):
self
.
dynamic_shape
.
min_input_shape
=
{
"input_data"
:
[
1
,
3
,
32
,
32
]}
self
.
dynamic_shape
.
min_input_shape
=
{
"input_data"
:
[
1
,
3
,
32
,
32
]}
self
.
dynamic_shape
.
max_input_shape
=
{
"input_data"
:
[
4
,
3
,
64
,
64
]}
self
.
dynamic_shape
.
max_input_shape
=
{
"input_data"
:
[
4
,
3
,
64
,
64
]}
...
@@ -117,7 +117,7 @@ class TrtConvertReduceSumTest(TrtLayerAutoScanTest):
...
@@ -117,7 +117,7 @@ class TrtConvertReduceSumTest(TrtLayerAutoScanTest):
clear_dynamic_shape
()
clear_dynamic_shape
()
self
.
trt_param
.
precision
=
paddle_infer
.
PrecisionType
.
Float32
self
.
trt_param
.
precision
=
paddle_infer
.
PrecisionType
.
Float32
yield
self
.
create_inference_config
(),
generate_trt_nodes_num
(
yield
self
.
create_inference_config
(),
generate_trt_nodes_num
(
attrs
,
False
),
1e-5
attrs
,
False
),
(
1e-5
,
1e-5
)
self
.
trt_param
.
precision
=
paddle_infer
.
PrecisionType
.
Half
self
.
trt_param
.
precision
=
paddle_infer
.
PrecisionType
.
Half
yield
self
.
create_inference_config
(),
generate_trt_nodes_num
(
yield
self
.
create_inference_config
(),
generate_trt_nodes_num
(
attrs
,
False
),
(
1e-5
,
1e-5
)
attrs
,
False
),
(
1e-5
,
1e-5
)
...
@@ -125,8 +125,8 @@ class TrtConvertReduceSumTest(TrtLayerAutoScanTest):
...
@@ -125,8 +125,8 @@ class TrtConvertReduceSumTest(TrtLayerAutoScanTest):
# for dynamic_shape
# for dynamic_shape
generate_dynamic_shape
(
attrs
)
generate_dynamic_shape
(
attrs
)
self
.
trt_param
.
precision
=
paddle_infer
.
PrecisionType
.
Float32
self
.
trt_param
.
precision
=
paddle_infer
.
PrecisionType
.
Float32
yield
self
.
create_inference_config
(),
generate_trt_nodes_num
(
attrs
,
yield
self
.
create_inference_config
(),
generate_trt_nodes_num
(
True
),
1e-5
attrs
,
True
),
(
1e-5
,
1e-5
)
self
.
trt_param
.
precision
=
paddle_infer
.
PrecisionType
.
Half
self
.
trt_param
.
precision
=
paddle_infer
.
PrecisionType
.
Half
yield
self
.
create_inference_config
(),
generate_trt_nodes_num
(
yield
self
.
create_inference_config
(),
generate_trt_nodes_num
(
attrs
,
True
),
(
1e-5
,
1e-5
)
attrs
,
True
),
(
1e-5
,
1e-5
)
...
...
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_roi_align.py
浏览文件 @
0951bfd1
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
from
trt_layer_auto_scan_test
import
TrtLayerAutoScanTest
,
SkipReasons
from
trt_layer_auto_scan_test
import
TrtLayerAutoScanTest
,
SkipReasons
from
program_config
import
TensorConfig
,
ProgramConfig
from
program_config
import
TensorConfig
,
ProgramConfig
import
unittest
import
numpy
as
np
import
numpy
as
np
import
paddle.inference
as
paddle_infer
import
paddle.inference
as
paddle_infer
from
functools
import
partial
from
functools
import
partial
...
@@ -141,6 +142,7 @@ class TrtConvertRoiAlignTest(TrtLayerAutoScanTest):
...
@@ -141,6 +142,7 @@ class TrtConvertRoiAlignTest(TrtLayerAutoScanTest):
return
1
,
3
return
1
,
3
else
:
else
:
return
0
,
4
return
0
,
4
return
0
,
4
attrs
=
[
attrs
=
[
program_config
.
ops
[
i
].
attrs
program_config
.
ops
[
i
].
attrs
...
...
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_skip_layernorm.py
浏览文件 @
0951bfd1
...
@@ -18,6 +18,7 @@ import numpy as np
...
@@ -18,6 +18,7 @@ import numpy as np
import
paddle.inference
as
paddle_infer
import
paddle.inference
as
paddle_infer
from
functools
import
partial
from
functools
import
partial
from
typing
import
Optional
,
List
,
Callable
,
Dict
,
Any
,
Set
from
typing
import
Optional
,
List
,
Callable
,
Dict
,
Any
,
Set
import
unittest
class
TrtConvertSkipLayernormTest
(
TrtLayerAutoScanTest
):
class
TrtConvertSkipLayernormTest
(
TrtLayerAutoScanTest
):
...
...
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_slice.py
浏览文件 @
0951bfd1
...
@@ -143,7 +143,11 @@ class TrtConvertSliceTest(TrtLayerAutoScanTest):
...
@@ -143,7 +143,11 @@ class TrtConvertSliceTest(TrtLayerAutoScanTest):
True
),
1e-4
True
),
1e-4
def
test
(
self
):
def
test
(
self
):
self
.
run_test
()
# TODO(inference): fix.
# trt6 and trt7.1 has bug.
# trt7.2 deserialize has bug.
# self.run_test()
pass
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
...
...
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_softmax.py
浏览文件 @
0951bfd1
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
from
trt_layer_auto_scan_test
import
TrtLayerAutoScanTest
,
SkipReasons
from
trt_layer_auto_scan_test
import
TrtLayerAutoScanTest
,
SkipReasons
from
program_config
import
TensorConfig
,
ProgramConfig
from
program_config
import
TensorConfig
,
ProgramConfig
import
unittest
import
numpy
as
np
import
numpy
as
np
import
paddle.inference
as
paddle_infer
import
paddle.inference
as
paddle_infer
from
functools
import
partial
from
functools
import
partial
...
@@ -135,7 +136,17 @@ class TrtConvertSoftmaxTest(TrtLayerAutoScanTest):
...
@@ -135,7 +136,17 @@ class TrtConvertSoftmaxTest(TrtLayerAutoScanTest):
True
),
1e-5
True
),
1e-5
def
add_skip_trt_case
(
self
):
def
add_skip_trt_case
(
self
):
pass
def
teller1
(
program_config
,
predictor_config
):
if
len
(
program_config
.
inputs
[
'softmax_input'
].
shape
)
==
2
and
not
predictor_config
.
tensorrt_dynamic_shape_enabled
():
return
True
return
False
self
.
add_skip_case
(
teller1
,
SkipReasons
.
TRT_NOT_IMPLEMENTED
,
"The output shape has diff, but we can add shuffle layer to resolve it."
)
def
test
(
self
):
def
test
(
self
):
self
.
add_skip_trt_case
()
self
.
add_skip_trt_case
()
...
...
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_split.py
浏览文件 @
0951bfd1
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
from
trt_layer_auto_scan_test
import
TrtLayerAutoScanTest
,
SkipReasons
from
trt_layer_auto_scan_test
import
TrtLayerAutoScanTest
,
SkipReasons
from
program_config
import
TensorConfig
,
ProgramConfig
from
program_config
import
TensorConfig
,
ProgramConfig
import
unittest
import
numpy
as
np
import
numpy
as
np
import
paddle.inference
as
paddle_infer
import
paddle.inference
as
paddle_infer
from
functools
import
partial
from
functools
import
partial
...
@@ -226,6 +227,18 @@ class TrtConvertSplitTest(TrtLayerAutoScanTest):
...
@@ -226,6 +227,18 @@ class TrtConvertSplitTest(TrtLayerAutoScanTest):
teller1
,
SkipReasons
.
TRT_NOT_SUPPORT
,
teller1
,
SkipReasons
.
TRT_NOT_SUPPORT
,
"INPUT AxisTensor AND SectionsTensorList NOT SUPPORT."
)
"INPUT AxisTensor AND SectionsTensorList NOT SUPPORT."
)
def
teller2
(
program_config
,
predictor_config
):
if
len
(
program_config
.
inputs
[
'split_input'
].
shape
)
==
2
and
not
predictor_config
.
tensorrt_dynamic_shape_enabled
():
return
True
return
False
self
.
add_skip_case
(
teller2
,
SkipReasons
.
TRT_NOT_IMPLEMENTED
,
"The output shape has diff, but we can add shuffle layer to resolve it."
)
def
test
(
self
):
def
test
(
self
):
self
.
add_skip_trt_case
()
self
.
add_skip_trt_case
()
self
.
run_test
()
self
.
run_test
()
...
...
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_stack.py
浏览文件 @
0951bfd1
...
@@ -18,6 +18,7 @@ import numpy as np
...
@@ -18,6 +18,7 @@ import numpy as np
import
paddle.inference
as
paddle_infer
import
paddle.inference
as
paddle_infer
from
functools
import
partial
from
functools
import
partial
from
typing
import
Optional
,
List
,
Callable
,
Dict
,
Any
,
Set
from
typing
import
Optional
,
List
,
Callable
,
Dict
,
Any
,
Set
import
unittest
class
TrtConvertStackTest
(
TrtLayerAutoScanTest
):
class
TrtConvertStackTest
(
TrtLayerAutoScanTest
):
...
...
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_tile.py
浏览文件 @
0951bfd1
...
@@ -77,10 +77,14 @@ class TrtConvertTileTest(TrtLayerAutoScanTest):
...
@@ -77,10 +77,14 @@ class TrtConvertTileTest(TrtLayerAutoScanTest):
self
.
dynamic_shape
.
opt_input_shape
=
{}
self
.
dynamic_shape
.
opt_input_shape
=
{}
def
generate_trt_nodes_num
(
attrs
,
dynamic_shape
):
def
generate_trt_nodes_num
(
attrs
,
dynamic_shape
):
if
dynamic_shape
==
True
:
ver
=
paddle_infer
.
get_trt_compile_version
()
return
0
,
3
if
ver
[
0
]
*
1000
+
ver
[
1
]
*
100
+
ver
[
0
]
*
10
>=
7000
:
if
dynamic_shape
==
True
:
return
0
,
3
else
:
return
1
,
2
else
:
else
:
return
1
,
2
return
0
,
3
attrs
=
[
attrs
=
[
program_config
.
ops
[
i
].
attrs
program_config
.
ops
[
i
].
attrs
...
...
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_yolo_box.py
浏览文件 @
0951bfd1
...
@@ -18,6 +18,7 @@ import numpy as np
...
@@ -18,6 +18,7 @@ import numpy as np
import
paddle.inference
as
paddle_infer
import
paddle.inference
as
paddle_infer
from
functools
import
partial
from
functools
import
partial
from
typing
import
Optional
,
List
,
Callable
,
Dict
,
Any
,
Set
from
typing
import
Optional
,
List
,
Callable
,
Dict
,
Any
,
Set
import
unittest
class
TrtConvertYoloBoxTest
(
TrtLayerAutoScanTest
):
class
TrtConvertYoloBoxTest
(
TrtLayerAutoScanTest
):
...
...
python/paddle/fluid/tests/unittests/ir/inference/trt_layer_auto_scan_test.py
浏览文件 @
0951bfd1
...
@@ -81,7 +81,7 @@ class TrtLayerAutoScanTest(AutoScanTest):
...
@@ -81,7 +81,7 @@ class TrtLayerAutoScanTest(AutoScanTest):
def
create_inference_config
(
self
,
use_trt
=
True
)
->
paddle_infer
.
Config
:
def
create_inference_config
(
self
,
use_trt
=
True
)
->
paddle_infer
.
Config
:
config
=
paddle_infer
.
Config
()
config
=
paddle_infer
.
Config
()
#
config.disable_glog_info()
config
.
disable_glog_info
()
config
.
enable_use_gpu
(
100
,
0
)
config
.
enable_use_gpu
(
100
,
0
)
config
.
set_optim_cache_dir
(
self
.
trt_cache_dir
)
config
.
set_optim_cache_dir
(
self
.
trt_cache_dir
)
if
use_trt
:
if
use_trt
:
...
@@ -276,11 +276,11 @@ class TrtLayerAutoScanTest(AutoScanTest):
...
@@ -276,11 +276,11 @@ class TrtLayerAutoScanTest(AutoScanTest):
str
(
prog_config
)
+
' vs '
+
self
.
inference_config_str
(
str
(
prog_config
)
+
' vs '
+
self
.
inference_config_str
(
pred_config
)
+
pred_config
)
+
'
\033
[1;31m
\n
ERROR INFO: {}
\033
[0m'
.
format
(
str
(
e
)))
'
\033
[1;31m
\n
ERROR INFO: {}
\033
[0m'
.
format
(
str
(
e
)))
status
=
False
if
not
skip_flag
:
status
=
False
continue
continue
self
.
success_log
(
'RUN '
+
str
(
prog_config
)
+
' vs '
+
self
.
success_log
(
'RUN '
+
str
(
prog_config
)
+
' vs '
+
self
.
inference_config_str
(
pred_config
))
self
.
inference_config_str
(
pred_config
))
# In the first step, we found the problem, and after the subsequent repairs, the assert assertion will be enabled
# self.assertTrue(status)
# self.assertTrue(status)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录