Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
aebff6d7
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
aebff6d7
编写于
5月 11, 2023
作者:
X
xiaoxiaohehe001
提交者:
GitHub
5月 11, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Paddle-Inference] Support trt 0dims of expand_as_v2 and mish. (#53627)
* support_expand_mish
上级
08b6f5d6
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
24 addition
and
4 deletion
+24
-4
paddle/fluid/inference/tensorrt/op_teller.cc
paddle/fluid/inference/tensorrt/op_teller.cc
+13
-2
test/ir/inference/test_trt_convert_expand_as_v2.py
test/ir/inference/test_trt_convert_expand_as_v2.py
+11
-2
未找到文件。
paddle/fluid/inference/tensorrt/op_teller.cc
浏览文件 @
aebff6d7
...
@@ -1890,8 +1890,10 @@ struct SimpleOpTypeSetTeller : public Teller {
...
@@ -1890,8 +1890,10 @@ struct SimpleOpTypeSetTeller : public Teller {
auto
x_var_name
=
desc
.
Input
(
"X"
)[
0
];
auto
x_var_name
=
desc
.
Input
(
"X"
)[
0
];
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
((
!
with_dynamic_shape
&&
x_shape
.
size
()
==
1
)
||
x_shape
.
size
()
==
0
)
{
VLOG
(
3
)
<<
"mish op does not support input's dim is 1 in tensorrt."
;
VLOG
(
3
)
<<
op_type
<<
"mish op does not support input's dim is 1 in tensorrt "
"static shape mode or 0."
;
return
false
;
return
false
;
}
}
}
}
...
@@ -2644,6 +2646,15 @@ struct SimpleOpTypeSetTeller : public Teller {
...
@@ -2644,6 +2646,15 @@ struct SimpleOpTypeSetTeller : public Teller {
"the pass."
;
"the pass."
;
return
false
;
return
false
;
}
}
#if IS_TRT_VERSION_LT(8000)
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
();
if
(
x_shape
.
size
()
==
0
)
{
return
false
;
// not supported 0 dim.
}
#endif
}
}
if
(
op_type
==
"grid_sampler"
)
{
if
(
op_type
==
"grid_sampler"
)
{
...
...
test/ir/inference/test_trt_convert_expand_as_v2.py
浏览文件 @
aebff6d7
...
@@ -49,8 +49,11 @@ class TrtConvertExpandASV2Test(TrtLayerAutoScanTest):
...
@@ -49,8 +49,11 @@ class TrtConvertExpandASV2Test(TrtLayerAutoScanTest):
elif
self
.
dims
==
1
:
elif
self
.
dims
==
1
:
self
.
input_shape
=
[
32
]
self
.
input_shape
=
[
32
]
return
np
.
random
.
random
([
32
]).
astype
(
np
.
float32
)
return
np
.
random
.
random
([
32
]).
astype
(
np
.
float32
)
elif
self
.
dims
==
0
:
self
.
input_shape
=
[]
return
np
.
random
.
random
([]).
astype
(
np
.
float32
)
for
dims
in
[
1
,
2
,
3
,
4
]:
for
dims
in
[
0
,
1
,
2
,
3
,
4
]:
for
shape
in
[
for
shape
in
[
[
10
,
8
,
32
,
32
],
[
10
,
8
,
32
,
32
],
[
2
,
8
,
32
,
32
],
[
2
,
8
,
32
,
32
],
...
@@ -125,6 +128,10 @@ class TrtConvertExpandASV2Test(TrtLayerAutoScanTest):
...
@@ -125,6 +128,10 @@ class TrtConvertExpandASV2Test(TrtLayerAutoScanTest):
self
.
dynamic_shape
.
min_input_shape
=
{
"expand_v2_input"
:
[
32
]}
self
.
dynamic_shape
.
min_input_shape
=
{
"expand_v2_input"
:
[
32
]}
self
.
dynamic_shape
.
max_input_shape
=
{
"expand_v2_input"
:
[
64
]}
self
.
dynamic_shape
.
max_input_shape
=
{
"expand_v2_input"
:
[
64
]}
self
.
dynamic_shape
.
opt_input_shape
=
{
"expand_v2_input"
:
[
32
]}
self
.
dynamic_shape
.
opt_input_shape
=
{
"expand_v2_input"
:
[
32
]}
elif
self
.
dims
==
0
:
self
.
dynamic_shape
.
min_input_shape
=
{
"expand_v2_input"
:
[]}
self
.
dynamic_shape
.
max_input_shape
=
{
"expand_v2_input"
:
[]}
self
.
dynamic_shape
.
opt_input_shape
=
{
"expand_v2_input"
:
[]}
def
clear_dynamic_shape
():
def
clear_dynamic_shape
():
self
.
dynamic_shape
.
min_input_shape
=
{}
self
.
dynamic_shape
.
min_input_shape
=
{}
...
@@ -132,7 +139,9 @@ class TrtConvertExpandASV2Test(TrtLayerAutoScanTest):
...
@@ -132,7 +139,9 @@ class TrtConvertExpandASV2Test(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
:
ver
=
paddle_infer
.
get_trt_compile_version
()
ver_num
=
ver
[
0
]
*
1000
+
ver
[
1
]
*
100
+
ver
[
2
]
*
10
if
dynamic_shape
and
(
ver_num
>
8000
or
self
.
dims
>
0
):
return
1
,
2
return
1
,
2
else
:
else
:
return
0
,
3
return
0
,
3
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录