Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
32dae48a
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看板
未验证
提交
32dae48a
编写于
5月 11, 2023
作者:
Z
zhoutianzi666
提交者:
GitHub
5月 11, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add unitest for reshpe 0 dims (#53685)
上级
4a97ba5d
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
94 addition
and
0 deletion
+94
-0
test/ir/inference/test_trt_convert_reshape.py
test/ir/inference/test_trt_convert_reshape.py
+94
-0
未找到文件。
test/ir/inference/test_trt_convert_reshape.py
浏览文件 @
32dae48a
...
...
@@ -431,5 +431,99 @@ class TrtConvertReshapeTest3(TrtLayerAutoScanTest):
self
.
run_test
()
class
TrtConvertReshapeZeroDimsTest
(
TrtLayerAutoScanTest
):
def
is_program_valid
(
self
,
program_config
:
ProgramConfig
)
->
bool
:
return
True
def
sample_program_configs
(
self
):
def
generate_input1
(
attrs
:
List
[
Dict
[
str
,
Any
]]):
if
self
.
dims
>
0
:
self
.
input_shape
=
[
1
]
*
self
.
dims
return
np
.
random
.
random
(
self
.
input_shape
).
astype
(
np
.
float32
)
elif
self
.
dims
==
0
:
self
.
input_shape
=
[]
return
np
.
random
.
random
([]).
astype
(
np
.
float32
)
for
dims
in
[
0
,
1
,
2
,
3
]:
for
shape
in
[
[],
[
1
,
1
],
]:
dics
=
[
{
"shape"
:
shape
,
},
]
self
.
dims
=
dims
dics_intput
=
[{
"X"
:
[
"reshape_input"
]}]
ops_config
=
[
{
"op_type"
:
"reshape"
,
"op_inputs"
:
dics_intput
[
0
],
"op_outputs"
:
{
"Out"
:
[
"reshape_out"
]},
"op_attrs"
:
dics
[
0
],
}
]
ops
=
self
.
generate_op_config
(
ops_config
)
program_config
=
ProgramConfig
(
ops
=
ops
,
weights
=
{},
inputs
=
{
"reshape_input"
:
TensorConfig
(
data_gen
=
partial
(
generate_input1
,
dics
)
)
},
outputs
=
[
"reshape_out"
],
)
yield
program_config
def
sample_predictor_configs
(
self
,
program_config
)
->
(
paddle_infer
.
Config
,
List
[
int
],
float
):
def
generate_dynamic_shape
(
attrs
):
self
.
dynamic_shape
.
min_input_shape
=
{
"reshape_input"
:
self
.
input_shape
}
self
.
dynamic_shape
.
max_input_shape
=
{
"reshape_input"
:
self
.
input_shape
}
self
.
dynamic_shape
.
opt_input_shape
=
{
"reshape_input"
:
self
.
input_shape
}
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
):
# only test dynamic shape mode
return
1
,
2
attrs
=
[
program_config
.
ops
[
i
].
attrs
for
i
in
range
(
len
(
program_config
.
ops
))
]
# 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-3
def
add_skip_trt_case
(
self
):
pass
def
test
(
self
):
self
.
add_skip_trt_case
()
self
.
run_test
()
if
__name__
==
"__main__"
:
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录