Skip to content
This repository was archived by the owner on Aug 1, 2025. It is now read-only.

extend __torch_function__ support to call_method#181

Merged
vkuzo merged 1 commit intomainfrom
tf_call_method
Apr 27, 2022
Merged

extend __torch_function__ support to call_method#181
vkuzo merged 1 commit intomainfrom
tf_call_method

Conversation

@vkuzo
Copy link
Copy Markdown
Contributor

@vkuzo vkuzo commented Apr 26, 2022

Summary:

In #167 we added __torch_function__
support for tracing through call_function.

This PR extends the support to also work on call_method.

Note: the LOC is high because some code was refactored to be reusable.
Note: implementing correct rewrapping logic for methods is saved for a
future PR, hope that's OK.

Test plan:

pytest -vsk test_simple_torch_function

Comment thread torchdynamo/utils.py Outdated
@vkuzo vkuzo force-pushed the tf_call_method branch 2 times, most recently from d07473b to 28f92b3 Compare April 26, 2022 15:14
Copy link
Copy Markdown
Contributor

@jansel jansel left a comment

Choose a reason for hiding this comment

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

Overall looks good. A few minor comments.

Comment thread torchdynamo/utils.py Outdated
Comment thread torchdynamo/variables/tensor.py
Summary:

In #167 we added `__torch_function__`
support for tracing through `call_function`.

This PR extends the support to also work on `call_method`.

Note: the LOC is high because some code was refactored to be reusable.
Note: implementing correct rewrapping logic for methods is saved for a
future PR, hope that's OK.

Test plan:

```
pytest -vsk test_simple_torch_function
```
@vkuzo vkuzo requested a review from jansel April 27, 2022 00:42
@vkuzo vkuzo merged commit 378db08 into main Apr 27, 2022
@jansel jansel deleted the tf_call_method branch August 23, 2022 22:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants