Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
292b7254
P
Paddle
项目概览
Crayon鑫
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
292b7254
编写于
6月 22, 2022
作者:
C
ccrrong
提交者:
GitHub
6月 22, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add arg max trt converter support dynamic shape mode (#43473)
* fix arg_max converter
上级
e176cc40
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
56 addition
and
4 deletion
+56
-4
paddle/fluid/inference/tensorrt/convert/arg_max_op.cc
paddle/fluid/inference/tensorrt/convert/arg_max_op.cc
+3
-1
paddle/fluid/inference/tensorrt/op_teller.cc
paddle/fluid/inference/tensorrt/op_teller.cc
+0
-1
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_arg_max.py
.../tests/unittests/ir/inference/test_trt_convert_arg_max.py
+53
-2
未找到文件。
paddle/fluid/inference/tensorrt/convert/arg_max_op.cc
浏览文件 @
292b7254
...
...
@@ -40,7 +40,9 @@ class ArgMaxOpConverter : public OpConverter {
int
axis
=
op_desc
.
HasAttr
(
"axis"
)
?
BOOST_GET_CONST
(
int64_t
,
op_desc
.
GetAttr
(
"axis"
))
:
-
1
;
if
(
axis
>
0
)
axis
-=
1
;
if
(
axis
>
0
&&
!
engine_
->
with_dynamic_shape
())
{
axis
-=
1
;
}
if
(
axis
<
0
)
axis
+=
rank
;
auto
*
topk_layer
=
TRT_ENGINE_ADD_LAYER
(
engine_
,
TopK
,
*
input
,
nvinfer1
::
TopKOperation
::
kMAX
,
1
,
1
<<
axis
);
...
...
paddle/fluid/inference/tensorrt/op_teller.cc
浏览文件 @
292b7254
...
...
@@ -738,7 +738,6 @@ bool OpTeller::Tell(const framework::ir::Node* node, bool use_no_calib_int8,
}
if
(
op_type
==
"arg_max"
)
{
if
(
with_dynamic_shape
)
return
false
;
int
axis
=
desc
.
HasAttr
(
"axis"
)
?
BOOST_GET_CONST
(
int64_t
,
desc
.
GetAttr
(
"axis"
))
:
-
1
;
...
...
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_arg_max.py
浏览文件 @
292b7254
...
...
@@ -45,6 +45,7 @@ class TrtConvertArgMaxTest(TrtLayerAutoScanTest):
for
batch
in
[
1
,
4
]:
for
axis
in
[
-
1
,
0
,
1
,
2
,
3
]:
for
keepdims
in
[
True
,
False
]:
self
.
rank
=
rank
flatten
=
False
dtype
=
2
ops_config
=
[{
...
...
@@ -76,9 +77,59 @@ class TrtConvertArgMaxTest(TrtLayerAutoScanTest):
def
sample_predictor_configs
(
self
,
program_config
)
->
(
paddle_infer
.
Config
,
List
[
int
],
float
):
self
.
trt_param
.
precision
=
paddle_infer
.
PrecisionType
.
Float32
def
generate_dynamic_shape
(
attrs
):
if
self
.
rank
==
3
:
self
.
dynamic_shape
.
min_input_shape
=
{
"arg_max_input"
:
[
1
,
8
,
16
]
}
self
.
dynamic_shape
.
max_input_shape
=
{
"arg_max_input"
:
[
4
,
8
,
16
]
}
self
.
dynamic_shape
.
opt_input_shape
=
{
"arg_max_input"
:
[
3
,
8
,
16
]
}
else
:
self
.
dynamic_shape
.
min_input_shape
=
{
"arg_max_input"
:
[
1
,
8
,
16
,
24
]
}
self
.
dynamic_shape
.
max_input_shape
=
{
"arg_max_input"
:
[
4
,
8
,
16
,
24
]
}
self
.
dynamic_shape
.
opt_input_shape
=
{
"arg_max_input"
:
[
1
,
8
,
16
,
24
]
}
def
clear_dynamic_shape
():
self
.
dynamic_shape
.
min_input_shape
=
{}
self
.
dynamic_shape
.
max_input_shape
=
{}
self
.
dynamic_shape
.
opt_input_shape
=
{}
def
generate_trt_nodes_num
(
attrs
,
dynamic_shape
):
return
1
,
2
attrs
=
[
program_config
.
ops
[
i
].
attrs
for
i
in
range
(
len
(
program_config
.
ops
))
]
self
.
trt_param
.
workspace_size
=
1024000
yield
self
.
create_inference_config
(),
[
1
,
2
],
1e-5
# for static_shape
clear_dynamic_shape
()
self
.
trt_param
.
precision
=
paddle_infer
.
PrecisionType
.
Float32
yield
self
.
create_inference_config
(),
generate_trt_nodes_num
(
attrs
,
False
),
1e-5
self
.
trt_param
.
precision
=
paddle_infer
.
PrecisionType
.
Half
yield
self
.
create_inference_config
(),
generate_trt_nodes_num
(
attrs
,
False
),
1e-5
# for dynamic_shape
generate_dynamic_shape
(
attrs
)
self
.
trt_param
.
precision
=
paddle_infer
.
PrecisionType
.
Float32
yield
self
.
create_inference_config
(),
generate_trt_nodes_num
(
attrs
,
True
),
1e-5
self
.
trt_param
.
precision
=
paddle_infer
.
PrecisionType
.
Half
yield
self
.
create_inference_config
(),
generate_trt_nodes_num
(
attrs
,
True
),
1e-5
def
test
(
self
):
self
.
run_test
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录