Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleFL
提交
17491aef
P
PaddleFL
项目概览
PaddlePaddle
/
PaddleFL
通知
35
Star
5
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
6
列表
看板
标记
里程碑
合并请求
4
Wiki
3
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleFL
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
6
Issue
6
列表
看板
标记
里程碑
合并请求
4
合并请求
4
Pages
分析
分析
仓库分析
DevOps
Wiki
3
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
17491aef
编写于
9月 01, 2020
作者:
H
He,Kai
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix bugs
上级
9a3ac286
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
29 addition
and
9 deletion
+29
-9
core/psi/prng.cc
core/psi/prng.cc
+6
-1
python/paddle_fl/mpc/data_utils/aby3.py
python/paddle_fl/mpc/data_utils/aby3.py
+2
-2
python/paddle_fl/mpc/tests/unittests/test_datautils_align.py
python/paddle_fl/mpc/tests/unittests/test_datautils_align.py
+21
-6
未找到文件。
core/psi/prng.cc
浏览文件 @
17491aef
...
@@ -21,7 +21,6 @@ namespace psi {
...
@@ -21,7 +21,6 @@ namespace psi {
PseudorandomNumberGenerator
::
PseudorandomNumberGenerator
(
const
block
&
seed
)
PseudorandomNumberGenerator
::
PseudorandomNumberGenerator
(
const
block
&
seed
)
:
_ctr
(
0
),
_now_byte
(
0
)
{
:
_ctr
(
0
),
_now_byte
(
0
)
{
set_seed
(
seed
);
set_seed
(
seed
);
refill_buffer
();
}
}
void
PseudorandomNumberGenerator
::
set_seed
(
const
block
&
b
)
{
void
PseudorandomNumberGenerator
::
set_seed
(
const
block
&
b
)
{
...
@@ -59,4 +58,10 @@ void PseudorandomNumberGenerator::get_array(void *res, size_t len) {
...
@@ -59,4 +58,10 @@ void PseudorandomNumberGenerator::get_array(void *res, size_t len) {
}
}
}
}
template
<
>
bool
PseudorandomNumberGenerator
::
get
<
bool
>
()
{
uint8_t
data
;
get_array
(
&
data
,
sizeof
(
data
));
return
data
&
1
;
}
}
// namespace smc
}
// namespace smc
python/paddle_fl/mpc/data_utils/aby3.py
浏览文件 @
17491aef
...
@@ -338,7 +338,7 @@ def _transpile_type_and_shape(block):
...
@@ -338,7 +338,7 @@ def _transpile_type_and_shape(block):
for
op
in
block
.
ops
:
for
op
in
block
.
ops
:
if
_is_supported_op
(
op
.
type
):
if
_is_supported_op
(
op
.
type
):
if
op
.
type
==
'fill_constant'
:
if
op
.
type
==
'fill_constant'
:
op
.
_set_attr
(
name
=
'shape'
,
val
=
(
2
L
,
1L
))
op
.
_set_attr
(
name
=
'shape'
,
val
=
(
2
,
1
))
# set default MPC value for fill_constant OP
# set default MPC value for fill_constant OP
op
.
_set_attr
(
name
=
'value'
,
val
=
MPC_ONE_SHARE
)
op
.
_set_attr
(
name
=
'value'
,
val
=
MPC_ONE_SHARE
)
op
.
_set_attr
(
name
=
'dtype'
,
val
=
3
)
op
.
_set_attr
(
name
=
'dtype'
,
val
=
3
)
...
@@ -482,7 +482,7 @@ def decrypt_model(mpc_model_dir, plain_model_path, mpc_model_filename=None, plai
...
@@ -482,7 +482,7 @@ def decrypt_model(mpc_model_dir, plain_model_path, mpc_model_filename=None, plai
new_type
=
str
(
mpc_op
.
type
)[
len
(
MPC_OP_PREFIX
):]
new_type
=
str
(
mpc_op
.
type
)[
len
(
MPC_OP_PREFIX
):]
mpc_op
.
desc
.
set_type
(
new_type
)
mpc_op
.
desc
.
set_type
(
new_type
)
elif
mpc_op
.
type
==
'fill_constant'
:
elif
mpc_op
.
type
==
'fill_constant'
:
mpc_op
.
_set_attr
(
name
=
'shape'
,
val
=
(
1
L
))
mpc_op
.
_set_attr
(
name
=
'shape'
,
val
=
(
1
))
mpc_op
.
_set_attr
(
name
=
'value'
,
val
=
1.0
)
mpc_op
.
_set_attr
(
name
=
'value'
,
val
=
1.0
)
mpc_op
.
_set_attr
(
name
=
'dtype'
,
val
=
5
)
mpc_op
.
_set_attr
(
name
=
'dtype'
,
val
=
5
)
...
...
python/paddle_fl/mpc/tests/unittests/test_datautils_align.py
浏览文件 @
17491aef
...
@@ -17,14 +17,16 @@ This module test align in aby3 module.
...
@@ -17,14 +17,16 @@ This module test align in aby3 module.
"""
"""
import
unittest
import
unittest
from
multiprocessing
import
Process
import
multiprocessing
as
mp
import
paddle_fl.mpc.data_utils.alignment
as
alignment
import
paddle_fl.mpc.data_utils.alignment
as
alignment
class
TestDataUtilsAlign
(
unittest
.
TestCase
):
class
TestDataUtilsAlign
(
unittest
.
TestCase
):
def
run_align
(
self
,
input_set
,
party_id
,
endpoints
,
is_receiver
):
@
staticmethod
def
run_align
(
input_set
,
party_id
,
endpoints
,
is_receiver
,
ret_list
):
"""
"""
Call align function in data_utils.
Call align function in data_utils.
:param input_set:
:param input_set:
...
@@ -37,7 +39,7 @@ class TestDataUtilsAlign(unittest.TestCase):
...
@@ -37,7 +39,7 @@ class TestDataUtilsAlign(unittest.TestCase):
party_id
=
party_id
,
party_id
=
party_id
,
endpoints
=
endpoints
,
endpoints
=
endpoints
,
is_receiver
=
is_receiver
)
is_receiver
=
is_receiver
)
self
.
assertEqual
(
result
,
{
'0'
}
)
ret_list
.
append
(
result
)
def
test_align
(
self
):
def
test_align
(
self
):
"""
"""
...
@@ -49,14 +51,27 @@ class TestDataUtilsAlign(unittest.TestCase):
...
@@ -49,14 +51,27 @@ class TestDataUtilsAlign(unittest.TestCase):
set_1
=
{
'0'
,
'10'
,
'11'
,
'111'
}
set_1
=
{
'0'
,
'10'
,
'11'
,
'111'
}
set_2
=
{
'0'
,
'30'
,
'33'
,
'333'
}
set_2
=
{
'0'
,
'30'
,
'33'
,
'333'
}
party_0
=
Process
(
target
=
self
.
run_align
,
args
=
(
set_0
,
0
,
endpoints
,
True
))
mp
.
set_start_method
(
'spawn'
)
party_1
=
Process
(
target
=
self
.
run_align
,
args
=
(
set_1
,
1
,
endpoints
,
False
))
party_2
=
Process
(
target
=
self
.
run_align
,
args
=
(
set_2
,
2
,
endpoints
,
False
))
manager
=
mp
.
Manager
()
ret_list
=
manager
.
list
()
party_0
=
mp
.
Process
(
target
=
self
.
run_align
,
args
=
(
set_0
,
0
,
endpoints
,
True
,
ret_list
))
party_1
=
mp
.
Process
(
target
=
self
.
run_align
,
args
=
(
set_1
,
1
,
endpoints
,
False
,
ret_list
))
party_2
=
mp
.
Process
(
target
=
self
.
run_align
,
args
=
(
set_2
,
2
,
endpoints
,
False
,
ret_list
))
party_1
.
start
()
party_1
.
start
()
party_2
.
start
()
party_2
.
start
()
party_0
.
start
()
party_0
.
start
()
party_0
.
join
()
party_0
.
join
()
party_1
.
join
()
party_2
.
join
()
self
.
assertEqual
(
3
,
len
(
ret_list
))
self
.
assertEqual
(
ret_list
[
0
],
ret_list
[
1
])
self
.
assertEqual
(
ret_list
[
0
],
ret_list
[
2
])
self
.
assertEqual
({
'0'
},
ret_list
[
0
])
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录