-
Notifications
You must be signed in to change notification settings - Fork 21.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added type promotion logic for complex numbers (#34093)
Summary: Issue: #33780 After this PR: 1. dtype promotion logic will correctly work for ops involving complex scalars 2. added alias for complex64 (cfloat) and complex128 (cdouble) 3. added an internal function get_complex_default_dtype (consciously not exposed in public API) - sets the default complex dtype to be double if default_dtype is set to double, else float #34093 (comment) >>> 1j*torch.ones(2) tensor([(0.0000 + 1.0000j), (0.0000 + 1.0000j)], dtype=torch.complex64) >>> torch.set_default_dtype(torch.float64) >>> 1j*torch.ones(2) tensor([(0.0000 + 1.0000j), (0.0000 + 1.0000j)], dtype=torch.complex128) >>> 1j + torch.ones(2) tensor([(1.0000 + 1.0000j), (1.0000 + 1.0000j)], dtype=torch.complex128) >>> torch.tensor(1j) + torch.ones(2,2) tensor([[(1.0000 + 1.0000j), (1.0000 + 1.0000j)], [(1.0000 + 1.0000j), (1.0000 + 1.0000j)]], dtype=torch.complex128) Pull Request resolved: #34093 Differential Revision: D20537125 Pulled By: anjali411 fbshipit-source-id: 05fb1f81b8ba039d0b698cdd2c0bbf8b0ce0b767
- Loading branch information
1 parent
361eed6
commit c73e970
Showing
9 changed files
with
104 additions
and
27 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
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
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