syft.frameworks.torch.linalg.operations¶
Module Contents¶
-
syft.frameworks.torch.linalg.operations.inv_sym(t)¶ This function performs the inversion of a symmetric matrix (2-dim tensor) in MPC. It uses LDLt decomposition, which is better than Cholensky decomposition in our case since it doesn’t use square root. Algorithm reference: https://arxiv.org/abs/1111.4144 - Section IV
- Parameters
t – symmetric 2-dim tensor
- Returns
inverse of t as 2-dim tensor
- Return type
t_inv
-
syft.frameworks.torch.linalg.operations._ldl(t)¶ This function performs the LDLt decomposition of a symmetric matrix (2-dim tensor)
- Parameters
t – symmetric 2-dim tensor
- Returns
lower triangular matrix as a 2-dim tensor with same type as t d: 1-dim tensor which represents the diagonal in the LDLt decomposition inv_d: 1-dim tensor which represents the inverse of the diagonal d. It is usefull
when computing inverse of a symmetric matrix, by caching it we avoid repeated computations with division, which is very slow in MPC
- Return type
l
-
syft.frameworks.torch.linalg.operations.qr(t, mode='reduced', norm_factor=None)¶ This function performs the QR decomposition of a matrix (2-dim tensor). The decomposition is performed using Householder Reflection.
- Parameters
t – 2-dim tensor, shape(M, N). It should be whether a local tensor, a pointer to a remote tensor or an AdditiveSharedTensor
mode – {‘reduced’, ‘complete’, ‘r’}. If K = min(M, N), then - ‘reduced’ : returns q, r with dimensions (M, K), (K, N) (default) - ‘complete’ : returns q, r with dimensions (M, M), (M, N) - ‘r’ : returns r only with dimensions (K, N)
norm_factor – float. The normalization factor used to avoid overflow when performing QR decomposition on an AdditiveSharedTensor. For example in the case of the DASH algorithm, this norm_factor should be of the order of the square root of number of entries in the original matrix used to perform the compression phase assuming the entries are standardized.
- Returns
orthogonal matrix as a 2-dim tensor with same type as t r: lower triangular matrix as a 2-dim tensor with same type as t
- Return type
q
-
syft.frameworks.torch.linalg.operations._norm_mpc(t, norm_factor)¶ Computation of a norm of a vector in MPC. The vector should be an AdditiveSharedTensor.
It performs the norm calculation by masking the tensor with a multiplication by a big random number drawn from a uniform distribution, and computing the square root of the squared norm of the masked tensor, which is computed beforehand with a dot product in MPC.
In order to maintain stability and avoid overflow, this functions uses a norm_factor that scales down the tensor for MPC computations and rescale it at the end. For example in the case of the DASH algorithm, this norm_factor should be of the order of the square root of number of entries in the original matrix used to perform the compression phase assuming the entries are standardized.
- Parameters
t – 1-dim AdditiveSharedTensor, representing a vector.
norm_factor – float. The normalization factor used to avoid overflow
- Returns
the norm of the vector as an AdditiveSharedTensor