def test_sum(self): """Tests sum using binary shares""" tensor = get_random_test_tensor(size=(5, 5, 5), is_float=False) encrypted = BinarySharedTensor(tensor) self._check(encrypted.sum(), tensor.sum(), "sum failed") for dim in [0, 1, 2]: reference = tensor.sum(dim) encrypted_out = encrypted.sum(dim) self._check(encrypted_out, reference, "sum failed")
def test_sum(self): """Tests sum using binary shares""" tensor = get_random_test_tensor(size=(5, 5, 5), is_float=False) encrypted = BinarySharedTensor(tensor) self._check(encrypted.sum(), tensor.sum(), "sum failed") for dim in [0, 1, 2]: reference = tensor.sum(dim) with self.benchmark(type="sum", dim=dim) as bench: for _ in bench.iters: encrypted_out = encrypted.sum(dim) self._check(encrypted_out, reference, "sum failed")