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

FIX Return invalid dtype when MPC is applied #4035

Merged
merged 6 commits into from
Aug 22, 2020
Merged

FIX Return invalid dtype when MPC is applied #4035

merged 6 commits into from
Aug 22, 2020

Conversation

aanurraj
Copy link
Member

@aanurraj aanurraj commented Aug 18, 2020

Description

Issue:
this was the original issue #3982 raised there was a mismatch in dtype after using the share()

Reason:
The create_wrapper class which was used to create the wrapper was returning tensor with a dtype torch.float32.

Fix
sending the type=self.dtype as a parameter in shared_tensor.wrap() from the share() solves the issue.
wrap() function calls another function sy.framework.hook.create_wrapper(type, **kwargs) which is appended below
Screenshot 2020-08-20 at 4 42 36 PM
in create_wrapper(cls, wrapper_type) function if wrapper_type is None we get torch.Tensor() in return which is by default of dtype torch.float32 (which is our issue). This was easily fixed by sending the dtype from the share() fucntion which ultimatly reaches to create_wrapper(cls, wrapper_type) and sets the dtype.

This pull request closes #3982

Affected Dependencies

None

How has this been tested?

one new test case has been added in test_share_get() function of the test_additive_shared.py file.

Checklist

@codecov
Copy link

codecov bot commented Aug 20, 2020

Codecov Report

Merging #4035 into master will decrease coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4035      +/-   ##
==========================================
- Coverage   94.78%   94.76%   -0.02%     
==========================================
  Files         205      205              
  Lines       21182    21183       +1     
==========================================
- Hits        20077    20075       -2     
- Misses       1105     1108       +3     
Impacted Files Coverage Δ
...ft/frameworks/torch/tensors/interpreters/native.py 91.27% <100.00%> (-0.22%) ⬇️
test/torch/tensors/test_additive_shared.py 100.00% <100.00%> (ø)
syft/execution/plan.py 94.33% <0.00%> (-0.57%) ⬇️

Copy link
Member

@Syzygianinfern0 Syzygianinfern0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎉

Thank you for your contributions @aanurraj
Well explained solution too 🥳

@Syzygianinfern0 Syzygianinfern0 merged commit 7fe9f79 into OpenMined:master Aug 22, 2020
rav1kantsingh pushed a commit to rav1kantsingh/PySyft that referenced this pull request Oct 29, 2020
* added sigmoid_approximation_plot

created benchmark folder, and scripts and benchmark graph

* added comments

* Lint, format, and type-check error fixed

* issues fixed

* fixed-invalid-dtype-issue

* bugs-fixed
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

Successfully merging this pull request may close these issues.

Return invalid dtype when MPC is applied to Other Dtype Tensor
3 participants