Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to concatenate ReplicatedSharedTensor? #324

Closed
Timo9Madrid7 opened this issue Apr 28, 2022 · 1 comment
Closed

How to concatenate ReplicatedSharedTensor? #324

Timo9Madrid7 opened this issue Apr 28, 2022 · 1 comment

Comments

@Timo9Madrid7
Copy link
Contributor

Hi,

I noticed sympc.tensor.static.cat can concatenate ShareTensors, but it couldn't support ReplicatedSharedTensor. So, I wonder if there exists a method to concatenate ReplicatedSharedTensor?

Thanks,
Timo

@Timo9Madrid7
Copy link
Contributor Author

Timo9Madrid7 commented Apr 28, 2022

I had solved this issue, so I closed it. If anyone meets the same problem, try to do the followings:
1. Create n replicated shares.
2. Before sharing these n shares, use torch.cat to concatenate shares shares[i].get_shares()[j] that belongs to the identical party j.
3. Use ReplicatedSharedTensor.distribute_shares or MPCTensor to send those shares to each party.

Or you can manually distribute those shares, but remember each party should have n-1 share_ptrs otherwise the reconstruct will give you the wrong shape and wrong values.

added cat_replicatedShare_tensor in apy.py and static.py for the concatenation of ReplicatedSharedTensor
PR: #326

Timo9Madrid7 added a commit to Timo9Madrid7/maliciousfl that referenced this issue Apr 28, 2022
Timo9Madrid7 added a commit to Timo9Madrid7/SyMPC that referenced this issue Apr 30, 2022
- refer to issue OpenMined#324
- `cat` can concatenates `ShareTensor`s, but it is not workable for `ReplicatedSharedTensor`.
- added `cat_replicatedShare_tensor` in *apy.py* and *static.py* for the concatenation of `ReplicatedSharedTensor`.
Timo9Madrid7 added a commit to Timo9Madrid7/SyMPC that referenced this issue Apr 30, 2022
- refer to issue OpenMined#324
- `cat` can concatenates `ShareTensor`s, but it is not workable for `ReplicatedSharedTensor`.
- added `cat_replicatedShare_tensor` in *apy.py* and *static.py* for the concatenation of `ReplicatedSharedTensor`.
gmuraru added a commit that referenced this issue May 15, 2022
* `cat` concatenates `ReplicatedSharedTensor`

- refer to issue #324
- `cat` can concatenates `ShareTensor`s, but it is not workable for `ReplicatedSharedTensor`.
- added `cat_replicatedShare_tensor` in *apy.py* and *static.py* for the concatenation of `ReplicatedSharedTensor`.

* Saving a variable and formatting

Format
The following commands have been run:
- `python -m black tensor/static.py`
- `python -m black api.py`
- `isort tensor/static.py`

Save number of replicated shares as a variable
- Q: Could you save the len(shares[0].shares) in a variable and then use it here and on line 140? [x]*done*

Amended docstring
- `shares` is a tuple of `ReplicatedSharedTensor`s
- the empty blank is deleted in `cat_replicatedShare_tensor`

* For Python3.7 that doesn't support `math.prod`

- python 3.7 cannot support `math.prod`, only python 3.8+ can.

* Remove python3.7

* Remove tutorial python3.7

Co-authored-by: George Muraru <murarugeorgec@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant