Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
ba71421c
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看板
未验证
提交
ba71421c
编写于
9月 18, 2021
作者:
W
Wilber
提交者:
GitHub
9月 18, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
trt support serialize and deserialize (#35828)
上级
2fff5a58
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
13 addition
and
6 deletion
+13
-6
python/paddle/fluid/tests/unittests/ir/inference/trt_layer_auto_scan_test.py
.../tests/unittests/ir/inference/trt_layer_auto_scan_test.py
+13
-6
未找到文件。
python/paddle/fluid/tests/unittests/ir/inference/trt_layer_auto_scan_test.py
浏览文件 @
ba71421c
...
@@ -25,6 +25,7 @@ import paddle
...
@@ -25,6 +25,7 @@ import paddle
import
paddle.fluid
as
fluid
import
paddle.fluid
as
fluid
import
paddle.fluid.core
as
core
import
paddle.fluid.core
as
core
import
paddle.inference
as
paddle_infer
import
paddle.inference
as
paddle_infer
import
shutil
from
paddle
import
compat
as
cpt
from
paddle
import
compat
as
cpt
from
typing
import
Optional
,
List
,
Callable
,
Dict
,
Any
,
Set
from
typing
import
Optional
,
List
,
Callable
,
Dict
,
Any
,
Set
...
@@ -68,18 +69,21 @@ class TrtLayerAutoScanTest(AutoScanTest):
...
@@ -68,18 +69,21 @@ class TrtLayerAutoScanTest(AutoScanTest):
max_batch_size
=
4
,
max_batch_size
=
4
,
min_subgraph_size
=
0
,
min_subgraph_size
=
0
,
precision
=
paddle_infer
.
PrecisionType
.
Float32
,
precision
=
paddle_infer
.
PrecisionType
.
Float32
,
use_static
=
Fals
e
,
use_static
=
Tru
e
,
use_calib_mode
=
False
)
use_calib_mode
=
False
)
self
.
dynamic_shape
=
self
.
DynamicShapeParam
({},
{},
{},
False
)
self
.
dynamic_shape
=
self
.
DynamicShapeParam
({},
{},
{},
False
)
self
.
num_percent_cases
=
float
(
self
.
num_percent_cases
=
float
(
os
.
getenv
(
os
.
getenv
(
'TEST_NUM_PERCENT_CASES'
,
default
=
'1.0'
))
'TEST_NUM_PERCENT_CASES'
,
default
=
'1.0'
))
abs_dir
=
os
.
path
.
abspath
(
os
.
path
.
dirname
(
__file__
))
cache_dir
=
str
(
self
.
__module__
)
+
'_trt_cache_dir'
self
.
trt_cache_dir
=
os
.
path
.
join
(
abs_dir
,
cache_dir
)
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
(
'trt_convert_cache_dir'
)
config
.
set_optim_cache_dir
(
self
.
trt_cache_dir
)
if
use_trt
:
if
use_trt
:
config
.
switch_ir_debug
()
config
.
switch_ir_debug
()
config
.
enable_tensorrt_engine
(
config
.
enable_tensorrt_engine
(
...
@@ -218,6 +222,9 @@ class TrtLayerAutoScanTest(AutoScanTest):
...
@@ -218,6 +222,9 @@ class TrtLayerAutoScanTest(AutoScanTest):
for
pred_config
,
nodes_num
,
threshold
in
self
.
sample_predictor_configs
(
for
pred_config
,
nodes_num
,
threshold
in
self
.
sample_predictor_configs
(
prog_config
):
prog_config
):
if
os
.
path
.
exists
(
self
.
trt_cache_dir
):
shutil
.
rmtree
(
self
.
trt_cache_dir
)
if
isinstance
(
threshold
,
float
):
if
isinstance
(
threshold
,
float
):
atol
=
threshold
atol
=
threshold
rtol
=
1e-8
rtol
=
1e-8
...
@@ -261,9 +268,9 @@ class TrtLayerAutoScanTest(AutoScanTest):
...
@@ -261,9 +268,9 @@ class TrtLayerAutoScanTest(AutoScanTest):
if
not
skip_flag
:
if
not
skip_flag
:
self
.
assert_op_size
(
nodes_num
[
0
],
nodes_num
[
1
])
self
.
assert_op_size
(
nodes_num
[
0
],
nodes_num
[
1
])
# deserialize test
# deserialize test
#
if nodes_num[0] > 0:
if
nodes_num
[
0
]
>
0
:
#
self.run_test_config(model, params, prog_config,
self
.
run_test_config
(
model
,
params
,
prog_config
,
#
pred_config_deserialize, feed_data)
pred_config_deserialize
,
feed_data
)
except
Exception
as
e
:
except
Exception
as
e
:
self
.
fail_log
(
self
.
fail_log
(
str
(
prog_config
)
+
' vs '
+
self
.
inference_config_str
(
str
(
prog_config
)
+
' vs '
+
self
.
inference_config_str
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录