提交 62d028c8 编写于 作者: J jingqinghe

update

上级 7da61872
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
INCLUDE(ExternalProject)
SET(HIREDIS_DIR ${CMAKE_CURRENT_SOURCE_DIR})
SET(HIREDIS_INCLUDE_DIRS ${HIREDIS_DIR})
SET(HIREDIS_NAME "hiredis" CACHE STRING "" FORCE)
SET(HIREDIS_URL "https://paddlefl.bj.bcebos.com/hiredis.tar.gz" CACHE STRING "" FORCE)
ExternalProject_Add(
extern_hiredis
#URL https://paddlefl.bj.bcebos.com/hiredis.tar.gz
# GIT_REPOSITORY "https://github.com/redis/hiredis"
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/hiredis
SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/hiredis
DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}/hiredis
DOWNLOAD_COMMAND wget --no-check-certificate ${HIREDIS_URL} -c -q -O ${HIREDIS_NAME}.tar.gz
&& tar xf ${HIREDIS_NAME}.tar.gz --strip-components 1
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND ""
BUILD_COMMAND make static
INSTALL_COMMAND "")
INCLUDE_DIRECTORIES(${HIREDIS_INCLUDE_DIRS})
message(STATUS "${HIREDIS_INCLUDE_DIRS}")
ADD_LIBRARY(hiredis SHARED IMPORTED GLOBAL)
ADD_DEPENDENCIES(hiredis extern_hiredis)
\ No newline at end of file
......@@ -106,9 +106,9 @@ template <typename DeviceContext, typename T>
class MpcElementwiseAddKernel : public MpcOpKernel<T> {
public:
void ComputeImpl(const framework::ExecutionContext &ctx) const override {
auto *in_x_t = ctx.Input<framework::LoDTensor>("X");
auto *in_y_t = ctx.Input<framework::LoDTensor>("Y");
auto *out_t = ctx.Output<framework::LoDTensor>("Out");
auto *in_x_t = ctx.Input<LoDTensor>("X");
auto *in_y_t = ctx.Input<LoDTensor>("Y");
auto *out_t = ctx.Output<LoDTensor>("Out");
int axis = ctx.Attr<int>("axis");
......
......@@ -90,7 +90,7 @@ def make_shares(num_array):
[c2, d2]]]
"""
old_size = num_array.size
flat_num_array = num_array.reshape(old_size, )
flat_num_array = num_array.reshape(old_size,)
new_shape = (SHARE_NUM, ) + num_array.shape
result = np.empty((old_size, SHARE_NUM), dtype=np.int64)
for idx in six.moves.range(0, old_size):
......@@ -151,7 +151,7 @@ def save_aby3_shares(share_reader, part_name):
files = [file0, file1, file2]
for shares in share_reader():
for idx in six.moves.range(0, 3): # 3 parts
for idx in six.moves.range(0, 3): # 3 parts
share = get_aby3_shares(shares, idx)
files[idx].write(share.tostring())
......@@ -211,12 +211,12 @@ def reconstruct(aby3_shares, type=np.float):
output:
[a, b], where a = decrypt(a0, a1, a2), b = decrypt(b0, b1, b2)
"""
if len(aby3_shares) != 3: # should collect shares from 3 parts
if len(aby3_shares) != 3: # should collect shares from 3 parts
raise ValueError("Number of aby3 shares should be 3 but was: {}".
format(len(aby3_shares)))
raw_shares = aby3_shares[:, 0]
data_shape = raw_shares.shape[1:] # get rid of the first dim of [3, xxx]
data_shape = raw_shares.shape[1:] # get rid of the first dim of [3, xxx]
data_size = np.prod(data_shape)
row_first_raw_shares = raw_shares.reshape(3, data_size).transpose(1, 0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册