Skip to content

Improve complex support in common_nn test machinery#50593

Closed
peterbell10 wants to merge 8 commits intogh/peterbell10/41/basefrom
gh/peterbell10/41/head
Closed

Improve complex support in common_nn test machinery#50593
peterbell10 wants to merge 8 commits intogh/peterbell10/41/basefrom
gh/peterbell10/41/head

Conversation

@peterbell10
Copy link
Copy Markdown
Collaborator

@peterbell10 peterbell10 commented Jan 15, 2021

Stack from ghstack:

There are no equivalent to torch.FloatTensor, torch.cuda.FloatTensor for complex
types. So get_gpu_type and get_cpu_type are broken for complex tensors.

Also found a few places that explicitly cast inputs to floating point types,
which would drop the imaginary component before running the test.

Differential Revision: D25954050

There are no equivalent to torch.FloatTensor, torch.cuda.FloatTensor for complex
types. So `get_gpu_type` and `get_cpu_type` are broken for complex tensors.

Also found a few places that explicitly cast inputs to floating point types,
which would drop the imaginary component before running the test.

[ghstack-poisoned]
There are no equivalent to torch.FloatTensor, torch.cuda.FloatTensor for complex
types. So `get_gpu_type` and `get_cpu_type` are broken for complex tensors.

Also found a few places that explicitly cast inputs to floating point types,
which would drop the imaginary component before running the test.

[ghstack-poisoned]
@peterbell10 peterbell10 requested a review from mruberry January 15, 2021 18:43
@anjali411 anjali411 added the module: complex Related to complex number support in PyTorch label Jan 15, 2021
@anjali411
Copy link
Copy Markdown
Contributor

we had a similar discussion in this PR adding complex support for L1 loss function #49912

Comment thread torch/testing/_internal/common_utils.py Outdated
else:
return tensor

def to_half(x):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think we should add to_half for complex tensors, since the support for torch.complex32 is bare minimum right now. In fact, @mruberry and I both agreed we should probably disable torch.complex32 for 1.8 release.

There are no equivalent to torch.FloatTensor, torch.cuda.FloatTensor for complex
types. So `get_gpu_type` and `get_cpu_type` are broken for complex tensors.

Also found a few places that explicitly cast inputs to floating point types,
which would drop the imaginary component before running the test.

[ghstack-poisoned]
@peterbell10
Copy link
Copy Markdown
Collaborator Author

Rebased on #49912 after it was merged and removed the reference to torch.complex32.

There are no equivalent to torch.FloatTensor, torch.cuda.FloatTensor for complex
types. So `get_gpu_type` and `get_cpu_type` are broken for complex tensors.

Also found a few places that explicitly cast inputs to floating point types,
which would drop the imaginary component before running the test.

[ghstack-poisoned]
There are no equivalent to torch.FloatTensor, torch.cuda.FloatTensor for complex
types. So `get_gpu_type` and `get_cpu_type` are broken for complex tensors.

Also found a few places that explicitly cast inputs to floating point types,
which would drop the imaginary component before running the test.

[ghstack-poisoned]
Copy link
Copy Markdown
Collaborator

@mruberry mruberry left a comment

Choose a reason for hiding this comment

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

Looks OK to me. Let's let @anjali411 take a look, too.

Copy link
Copy Markdown
Contributor

@anjali411 anjali411 left a comment

Choose a reason for hiding this comment

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

LGTM!

peterbell10 and others added 2 commits January 19, 2021 19:53
There are no equivalent to torch.FloatTensor, torch.cuda.FloatTensor for complex
types. So `get_gpu_type` and `get_cpu_type` are broken for complex tensors.

Also found a few places that explicitly cast inputs to floating point types,
which would drop the imaginary component before running the test.

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

[ghstack-poisoned]
There are no equivalent to torch.FloatTensor, torch.cuda.FloatTensor for complex
types. So `get_gpu_type` and `get_cpu_type` are broken for complex tensors.

Also found a few places that explicitly cast inputs to floating point types,
which would drop the imaginary component before running the test.

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

[ghstack-poisoned]
peterbell10 pushed a commit to peterbell10/pytorch that referenced this pull request Jan 21, 2021
There are no equivalent to torch.FloatTensor, torch.cuda.FloatTensor for complex
types. So `get_gpu_type` and `get_cpu_type` are broken for complex tensors.

Also found a few places that explicitly cast inputs to floating point types,
which would drop the imaginary component before running the test.

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

[ghstack-poisoned]
input = input + (kwargs['target_fn'](),)

args_variable, kwargs_variable = create_input(input)
args_variable, kwargs_variable = create_input(input, dtype=input_dtype)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@anjali411 this should fix the test failure in #50594.

@facebook-github-bot
Copy link
Copy Markdown
Contributor

@mruberry merged this pull request in 47f0bda.

@facebook-github-bot facebook-github-bot deleted the gh/peterbell10/41/head branch January 26, 2021 15:21
laurentdupin pushed a commit to laurentdupin/pytorch that referenced this pull request Apr 24, 2026
Summary:
Pull Request resolved: pytorch#50593

There are no equivalent to torch.FloatTensor, torch.cuda.FloatTensor for complex
types. So `get_gpu_type` and `get_cpu_type` are broken for complex tensors.

Also found a few places that explicitly cast inputs to floating point types,
which would drop the imaginary component before running the test.

Test Plan: Imported from OSS

Reviewed By: ngimel

Differential Revision: D25954050

Pulled By: mruberry

fbshipit-source-id: 1fa8e5af233aa095c839d5e2f860564baaf92aef
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla signed Merged module: complex Related to complex number support in PyTorch open source

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants