(
is_remote: bool, model_type: Type[sy.Module], get_clients: Callable[[int], Any]
)
| 109 | @pytest.mark.parametrize("is_remote", [False, True]) |
| 110 | @pytest.mark.parametrize("model_type", [LinearNet, ConvNet]) |
| 111 | def test_reconstruct_shared_model( |
| 112 | is_remote: bool, model_type: Type[sy.Module], get_clients: Callable[[int], Any] |
| 113 | ): |
| 114 | net = model_type(torch) |
| 115 | |
| 116 | clients = get_clients(2) |
| 117 | |
| 118 | session = Session(parties=clients) |
| 119 | SessionManager.setup_mpc(session) |
| 120 | |
| 121 | if is_remote: |
| 122 | model = net.send(clients[0]) |
| 123 | else: |
| 124 | model = net |
| 125 | |
| 126 | mpc_model = model.share(session=session) |
| 127 | res = mpc_model.reconstruct() |
| 128 | |
| 129 | assert isinstance(res, sy.Module) |
| 130 | |
| 131 | if is_remote: |
| 132 | # If the model is remote fetch it such that we could compare it |
| 133 | model = model.get() |
| 134 | |
| 135 | for name_res, name_expected in zip(res.modules, model.modules): |
| 136 | assert name_res == name_expected |
| 137 | |
| 138 | module_expected = model.modules[name_expected] |
| 139 | module_res = res.modules[name_res] |
| 140 | |
| 141 | name_module = type(module_expected).__name__ |
| 142 | assert MAP_TORCH_TO_SYMPC[name_module].eq_close( |
| 143 | module_expected, module_res, atol=1e-4 |
| 144 | ) |
| 145 | |
| 146 | |
| 147 | def test_additional_attributes(get_clients): |
nothing calls this directly
no test coverage detected