-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5625 from OpenMined/dev
0.5.0rc2 one more time
- Loading branch information
Showing
12 changed files
with
184 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
syntax = "proto3"; | ||
|
||
package syft.lib.torch; | ||
import "proto/core/common/common_object.proto"; | ||
|
||
message Size { | ||
repeated uint64 data = 1; | ||
syft.core.common.UID id = 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
flake8-kwarger @ git+https://github.com/madhavajay/flake8-kwarger | ||
pytorch-lightning @ git+https://github.com/tudorcebere/pytorch-lightning@tudor-om-v0 | ||
sympc @ git+https://github.com/OpenMined/SyMPC@main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# third party | ||
import torch | ||
|
||
# syft relative | ||
from ...generate_wrapper import GenerateWrapper | ||
from ...proto.lib.torch.size_pb2 import Size as TorchSize_PB | ||
|
||
|
||
def protobuf_torch_size_serializer(torch_size: torch.Size) -> TorchSize_PB: | ||
serialized_size = TorchSize_PB(data=torch_size) | ||
return serialized_size | ||
|
||
|
||
def protobuf_torch_size_deserializer(proto_size: TorchSize_PB) -> torch.Size: | ||
torch_size = torch.Size(proto_size.data) | ||
return torch_size | ||
|
||
|
||
GenerateWrapper( | ||
wrapped_type=torch.Size, | ||
import_path="torch.Size", | ||
protobuf_scheme=TorchSize_PB, | ||
type_object2proto=protobuf_torch_size_serializer, | ||
type_proto2object=protobuf_torch_size_deserializer, | ||
) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# third party | ||
import torch | ||
|
||
# syft absolute | ||
import syft as sy | ||
|
||
|
||
def test_protobuf_torch_size_serializer_deserializer() -> None: | ||
torch_size = torch.Size([4, 5, 2, 1]) | ||
torch_size_pb = sy.lib.torch.size.protobuf_torch_size_serializer(torch_size) | ||
torch_size_deserialized = sy.lib.torch.size.protobuf_torch_size_deserializer( | ||
torch_size_pb | ||
) | ||
|
||
assert isinstance(torch_size_deserialized, torch.Size) | ||
assert torch_size == torch_size_deserialized | ||
|
||
|
||
def test_torch_size_serde(client: sy.VirtualMachineClient) -> None: | ||
torch_size = torch.Size([2, 3, 4, 100]) | ||
torch_size_ptr = torch_size.send(client) | ||
assert torch_size_ptr.get() == torch_size |