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
[profiler] use PyCFunction_Check to check both PyCMethod_Type and PyC… #110002
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/110002
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit ae9368e with merge base 52e1478 (): This comment was automatically generated by Dr. CI and updates every 15 minutes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okey
@pytorchbot merge -r main |
@pytorchbot started a rebase job onto refs/remotes/origin/main. Check the current status here |
Successfully rebased |
c70946f
to
5ab6d47
Compare
Merge failedReason: This PR needs a If not, please add the To add a label, you can comment to pytorchbot, for example For more information, see Details for Dev Infra teamRaised by workflow job |
@pytorchbot merge |
Merge startedYour 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 |
Merge failedReason: 1 jobs have failed, first few of them are: trunk / linux-focal-rocm5.6-py3.8 / test (default, 1, 3, linux.rocm.gpu) Details for Dev Infra teamRaised by workflow job |
@pytorchbot merge -r main |
@pytorchbot started a rebase job onto refs/remotes/origin/main. Check the current status here |
Successfully rebased |
5ab6d47
to
ae9368e
Compare
Merge startedYour 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 |
pytorch#110002) At https://github.com/pytorch/pytorch/blob/main/torch/csrc/autograd/profiler_python.cpp#L1096, when what is PyTrace_C_CALL, Py_TYPE(arg) only can be PyCFunction_Type before python3.9. But in python3.9 or later, Py_TYPE(arg) also can be PyCMethod_Type. PyCMethod_Type is subtype of PyCFunction_Type, ref to https://github.com/python/cpython/blob/f2eaa92b0cc5a37a9e6010c7c6f5ad1a230ea49b/Objects/methodobject.c#L372. So there should use PyCFunction_Check to check arg->ob_type. Fixes pytorch#109877 Pull Request resolved: pytorch#110002 Approved by: https://github.com/ezyang
At https://github.com/pytorch/pytorch/blob/main/torch/csrc/autograd/profiler_python.cpp#L1096, when what is PyTrace_C_CALL, Py_TYPE(arg) only can be PyCFunction_Type before python3.9. But in python3.9 or later, Py_TYPE(arg) also can be PyCMethod_Type.
PyCMethod_Type is subtype of PyCFunction_Type, ref to
https://github.com/python/cpython/blob/f2eaa92b0cc5a37a9e6010c7c6f5ad1a230ea49b/Objects/methodobject.c#L372.
So there should use PyCFunction_Check to check arg->ob_type.
Fixes #109877