예제 #1
0
def test_additive_sharing_tensor_serde(compress, workers):
    alice, bob, james, me = workers["alice"], workers["bob"], workers["james"], workers["me"]

    x = torch.tensor([[3.1, 4.3]]).fix_prec().share(alice, bob, crypto_provider=james)

    additive_sharing_tensor = x.child.child
    data = AdditiveSharingTensor.simplify(me, additive_sharing_tensor)
    additive_sharing_tensor_reconstructed = AdditiveSharingTensor.detail(me, data)

    assert additive_sharing_tensor_reconstructed.field == additive_sharing_tensor.field

    assert (
        additive_sharing_tensor_reconstructed.child.keys() == additive_sharing_tensor.child.keys()
    )
예제 #2
0
def test_wrap(workers):
    """
    Test the .on() wrap functionality for AdditiveSharingTensor
    """

    x_tensor = torch.Tensor([1, 2, 3])
    x = AdditiveSharingTensor().on(x_tensor)
    assert isinstance(x, torch.Tensor)
    assert isinstance(x.child, AdditiveSharingTensor)
    assert isinstance(x.child.child, torch.Tensor)