Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
45b93325
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
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看板
未验证
提交
45b93325
编写于
10月 10, 2022
作者:
F
feng_shuai
提交者:
GitHub
10月 10, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:gather op (#46779)
* fix:gather op * add ut
上级
140f3b24
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
56 addition
and
39 deletion
+56
-39
paddle/fluid/inference/tensorrt/op_teller.cc
paddle/fluid/inference/tensorrt/op_teller.cc
+10
-0
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_gather.py
...d/tests/unittests/ir/inference/test_trt_convert_gather.py
+46
-39
未找到文件。
paddle/fluid/inference/tensorrt/op_teller.cc
浏览文件 @
45b93325
...
...
@@ -534,6 +534,16 @@ struct SimpleOpTypeSetTeller : public Teller {
"the pass."
;
return
false
;
}
auto
index_var_name
=
desc
.
Input
(
"Index"
)[
0
];
auto
*
index_var_desc
=
block
->
FindVar
(
index_var_name
);
// The index input must be int32 datatype.
if
(
index_var_desc
->
GetDataType
()
!=
paddle
::
framework
::
proto
::
VarType_Type
::
VarType_Type_INT32
)
{
VLOG
(
3
)
<<
"gather op Index input data type must be int32"
;
return
false
;
}
#if !IS_TRT_VERSION_GE(7000)
auto
*
x_var_desc
=
block
->
FindVar
(
desc
.
Input
(
"X"
)[
0
]);
const
auto
x_shape
=
x_var_desc
->
GetShape
();
...
...
python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_gather.py
浏览文件 @
45b93325
...
...
@@ -42,6 +42,9 @@ class TrtConvertGatherTest(TrtLayerAutoScanTest):
def
generate_input2
(
index
):
return
np
.
array
(
index
).
astype
(
np
.
int32
)
def
generate_input4
(
index
):
return
np
.
array
(
index
).
astype
(
np
.
int64
)
def
generate_input3
(
axis
):
return
np
.
array
([
axis
]).
astype
(
np
.
int32
)
...
...
@@ -57,44 +60,48 @@ class TrtConvertGatherTest(TrtLayerAutoScanTest):
"Index"
:
[
"index_data"
],
"Axis"
:
[
"axis_data"
]
}]:
self
.
shape
=
shape
self
.
axis
=
axis
self
.
input_num
=
len
(
input
)
dics
=
[{
"overwrite"
:
overwrite
,
"axis"
:
axis
}]
ops_config
=
[{
"op_type"
:
"gather"
,
"op_inputs"
:
input
,
"op_outputs"
:
{
"Out"
:
[
"output_data"
]
},
"op_attrs"
:
dics
[
0
]
}]
ops
=
self
.
generate_op_config
(
ops_config
)
program_config
=
ProgramConfig
(
ops
=
ops
,
weights
=
{},
inputs
=
{
"input_data"
:
TensorConfig
(
data_gen
=
partial
(
generate_input1
,
shape
)),
"index_data"
:
TensorConfig
(
data_gen
=
partial
(
generate_input2
,
index
)),
}
if
len
(
input
)
==
2
else
{
"input_data"
:
TensorConfig
(
data_gen
=
partial
(
generate_input1
,
shape
)),
"index_data"
:
TensorConfig
(
data_gen
=
partial
(
generate_input2
,
index
)),
"axis_data"
:
TensorConfig
(
data_gen
=
partial
(
generate_input3
,
axis
)),
},
outputs
=
[
"output_data"
])
yield
program_config
for
index_type_int32
in
[
True
,
False
]:
self
.
shape
=
shape
self
.
axis
=
axis
self
.
input_num
=
len
(
input
)
self
.
index_type_int32
=
index_type_int32
dics
=
[{
"overwrite"
:
overwrite
,
"axis"
:
axis
}]
ops_config
=
[{
"op_type"
:
"gather"
,
"op_inputs"
:
input
,
"op_outputs"
:
{
"Out"
:
[
"output_data"
]
},
"op_attrs"
:
dics
[
0
]
}]
ops
=
self
.
generate_op_config
(
ops_config
)
program_config
=
ProgramConfig
(
ops
=
ops
,
weights
=
{},
inputs
=
{
"input_data"
:
TensorConfig
(
data_gen
=
partial
(
generate_input1
,
shape
)),
"index_data"
:
TensorConfig
(
data_gen
=
partial
(
generate_input2
if
index_type_int32
==
True
else
generate_input4
,
index
)),
}
if
len
(
input
)
==
2
else
{
"input_data"
:
TensorConfig
(
data_gen
=
partial
(
generate_input1
,
shape
)),
"index_data"
:
TensorConfig
(
data_gen
=
partial
(
generate_input2
,
index
)),
"axis_data"
:
TensorConfig
(
data_gen
=
partial
(
generate_input3
,
axis
)),
},
outputs
=
[
"output_data"
])
yield
program_config
def
sample_predictor_configs
(
self
,
program_config
)
->
(
paddle_infer
.
Config
,
List
[
int
],
float
):
...
...
@@ -162,7 +169,7 @@ class TrtConvertGatherTest(TrtLayerAutoScanTest):
if
self
.
input_num
==
3
:
return
0
,
5
else
:
if
dynamic_shape
:
if
dynamic_shape
and
self
.
index_type_int32
==
True
:
return
1
,
3
else
:
return
0
,
4
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录