-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: weiwee <wbwmat@gmail.com>
- Loading branch information
Showing
3 changed files
with
80 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import torch | ||
from fate.arch import Context, tensor | ||
from fate.arch.computing.standalone import CSession | ||
from fate.arch.context import Context | ||
from fate.arch.federation.standalone import StandaloneFederation | ||
from pytest import fixture | ||
|
||
|
||
@fixture | ||
def ctx(): | ||
computing = CSession() | ||
return Context( | ||
"guest", | ||
computing=computing, | ||
federation=StandaloneFederation(computing, "fed", ("guest", 10000), [("host", 9999)]), | ||
) | ||
|
||
|
||
@fixture | ||
def t1(ctx): | ||
return tensor.distributed_tensor( | ||
ctx, | ||
[ | ||
torch.tensor([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]), | ||
torch.tensor([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]), | ||
torch.tensor([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]), | ||
], | ||
) | ||
|
||
|
||
@fixture | ||
def t3(): | ||
return tensor.tensor( | ||
torch.tensor([[1.0, 2.0, 3.0, 4.0, 5.0, 6.0], [1.0, 2.0, 3.0, 4.0, 5.0, 6.0], [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]]), | ||
) | ||
|
||
|
||
@fixture | ||
def t2(ctx): | ||
return tensor.distributed_tensor( | ||
ctx, | ||
[ | ||
torch.tensor([[1.0, 4.0], [2.0, 5.0], [3.0, 6.0]]), | ||
torch.tensor([[1.0, 4.0], [2.0, 5.0], [3.0, 6.0]]), | ||
torch.tensor([[1.0, 4.0], [2.0, 5.0], [3.0, 6.0]]), | ||
], | ||
d_axis=1, | ||
) | ||
|
||
|
||
@fixture | ||
def t4(): | ||
return torch.tensor( | ||
[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [1.0, 2.0, 3.0], [4.0, 5.0, 6.0]] | ||
) | ||
|
||
|
||
def test_1(t1, t3): | ||
print(t1.to_local()) | ||
print(t3) | ||
print(tensor.matmul(t1, t3).to_local()) |