Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleSlim
提交
410d90ef
P
PaddleSlim
项目概览
PaddlePaddle
/
PaddleSlim
1 年多 前同步成功
通知
51
Star
1434
Fork
344
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
53
列表
看板
标记
里程碑
合并请求
16
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleSlim
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
53
Issue
53
列表
看板
标记
里程碑
合并请求
16
合并请求
16
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
410d90ef
编写于
5月 17, 2022
作者:
Z
zhouzj
提交者:
GitHub
5月 17, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[latency predictor] Solve the bug of downloading predictors' files (#1107)
上级
157dcb21
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
18 addition
and
7 deletion
+18
-7
paddleslim/analysis/_utils.py
paddleslim/analysis/_utils.py
+9
-3
paddleslim/analysis/latency_predictor.py
paddleslim/analysis/latency_predictor.py
+9
-4
未找到文件。
paddleslim/analysis/_utils.py
浏览文件 @
410d90ef
...
...
@@ -19,11 +19,15 @@ import paddle
import
paddleslim
import
subprocess
import
time
import
urllib.request
as
request
import
ssl
__all__
=
[
"save_cls_model"
,
"save_det_model"
,
"nearest_interpolate"
,
"opt_model"
,
"load_predictor"
]
PREDICTOR_URL
=
'https://paddlemodels.bj.bcebos.com/PaddleSlim/analysis/'
def
opt_model
(
opt
=
"paddle_lite_opt"
,
model_file
=
''
,
...
...
@@ -200,9 +204,11 @@ def download_predictor(op_dir, op):
op_path
=
os
.
path
.
join
(
op_dir
,
op
+
'_predictor.pkl'
)
if
not
os
.
path
.
exists
(
op_path
):
subprocess
.
call
(
f
'wget -P
{
op_dir
}
https://paddlemodels.bj.bcebos.com/PaddleSlim/analysis/
{
op_path
}
'
,
shell
=
True
)
# NOTE: To solve the 'SSL: certificate verify failed' error.
ssl
.
_create_default_https_context
=
ssl
.
_create_unverified_context
url
=
PREDICTOR_URL
+
op_path
request
.
urlretrieve
(
url
,
op_path
)
print
(
'Successfully download {}!'
.
format
(
op_path
))
return
op_path
...
...
paddleslim/analysis/latency_predictor.py
浏览文件 @
410d90ef
...
...
@@ -24,8 +24,12 @@ from ._utils import opt_model, load_predictor, nearest_interpolate
import
paddle
import
paddleslim
import
warnings
import
urllib.request
as
request
import
ssl
__all__
=
[
"LatencyPredictor"
,
"TableLatencyPredictor"
]
TABLE_URL
=
'https://paddlemodels.bj.bcebos.com/PaddleSlim/analysis/'
def
format_Warning
(
message
,
category
,
filename
,
lineno
,
line
=
''
):
return
str
(
filename
)
+
':'
+
str
(
...
...
@@ -86,10 +90,11 @@ class TableLatencyPredictor(LatencyPredictor):
self
.
table_file
=
f
'
{
self
.
hardware
}
_threads_4_power_mode_0.pkl'
self
.
predictor_state
=
True
if
not
os
.
path
.
exists
(
self
.
table_file
):
subprocess
.
call
(
f
'wget https://paddlemodels.bj.bcebos.com/PaddleSlim/analysis/
{
self
.
table_file
}
'
,
shell
=
True
)
# NOTE: To solve the 'SSL: certificate verify failed' error.
ssl
.
_create_default_https_context
=
ssl
.
_create_unverified_context
url
=
TABLE_URL
+
self
.
table_file
request
.
urlretrieve
(
url
,
self
.
table_file
)
print
(
'Successfully download {}!'
.
format
(
self
.
table_file
))
assert
os
.
path
.
exists
(
self
.
table_file
),
f
'
{
self
.
table_file
}
does not exist. If you want to use our table files, please set
\'
table_file
\'
in
{
TableLatencyPredictor
.
hardware_list
}
'
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录