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

Conjugate View #54987

Closed
wants to merge 43 commits into from
Closed

Conjugate View #54987

wants to merge 43 commits into from

Conversation

anjali411
Copy link
Contributor

@anjali411 anjali411 commented Mar 30, 2021

Based off of ezyang (#44799) and bdhirsh (#43702) 's prototype:
Stack from ghstack:

Here's a summary of the changes in this PR:
This PR adds a new dispatch key called Conjugate. This enables us to make conjugate operation a view and leverage the specialized library functions that fast path with the hermitian operation (conj + transpose).

  1. Conjugate operation will now return a view with conj bit (1) for complex tensors and returns self for non-complex tensors as before. This also means torch.view_as_real will no longer be a view on conjugated complex tensors and is hence disabled. To fill the gap, we have added torch.view_as_real_physical which would return the real tensor agnostic of the conjugate bit on the input complex tensor. The information about conjugation on the old tensor can be obtained by calling .is_conj() on the new tensor.
  2. NEW API:
    a) .conj() -- now returning a view.
    b) .conj_physical() -- does the physical conjugate operation. If the conj bit for input was set, you'd get self.clone(), else you'll get a new tensor with conjugated value in its memory.
    c) .conj_physical_(), and out= variant
    d) .resolve_conj() -- materializes the conjugation. returns self if the conj bit is unset, else returns a new tensor with conjugated values and conj bit set to 0.
    e) view_as_real_physical -- as described in (1), it's functionally same as view_as_real, just that it doesn't error out on conjugated tensors.
    g) view_as_real -- existing function, but now errors out on conjugated tensors.
  3. Conjugate Fallback
    a) Vast majority of PyTorch functions would currently use this fallback when they are called on a conjugated tensor.
    b) This fallback is well equipped to handle the following cases:
    - functional operation e.g., torch.sin(input)
    - Mutable inputs and in-place operations e.g., tensor.add_(2)
    - out-of-place operation e.g., torch.sin(input, out=out)
    - Tensorlist input args
    - NOTE: Meta tensors don't work with conjugate fallback.
  4. Autograd
    a) resolve_conj() is an identity function w.r.t. autograd
    b) Everything else works as expected.
  5. Testing:
    a) All method_tests run with conjugate view tensors.
    b) OpInfo tests that run with conjugate views
    - test_variant_consistency_eager/jit
    - gradcheck, gradgradcheck
    - test_conj_views (that only run for torch.cfloat dtype)

NOTE: functions like empty_like, zero_like, randn_like, clone don't propagate the conjugate bit.

Follow up work:

  1. conjugate view RFC
  2. Add neg bit to re-enable view operation on conjugated tensors
  3. Update linalg functions to call into specialized functions that fast path with the hermitian operation.

Differential Revision: D28227315

[ghstack-poisoned]
@facebook-github-bot facebook-github-bot added oncall: jit Add this issue/PR to JIT oncall triage queue cla signed labels Mar 30, 2021
anjali411 added a commit that referenced this pull request Mar 30, 2021
ghstack-source-id: 8778085a27393ae1c75b43f2439bcd785fb1772d
Pull Request resolved: #54987
@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented Mar 30, 2021

💊 CI failures summary and remediations

As of commit 316fbe3 (more details on the Dr. CI page):


  • 2/2 failures possibly* introduced in this PR
    • 1/2 non-scanned failure(s)

1 failure not recognized by patterns:

Job Step Action
CircleCI pytorch_linux_xenial_py3_6_gcc5_4_test Run tests 🔁 rerun

This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions to the (internal) Dr. CI Users group.

Click here to manually regenerate this comment.

@anjali411 anjali411 changed the title Conjugate View [WIP] Conjugate View Mar 30, 2021
@anjali411 anjali411 marked this pull request as draft March 30, 2021 21:26
@anjali411 anjali411 changed the title [WIP] Conjugate View Conjugate View Mar 31, 2021
@anjali411 anjali411 added the module: bc-breaking Related to a BC-breaking change label Apr 1, 2021
Based off of @ezyang (#44799) and @bdhirsh (#43702) 's prototype:  



[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Apr 1, 2021
ghstack-source-id: d4412253e1beb7d876ffca72b80fa06a59898644
Pull Request resolved: #54987
Based off of @ezyang (#44799) and @bdhirsh (#43702) 's prototype:  



[ghstack-poisoned]
Based off of @ezyang (#44799) and @bdhirsh (#43702) 's prototype:  



[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Apr 2, 2021
ghstack-source-id: f69c3327e081b22200ad5f1bfd469be67b800201
Pull Request resolved: #54987
Based off of @ezyang (#44799) and @bdhirsh (#43702) 's prototype:  



[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Apr 2, 2021
ghstack-source-id: cb1684261c01a96d8e823ccf23793ddfd7c6bc22
Pull Request resolved: #54987
Based off of @ezyang (#44799) and @bdhirsh (#43702) 's prototype:  



[ghstack-poisoned]
Based off of @ezyang (#44799) and @bdhirsh (#43702) 's prototype:  



[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Apr 6, 2021
ghstack-source-id: a381be7b3e4d12d46c629d44939c249e4b3ee8c4
Pull Request resolved: #54987
Based off of @ezyang (#44799) and @bdhirsh (#43702) 's prototype:  



[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Apr 6, 2021
ghstack-source-id: b6bf594e29cef9cd3a1348c87746c8ef6f3bb97a
Pull Request resolved: #54987
Based off of @ezyang (#44799) and @bdhirsh (#43702) 's prototype:  



[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Apr 7, 2021
ghstack-source-id: c0c68785b17f0d820b80ed10f598dfada9595e2f
Pull Request resolved: #54987
Based off of ezyang (#44799) and bdhirsh (#43702) 's prototype:  



[ghstack-poisoned]
@facebook-github-bot
Copy link
Contributor

@anjali411 merged this pull request in 3607478.

@facebook-github-bot facebook-github-bot deleted the gh/anjali411/114/head branch June 8, 2021 14:17
deniskokarev pushed a commit to deniskokarev/pytorch that referenced this pull request Jun 9, 2021
Summary:
Pull Request resolved: pytorch#54987

Based off of ezyang (pytorch#44799) and bdhirsh (pytorch#43702) 's prototype:

Here's a summary of the changes in this PR:
This PR adds a new dispatch key called Conjugate. This enables us to make conjugate operation a view and leverage the specialized library functions that fast path with the hermitian operation (conj + transpose).

1. Conjugate operation will now return a view with conj bit (1) for complex tensors and returns self for non-complex tensors as before. This also means `torch.view_as_real` will no longer be a view on conjugated complex tensors and is hence disabled. To fill the gap, we have added `torch.view_as_real_physical` which would return the real tensor agnostic of the conjugate bit on the input complex tensor. The information about conjugation on the old tensor can be obtained by calling `.is_conj()` on the new tensor.
2. NEW API:
    a) `.conj()` -- now returning a view.
    b) `.conj_physical()` -- does the physical conjugate operation. If the conj bit for input was set, you'd get `self.clone()`, else you'll get a new tensor with conjugated value in its memory.
    c) `.conj_physical_()`, and `out=` variant
    d) `.resolve_conj()`  -- materializes the conjugation. returns self if the conj bit is unset, else returns a new tensor with conjugated values and conj bit set to 0.
    e) `.resolve_conj_()` in-place version of (d)
    f) `view_as_real_physical` -- as described in (1), it's functionally same as `view_as_real`, just that it doesn't error out on conjugated tensors.
    g) `view_as_real` -- existing function, but now errors out on conjugated tensors.
3. Conjugate Fallback
    a) Vast majority of PyTorch functions would currently use this fallback when they are called on a conjugated tensor.
    b) This fallback is well equipped to handle the following cases:
        - functional operation e.g., `torch.sin(input)`
        - Mutable inputs and in-place operations e.g., `tensor.add_(2)`
        - out-of-place operation e.g., `torch.sin(input, out=out)`
        - Tensorlist input args
        - NOTE: Meta tensors don't work with conjugate fallback.
4. Autograd
    a) `resolve_conj()` is an identity function w.r.t. autograd
    b) Everything else works as expected.
5. Testing:
    a) All method_tests run with conjugate view tensors.
    b) OpInfo tests that run with conjugate views
        - test_variant_consistency_eager/jit
        - gradcheck, gradgradcheck
        - test_conj_views (that only run for `torch.cfloat` dtype)

NOTE: functions like `empty_like`, `zero_like`, `randn_like`, `clone` don't propagate the conjugate bit.

Follow up work:
1. conjugate view RFC
2. Add neg bit to re-enable view operation on conjugated tensors
3. Update linalg functions to call into specialized functions that fast path with the hermitian operation.

Test Plan: Imported from OSS

Reviewed By: VitalyFedyunin

Differential Revision: D28227315

Pulled By: anjali411

fbshipit-source-id: acab9402b9d6a970c6d512809b627a290c8def5f
anjali411 added a commit that referenced this pull request Jul 8, 2021
User facing changes:
1. Adds a negative bit and corresponding new API (`is_neg()`,`resolve_neg()`)
2. `tensor.conj().imag` now returns a floating point tensor with neg bit set to 1 instead of a tensor with no notion of negative bit. Note that imag is still a view and all the view properties still hold for imag.

Non user facing changes:
1. Added a new Negative dispatch key and a backend fallback to handle it
2. Updated copy kernel to handle negative bit
3. Merged conjugate and negative bit fallback kernel
4. fixed #60478 (caused due to #54987)

Testing:
1. Added a new OpInfo based test `test_neg_view` (verifies that out-of-place and in-place operations work correctly for all operations when the input is a neg view tensor by checking the result against an actually negated tensor, verifies that autograd returns the same output for both neg view and actually negated tensors as well as it works fine when grad_out is a neg view).
2. Added a new test class containing `test_conj_view`, `test_neg_view`. 

TODO:
follow up on #60522 (comment)

Differential Revision: [](https://our.internmc.facebook.com/intern/diff/)

[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Jul 8, 2021
User facing changes:
1. Adds a negative bit and corresponding new API (`is_neg()`,`resolve_neg()`)
2. `tensor.conj().imag` now returns a floating point tensor with neg bit set to 1 instead of a tensor with no notion of negative bit. Note that imag is still a view and all the view properties still hold for imag.

Non user facing changes:
1. Added a new Negative dispatch key and a backend fallback to handle it
2. Updated copy kernel to handle negative bit
3. Merged conjugate and negative bit fallback kernel
4. fixed #60478 (caused due to #54987)

Testing:
1. Added a new OpInfo based test `test_neg_view` (verifies that out-of-place and in-place operations work correctly for all operations when the input is a neg view tensor by checking the result against an actually negated tensor, verifies that autograd returns the same output for both neg view and actually negated tensors as well as it works fine when grad_out is a neg view).
2. Added a new test class containing `test_conj_view`, `test_neg_view`. 

TODO:
follow up on #60522 (comment)

Differential Revision: [](https://our.internmc.facebook.com/intern/diff/)

[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Jul 9, 2021
User facing changes:
1. Adds a negative bit and corresponding new API (`is_neg()`,`resolve_neg()`)
2. `tensor.conj().imag` now returns a floating point tensor with neg bit set to 1 instead of a tensor with no notion of negative bit. Note that imag is still a view and all the view properties still hold for imag.

Non user facing changes:
1. Added a new Negative dispatch key and a backend fallback to handle it
2. Updated copy kernel to handle negative bit
3. Merged conjugate and negative bit fallback kernel
4. fixed #60478 (caused due to #54987)

Testing:
1. Added a new OpInfo based test `test_neg_view` (verifies that out-of-place and in-place operations work correctly for all operations when the input is a neg view tensor by checking the result against an actually negated tensor, verifies that autograd returns the same output for both neg view and actually negated tensors as well as it works fine when grad_out is a neg view).
2. Added a new test class containing `test_conj_view`, `test_neg_view`. 

Differential Revision: [](https://our.internmc.facebook.com/intern/diff/)

[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Jul 9, 2021
User facing changes:
1. Adds a negative bit and corresponding new API (`is_neg()`,`resolve_neg()`)
2. `tensor.conj().imag` now returns a floating point tensor with neg bit set to 1 instead of a tensor with no notion of negative bit. Note that imag is still a view and all the view properties still hold for imag.

Non user facing changes:
1. Added a new Negative dispatch key and a backend fallback to handle it
2. Updated copy kernel to handle negative bit
3. Merged conjugate and negative bit fallback kernel
4. fixed #60478 (caused due to #54987)

Testing:
1. Added a new OpInfo based test `test_neg_view` (verifies that out-of-place and in-place operations work correctly for all operations when the input is a neg view tensor by checking the result against an actually negated tensor, verifies that autograd returns the same output for both neg view and actually negated tensors as well as it works fine when grad_out is a neg view).
2. Added a new test class containing `test_conj_view`, `test_neg_view`. 

Differential Revision: [](https://our.internmc.facebook.com/intern/diff/)

[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Jul 9, 2021
User facing changes:
1. Adds a negative bit and corresponding new API (`is_neg()`,`resolve_neg()`)
2. `tensor.conj().imag` now returns a floating point tensor with neg bit set to 1 instead of a tensor with no notion of negative bit. Note that imag is still a view and all the view properties still hold for imag.

Non user facing changes:
1. Added a new Negative dispatch key and a backend fallback to handle it
2. Updated copy kernel to handle negative bit
3. Merged conjugate and negative bit fallback kernel
4. fixed #60478 (caused due to #54987)

Testing:
1. Added a new OpInfo based test `test_neg_view` (verifies that out-of-place and in-place operations work correctly for all operations when the input is a neg view tensor by checking the result against an actually negated tensor, verifies that autograd returns the same output for both neg view and actually negated tensors as well as it works fine when grad_out is a neg view).
2. Added a new test class containing `test_conj_view`, `test_neg_view`. 

Differential Revision: [](https://our.internmc.facebook.com/intern/diff/)

[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Jul 9, 2021
User facing changes:
1. Adds a negative bit and corresponding new API (`is_neg()`,`resolve_neg()`)
2. `tensor.conj().imag` now returns a floating point tensor with neg bit set to 1 instead of a tensor with no notion of negative bit. Note that imag is still a view and all the view properties still hold for imag.

Non user facing changes:
1. Added a new Negative dispatch key and a backend fallback to handle it
2. Updated copy kernel to handle negative bit
3. Merged conjugate and negative bit fallback kernel
4. fixed #60478 (caused due to #54987)

Testing:
1. Added a new OpInfo based test `test_neg_view` (verifies that out-of-place and in-place operations work correctly for all operations when the input is a neg view tensor by checking the result against an actually negated tensor, verifies that autograd returns the same output for both neg view and actually negated tensors as well as it works fine when grad_out is a neg view).
2. Added a new test class containing `test_conj_view`, `test_neg_view`. 

Differential Revision: [](https://our.internmc.facebook.com/intern/diff/)

[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Jul 9, 2021
User facing changes:
1. Adds a negative bit and corresponding new API (`is_neg()`,`resolve_neg()`)
2. `tensor.conj().imag` now returns a floating point tensor with neg bit set to 1 instead of a tensor with no notion of negative bit. Note that imag is still a view and all the view properties still hold for imag.

Non user facing changes:
1. Added a new Negative dispatch key and a backend fallback to handle it
2. Updated copy kernel to handle negative bit
3. Merged conjugate and negative bit fallback kernel
4. fixed #60478 (caused due to #54987)

Testing:
1. Added a new OpInfo based test `test_neg_view` (verifies that out-of-place and in-place operations work correctly for all operations when the input is a neg view tensor by checking the result against an actually negated tensor, verifies that autograd returns the same output for both neg view and actually negated tensors as well as it works fine when grad_out is a neg view).
2. Added a new test class containing `test_conj_view`, `test_neg_view`. 

Differential Revision: [](https://our.internmc.facebook.com/intern/diff/)

[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Jul 9, 2021
User facing changes:
1. Adds a negative bit and corresponding new API (`is_neg()`,`resolve_neg()`)
2. `tensor.conj().imag` now returns a floating point tensor with neg bit set to 1 instead of a tensor with no notion of negative bit. Note that imag is still a view and all the view properties still hold for imag.

Non user facing changes:
1. Added a new Negative dispatch key and a backend fallback to handle it
2. Updated copy kernel to handle negative bit
3. Merged conjugate and negative bit fallback kernel
4. fixed #60478 (caused due to #54987)

Testing:
1. Added a new OpInfo based test `test_neg_view` (verifies that out-of-place and in-place operations work correctly for all operations when the input is a neg view tensor by checking the result against an actually negated tensor, verifies that autograd returns the same output for both neg view and actually negated tensors as well as it works fine when grad_out is a neg view).
2. Added a new test class containing `test_conj_view`, `test_neg_view`. 

Differential Revision: [](https://our.internmc.facebook.com/intern/diff/)

[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Jul 9, 2021
User facing changes:
1. Adds a negative bit and corresponding new API (`is_neg()`,`resolve_neg()`)
2. `tensor.conj().imag` now returns a floating point tensor with neg bit set to 1 instead of a tensor with no notion of negative bit. Note that imag is still a view and all the view properties still hold for imag.

Non user facing changes:
1. Added a new Negative dispatch key and a backend fallback to handle it
2. Updated copy kernel to handle negative bit
3. Merged conjugate and negative bit fallback kernel
4. fixed #60478 (caused due to #54987)

Testing:
1. Added a new OpInfo based test `test_neg_view` (verifies that out-of-place and in-place operations work correctly for all operations when the input is a neg view tensor by checking the result against an actually negated tensor, verifies that autograd returns the same output for both neg view and actually negated tensors as well as it works fine when grad_out is a neg view).
2. Added a new test class containing `test_conj_view`, `test_neg_view`. 

Differential Revision: [](https://our.internmc.facebook.com/intern/diff/)

Differential Revision: [D29636403](https://our.internmc.facebook.com/intern/diff/D29636403)

[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Jul 9, 2021
User facing changes:
1. Adds a negative bit and corresponding new API (`is_neg()`,`resolve_neg()`)
2. `tensor.conj().imag` now returns a floating point tensor with neg bit set to 1 instead of a tensor with no notion of negative bit. Note that imag is still a view and all the view properties still hold for imag.

Non user facing changes:
1. Added a new Negative dispatch key and a backend fallback to handle it
2. Updated copy kernel to handle negative bit
3. Merged conjugate and negative bit fallback kernel
4. fixed #60478 (caused due to #54987)

Testing:
1. Added a new OpInfo based test `test_neg_view` (verifies that out-of-place and in-place operations work correctly for all operations when the input is a neg view tensor by checking the result against an actually negated tensor, verifies that autograd returns the same output for both neg view and actually negated tensors as well as it works fine when grad_out is a neg view).
2. Added a new test class containing `test_conj_view`, `test_neg_view`. 

Differential Revision: [](https://our.internmc.facebook.com/intern/diff/)

Differential Revision: [D29636403](https://our.internmc.facebook.com/intern/diff/D29636403)

[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Jul 9, 2021
User facing changes:
1. Adds a negative bit and corresponding new API (`is_neg()`,`resolve_neg()`)
2. `tensor.conj().imag` now returns a floating point tensor with neg bit set to 1 instead of a tensor with no notion of negative bit. Note that imag is still a view and all the view properties still hold for imag.

Non user facing changes:
1. Added a new Negative dispatch key and a backend fallback to handle it
2. Updated copy kernel to handle negative bit
3. Merged conjugate and negative bit fallback kernel
4. fixed #60478 (caused due to #54987)

Testing:
1. Added a new OpInfo based test `test_neg_view` (verifies that out-of-place and in-place operations work correctly for all operations when the input is a neg view tensor by checking the result against an actually negated tensor, verifies that autograd returns the same output for both neg view and actually negated tensors as well as it works fine when grad_out is a neg view).
2. Added a new test class containing `test_conj_view`, `test_neg_view`. 

Differential Revision: [](https://our.internmc.facebook.com/intern/diff/)

Differential Revision: [D29636403](https://our.internmc.facebook.com/intern/diff/D29636403)

[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Jul 9, 2021
User facing changes:
1. Adds a negative bit and corresponding new API (`is_neg()`,`resolve_neg()`)
2. `tensor.conj().imag` now returns a floating point tensor with neg bit set to 1 instead of a tensor with no notion of negative bit. Note that imag is still a view and all the view properties still hold for imag.

Non user facing changes:
1. Added a new Negative dispatch key and a backend fallback to handle it
2. Updated copy kernel to handle negative bit
3. Merged conjugate and negative bit fallback kernel
4. fixed #60478 (caused due to #54987)

Testing:
1. Added a new OpInfo based test `test_neg_view` (verifies that out-of-place and in-place operations work correctly for all operations when the input is a neg view tensor by checking the result against an actually negated tensor, verifies that autograd returns the same output for both neg view and actually negated tensors as well as it works fine when grad_out is a neg view).
2. Added a new test class containing `test_conj_view`, `test_neg_view`. 

Differential Revision: [](https://our.internmc.facebook.com/intern/diff/)

Differential Revision: [D29636403](https://our.internmc.facebook.com/intern/diff/D29636403)

[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Jul 9, 2021
User facing changes:
1. Adds a negative bit and corresponding new API (`is_neg()`,`resolve_neg()`)
2. `tensor.conj().imag` now returns a floating point tensor with neg bit set to 1 instead of a tensor with no notion of negative bit. Note that imag is still a view and all the view properties still hold for imag.

Non user facing changes:
1. Added a new Negative dispatch key and a backend fallback to handle it
2. Updated copy kernel to handle negative bit
3. Merged conjugate and negative bit fallback kernel
4. fixed #60478 (caused due to #54987)

Testing:
1. Added a new OpInfo based test `test_neg_view` (verifies that out-of-place and in-place operations work correctly for all operations when the input is a neg view tensor by checking the result against an actually negated tensor, verifies that autograd returns the same output for both neg view and actually negated tensors as well as it works fine when grad_out is a neg view).
2. Added a new test class containing `test_conj_view`, `test_neg_view`. 

Differential Revision: [](https://our.internmc.facebook.com/intern/diff/)

Differential Revision: [D29636403](https://our.internmc.facebook.com/intern/diff/D29636403)

[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Jul 9, 2021
User facing changes:
1. Adds a negative bit and corresponding new API (`is_neg()`,`resolve_neg()`)
2. `tensor.conj().imag` now returns a floating point tensor with neg bit set to 1 instead of a tensor with no notion of negative bit. Note that imag is still a view and all the view properties still hold for imag.

Non user facing changes:
1. Added a new Negative dispatch key and a backend fallback to handle it
2. Updated copy kernel to handle negative bit
3. Merged conjugate and negative bit fallback kernel
4. fixed #60478 (caused due to #54987)

Testing:
1. Added a new OpInfo based test `test_neg_view` (verifies that out-of-place and in-place operations work correctly for all operations when the input is a neg view tensor by checking the result against an actually negated tensor, verifies that autograd returns the same output for both neg view and actually negated tensors as well as it works fine when grad_out is a neg view).
2. Added a new test class containing `test_conj_view`, `test_neg_view`. 

Differential Revision: [](https://our.internmc.facebook.com/intern/diff/)

Differential Revision: [D29636403](https://our.internmc.facebook.com/intern/diff/D29636403)

[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Jul 11, 2021
User facing changes:
1. Adds a negative bit and corresponding new API (`is_neg()`,`resolve_neg()`)
2. `tensor.conj().imag` now returns a floating point tensor with neg bit set to 1 instead of a tensor with no notion of negative bit. Note that imag is still a view and all the view properties still hold for imag.

Non user facing changes:
1. Added a new Negative dispatch key and a backend fallback to handle it
2. Updated copy kernel to handle negative bit
3. Merged conjugate and negative bit fallback kernel
4. fixed #60478 (caused due to #54987)

Testing:
1. Added a new OpInfo based test `test_neg_view` (verifies that out-of-place and in-place operations work correctly for all operations when the input is a neg view tensor by checking the result against an actually negated tensor, verifies that autograd returns the same output for both neg view and actually negated tensors as well as it works fine when grad_out is a neg view).
2. Added a new test class containing `test_conj_view`, `test_neg_view`. 

Differential Revision: [](https://our.internmc.facebook.com/intern/diff/)

Differential Revision: [D29636403](https://our.internmc.facebook.com/intern/diff/D29636403)

[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Jul 11, 2021
User facing changes:
1. Adds a negative bit and corresponding new API (`is_neg()`,`resolve_neg()`)
2. `tensor.conj().imag` now returns a floating point tensor with neg bit set to 1 instead of a tensor with no notion of negative bit. Note that imag is still a view and all the view properties still hold for imag.

Non user facing changes:
1. Added a new Negative dispatch key and a backend fallback to handle it
2. Updated copy kernel to handle negative bit
3. Merged conjugate and negative bit fallback kernel
4. fixed #60478 (caused due to #54987)

Testing:
1. Added a new OpInfo based test `test_neg_view` (verifies that out-of-place and in-place operations work correctly for all operations when the input is a neg view tensor by checking the result against an actually negated tensor, verifies that autograd returns the same output for both neg view and actually negated tensors as well as it works fine when grad_out is a neg view).
2. Added a new test class containing `test_conj_view`, `test_neg_view`. 

Differential Revision: [](https://our.internmc.facebook.com/intern/diff/)

Differential Revision: [D29636403](https://our.internmc.facebook.com/intern/diff/D29636403)

[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Jul 12, 2021
User facing changes:
1. Adds a negative bit and corresponding new API (`is_neg()`,`resolve_neg()`)
2. `tensor.conj().imag` now returns a floating point tensor with neg bit set to 1 instead of a tensor with no notion of negative bit. Note that imag is still a view and all the view properties still hold for imag.

Non user facing changes:
1. Added a new Negative dispatch key and a backend fallback to handle it
2. Updated copy kernel to handle negative bit
3. Merged conjugate and negative bit fallback kernel
4. fixed #60478 (caused due to #54987)

Testing:
1. Added a new OpInfo based test `test_neg_view` (verifies that out-of-place and in-place operations work correctly for all operations when the input is a neg view tensor by checking the result against an actually negated tensor, verifies that autograd returns the same output for both neg view and actually negated tensors as well as it works fine when grad_out is a neg view).
2. Added a new test class containing `test_conj_view`, `test_neg_view`. 

Differential Revision: [](https://our.internmc.facebook.com/intern/diff/)

Differential Revision: [D29636403](https://our.internmc.facebook.com/intern/diff/D29636403)

[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Jul 12, 2021
User facing changes:
1. Adds a negative bit and corresponding new API (`is_neg()`,`resolve_neg()`)
2. `tensor.conj().imag` now returns a floating point tensor with neg bit set to 1 instead of a tensor with no notion of negative bit. Note that imag is still a view and all the view properties still hold for imag.

Non user facing changes:
1. Added a new Negative dispatch key and a backend fallback to handle it
2. Updated copy kernel to handle negative bit
3. Merged conjugate and negative bit fallback kernel
4. fixed #60478 (caused due to #54987)

Testing:
1. Added a new OpInfo based test `test_neg_view` (verifies that out-of-place and in-place operations work correctly for all operations when the input is a neg view tensor by checking the result against an actually negated tensor, verifies that autograd returns the same output for both neg view and actually negated tensors as well as it works fine when grad_out is a neg view).
2. Added a new test class containing `test_conj_view`, `test_neg_view`. 

Differential Revision: [](https://our.internmc.facebook.com/intern/diff/)

Differential Revision: [D29636403](https://our.internmc.facebook.com/intern/diff/D29636403)

[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Jul 12, 2021
User facing changes:
1. Adds a negative bit and corresponding new API (`is_neg()`,`resolve_neg()`)
2. `tensor.conj().imag` now returns a floating point tensor with neg bit set to 1 instead of a tensor with no notion of negative bit. Note that imag is still a view and all the view properties still hold for imag.

Non user facing changes:
1. Added a new Negative dispatch key and a backend fallback to handle it
2. Updated copy kernel to handle negative bit
3. Merged conjugate and negative bit fallback kernel
4. fixed #60478 (caused due to #54987)

Testing:
1. Added a new OpInfo based test `test_neg_view` (verifies that out-of-place and in-place operations work correctly for all operations when the input is a neg view tensor by checking the result against an actually negated tensor, verifies that autograd returns the same output for both neg view and actually negated tensors as well as it works fine when grad_out is a neg view).
2. Added a new test class containing `test_conj_view`, `test_neg_view`. 

Differential Revision: [](https://our.internmc.facebook.com/intern/diff/)

Differential Revision: [D29636403](https://our.internmc.facebook.com/intern/diff/D29636403)

[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Jul 12, 2021
User facing changes:
1. Adds a negative bit and corresponding new API (`is_neg()`,`resolve_neg()`)
2. `tensor.conj().imag` now returns a floating point tensor with neg bit set to 1 instead of a tensor with no notion of negative bit. Note that imag is still a view and all the view properties still hold for imag.

Non user facing changes:
1. Added a new Negative dispatch key and a backend fallback to handle it
2. Updated copy kernel to handle negative bit
3. Merged conjugate and negative bit fallback kernel
4. fixed #60478 (caused due to #54987)

Testing:
1. Added a new OpInfo based test `test_neg_view` (verifies that out-of-place and in-place operations work correctly for all operations when the input is a neg view tensor by checking the result against an actually negated tensor, verifies that autograd returns the same output for both neg view and actually negated tensors as well as it works fine when grad_out is a neg view).
2. Added a new test class containing `test_conj_view`, `test_neg_view`. 

Differential Revision: [](https://our.internmc.facebook.com/intern/diff/)

Differential Revision: [D29636403](https://our.internmc.facebook.com/intern/diff/D29636403)

[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Jul 12, 2021
User facing changes:
1. Adds a negative bit and corresponding new API (`is_neg()`,`resolve_neg()`)
2. `tensor.conj().imag` now returns a floating point tensor with neg bit set to 1 instead of a tensor with no notion of negative bit. Note that imag is still a view and all the view properties still hold for imag.

Non user facing changes:
1. Added a new Negative dispatch key and a backend fallback to handle it
2. Updated copy kernel to handle negative bit
3. Merged conjugate and negative bit fallback kernel
4. fixed #60478 (caused due to #54987)

Testing:
1. Added a new OpInfo based test `test_neg_view` (verifies that out-of-place and in-place operations work correctly for all operations when the input is a neg view tensor by checking the result against an actually negated tensor, verifies that autograd returns the same output for both neg view and actually negated tensors as well as it works fine when grad_out is a neg view).
2. Added a new test class containing `test_conj_view`, `test_neg_view`. 

Differential Revision: [](https://our.internmc.facebook.com/intern/diff/)

Differential Revision: [D29636403](https://our.internmc.facebook.com/intern/diff/D29636403)

[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Jul 12, 2021
User facing changes:
1. Adds a negative bit and corresponding new API (`is_neg()`,`resolve_neg()`)
2. `tensor.conj().imag` now returns a floating point tensor with neg bit set to 1 instead of a tensor with no notion of negative bit. Note that imag is still a view and all the view properties still hold for imag.

Non user facing changes:
1. Added a new Negative dispatch key and a backend fallback to handle it
2. Updated copy kernel to handle negative bit
3. Merged conjugate and negative bit fallback kernel
4. fixed #60478 (caused due to #54987)

Testing:
1. Added a new OpInfo based test `test_neg_view` (verifies that out-of-place and in-place operations work correctly for all operations when the input is a neg view tensor by checking the result against an actually negated tensor, verifies that autograd returns the same output for both neg view and actually negated tensors as well as it works fine when grad_out is a neg view).
2. Added a new test class containing `test_conj_view`, `test_neg_view`. 

Differential Revision: [](https://our.internmc.facebook.com/intern/diff/)

Differential Revision: [D29636403](https://our.internmc.facebook.com/intern/diff/D29636403)

[ghstack-poisoned]
facebook-github-bot pushed a commit that referenced this pull request Jul 13, 2021
Summary:
Pull Request resolved: #56058

User facing changes:
1. Adds a negative bit and corresponding new API (`is_neg()`,`resolve_neg()`)
2. `tensor.conj().imag` now returns a floating point tensor with neg bit set to 1 instead of a tensor with no notion of negative bit. Note that imag is still a view and all the view properties still hold for imag.

Non user facing changes:
1. Added a new Negative dispatch key and a backend fallback to handle it
2. Updated copy kernel to handle negative bit
3. Merged conjugate and negative bit fallback kernel
4. fixed #60478 (caused due to #54987)

Testing:
1. Added a new OpInfo based test `test_neg_view` (verifies that out-of-place and in-place operations work correctly for all operations when the input is a neg view tensor by checking the result against an actually negated tensor, verifies that autograd returns the same output for both neg view and actually negated tensors as well as it works fine when grad_out is a neg view).
2. Added a new test class containing `test_conj_view`, `test_neg_view`.

Test Plan: Imported from OSS

Reviewed By: soulitzer

Differential Revision: D29636403

fbshipit-source-id: 12214c9dc4806c51850f4a72a109db9527c0ca63
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla signed Merged module: bc-breaking Related to a BC-breaking change module: complex Related to complex number support in PyTorch oncall: jit Add this issue/PR to JIT oncall triage queue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants