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

Method/constructor which takes as input angle and magnitude and returns a complex tensor #35312

Open
anjali411 opened this issue Mar 24, 2020 · 10 comments

Comments

@anjali411
Copy link
Contributor

@anjali411 anjali411 commented Mar 24, 2020

@anjali411 anjali411 changed the title Method/constructor which takes as input a tensor containing angles and magnitude and returns a complex tensor Method/constructor which takes as input angle and magnitude and returns a complex tensor Mar 24, 2020
@anjali411 anjali411 mentioned this issue Mar 24, 2020
13 of 46 tasks complete
@albanD albanD added the triaged label Mar 24, 2020
@kostekIV
Copy link
Contributor

@kostekIV kostekIV commented Mar 26, 2020

Hello, I would like to work on this, can I? If so, what is a good place for this functionality?

@dylanbespalko
Copy link
Contributor

@dylanbespalko dylanbespalko commented Mar 26, 2020

@kostekIV,

Here is a short range vs. long range solution to get you into PyTorch development. I've added some links to some relevant files you will need to change.

Short Range Solution: Add a polar() and cart() math kernels.

  1. Learn how to register a new math kernel in PyTorch.
  2. Implement the non-vectorized math kernels
  1. Implement the vectorized math kernels

Long Range Solution: Add ComplexPolarFloat dtype

The short range solution does not provide PyTorch with the knowledge that your complex number is in polar or cartesian coordinates. Hence all operators currently assume cartesian coordinates. We have started to discuss adding a Complex Polar dtype.

  1. Work with fb to add a new polar dtypes (ComplexPolarHalf, ComplexPolarFloat, ComplexPolarDouble).
  2. Add math kernels to the ComplexPolar Dtype to solve this issue.
    • Vectorized: Create a new vec256 file aten/src/ATen/cpu/vec256/vec256_complex_polar float.h

I would just focus on the short-range solution for now, but I think we need the long-range solution to speed up some of these computations.

@kostekIV
Copy link
Contributor

@kostekIV kostekIV commented Mar 26, 2020

@dylanbespalko
Thank you for such a comprehensive explanation. I will start with short range solution.

@ezyang
Copy link
Contributor

@ezyang ezyang commented Mar 27, 2020

For reference, Numpy doesn't seem to have this yet: numpy/numpy#5228

@dylanbespalko
Copy link
Contributor

@dylanbespalko dylanbespalko commented Mar 27, 2020

@ezyang
Correct, numpy does not support polar() or cart() and perhaps these kernels should stay undocumented in the short-range solution.

The long-range solution of creating a ComplexPolarFloat dtype will likely run into a problem where the cast operation ComplexFloat.to(ComplexPolarFloat) performs a Scalar cast that does not benefit from vectorization.

Hence, the end-goal here should be to implement a vectorized polar() and cart() private method that is only used inside the Vec256 class when ComplexFloat or ComplexPolarFloat has to change coordinate systems.

@kostekIV

#35524 contains some new files that you should be aware of.

@wjgan7
Copy link
Contributor

@wjgan7 wjgan7 commented Jun 3, 2020

Hi, is there any update on this? I'd also like to help if possible.

@anjali411
Copy link
Contributor Author

@anjali411 anjali411 commented Jun 4, 2020

Hi @wjgan7 this task is still open, so feel free to start working on it. I think we wanna go with the API mentioned here, which is similar to API that tensorflow and matlab have as well. Check out the wiki and contribution-guide and ping me if you have any questions!

@wjgan7
Copy link
Contributor

@wjgan7 wjgan7 commented Jun 4, 2020

Great! Is the best place to ask questions in this issue?

@anjali411
Copy link
Contributor Author

@anjali411 anjali411 commented Jun 5, 2020

yeah!

@ShivamSRS
Copy link

@ShivamSRS ShivamSRS commented Jun 27, 2020

hey @anjali411 I want to start contributing to pytorch and noticed that this is a good first issue, however i am using a windows device, will it be possible? Also is there any discussion forum like slack for pytorch where others can help me try contributing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
7 participants
You can’t perform that action at this time.