Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
a61c31df
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
331
Star
4
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
271
列表
看板
标记
里程碑
合并请求
78
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle-Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
271
Issue
271
列表
看板
标记
里程碑
合并请求
78
合并请求
78
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a61c31df
编写于
8月 12, 2019
作者:
Z
zp7
提交者:
Yanzhan Yang
8月 12, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add encrypt feature to run.py (#1789)
上级
8d02789f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
26 addition
and
1 deletion
+26
-1
tools/python/fluidtools/.gitignore
tools/python/fluidtools/.gitignore
+1
-1
tools/python/fluidtools/model-encrypt-tool/enc_key_gen
tools/python/fluidtools/model-encrypt-tool/enc_key_gen
+0
-0
tools/python/fluidtools/model-encrypt-tool/enc_model_gen
tools/python/fluidtools/model-encrypt-tool/enc_model_gen
+0
-0
tools/python/fluidtools/run.py
tools/python/fluidtools/run.py
+25
-0
未找到文件。
tools/python/fluidtools/.gitignore
浏览文件 @
a61c31df
*
!run.py
!.gitignore
info.txt
!/model-encrypt-tool
tools/python/fluidtools/model-encrypt-tool/enc_key_gen
0 → 100755
浏览文件 @
a61c31df
文件已添加
tools/python/fluidtools/model-encrypt-tool/enc_model_gen
0 → 100755
浏览文件 @
a61c31df
文件已添加
tools/python/fluidtools/run.py
浏览文件 @
a61c31df
...
...
@@ -17,6 +17,8 @@ fast_check = False
is_sample_step
=
False
sample_step
=
1
sample_num
=
20
need_encrypt
=
False
checked_encrypt_model_path
=
"checked_encrypt_model"
np
.
set_printoptions
(
linewidth
=
150
)
...
...
@@ -107,6 +109,27 @@ def resave_model(feed_kv):
pp_green
(
"has not found wrong shape"
,
1
)
pp_green
(
"new model is saved into directory 【{}】"
.
format
(
checked_model_path
),
1
)
# 分别加密model和params,加密key使用同一个
def
encrypt_model
():
if
not
need_encrypt
:
return
pp_yellow
(
dot
+
dot
+
" encrypting model"
)
if
not
os
.
path
.
exists
(
checked_encrypt_model_path
):
os
.
mkdir
(
checked_encrypt_model_path
)
res
=
sh
(
"model-encrypt-tool/enc_key_gen -l 20 -c 232"
)
lines
=
res
.
split
(
"
\n
"
)
for
line
in
lines
:
if
line
.
startswith
(
"key:"
):
line
=
line
.
replace
(
'key:'
,
''
)
sh
(
"model-encrypt-tool/enc_model_gen -k '{}' -c 2 -i checked_model/model -o "
"checked_model/model.ml"
.
format
(
line
))
sh
(
"model-encrypt-tool/enc_model_gen -k '{}' -c 2 -i checked_model/params -o checked_model/params.ml"
.
format
(
line
))
pp_green
(
"model has been encrypted, key is : {}"
.
format
(
line
),
1
)
sh
(
"mv {} {}"
.
format
(
checked_model_path
+
"/*.ml"
,
checked_encrypt_model_path
))
return
pp_red
(
"model encrypt error"
,
1
)
# 生成feed的key-value对
def
gen_feed_kv
():
feed_kv
=
{}
...
...
@@ -413,6 +436,8 @@ def main():
# 重新保存模型
pp_yellow
(
dot
+
dot
+
" checking model correctness"
)
resave_model
(
feed_kv
=
feed_kv
)
# 输出加密模型
encrypt_model
()
# 输出所有中间结果
pp_yellow
(
dot
+
dot
+
" checking output result of every op"
)
save_all_op_output
(
feed_kv
=
feed_kv
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录