Skip to content

Conversation

YangQun1
Copy link
Contributor

@YangQun1 YangQun1 commented Apr 25, 2024

This PR is to add support for tensor's is_complex method in dynamo. Take the following code as an example:

   def test_tensor_is_complex(x):
        if x.is_complex():
            return x + 1
        else:
            return x - 1

Before this fix, the is_complex() call will cause a graph break "torch.* op returned non-Tensor bool call_method is_complex". After this fix, the graph break can be avoided.

Fixes #122692

cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @chenyang78 @kadeng @chauhang

Copy link

pytorch-bot bot commented Apr 25, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/124927

Note: Links to docs will display an error until the docs builds have been completed.

✅ You can merge normally! (2 Unrelated Failures)

As of commit 1f46fad with merge base 7a6813b (image):

FLAKY - The following job failed but was likely due to flakiness present on trunk:

BROKEN TRUNK - The following job failed but was present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

This comment was automatically generated by Dr. CI and updates every 15 minutes.

Copy link

linux-foundation-easycla bot commented Apr 25, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@YangQun1 YangQun1 force-pushed the dynamo-add-support-is_complex branch from 94dfbcc to 03a0017 Compare April 25, 2024 10:37
@ezyang
Copy link
Contributor

ezyang commented Apr 25, 2024

fix lint please

@ezyang ezyang added ciflow/trunk Trigger trunk jobs on your pull request topic: bug fixes topic category release notes: dynamo labels Apr 25, 2024
@ezyang
Copy link
Contributor

ezyang commented Apr 26, 2024

@pytorchbot merge

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

petrex pushed a commit to petrex/pytorch that referenced this pull request May 3, 2024
This PR is to add support for tensor's is_complex method in dynamo. Take the following code as an example:
```python
   def test_tensor_is_complex(x):
        if x.is_complex():
            return x + 1
        else:
            return x - 1
```
Before this fix, the is_complex() call will cause a graph break "torch.* op returned non-Tensor bool call_method is_complex". After this fix, the graph break can be avoided.

Fixes pytorch#122692

Pull Request resolved: pytorch#124927
Approved by: https://github.com/ezyang
@IlyasMoutawwakil
Copy link
Contributor

Hi @ezyang I see many of PRs adding support for tensor methods that are not returning a tensor, is there a way to do this from the user side when implementing a similar method in a tensor wrapper subclass ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"torch._dynamo.exc.Unsupported: torch.* op returned non-Tensor bool call_method is_complex" error

5 participants