-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Fix sign-compare violations in torch_python #75079
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
Conversation
Prerequisite change for enabling `-Werror=sign-compare` across PyTorch repo [ghstack-poisoned]
🔗 Helpful links
💊 CI failures summary and remediationsAs of commit 503ebab (more details on the Dr. CI page): 💚 💚 Looks good so far! There are no failures yet. 💚 💚 This comment was automatically generated by Dr. CI (expand for details).Please report bugs/suggestions to the (internal) Dr. CI Users group. |
torch/csrc/utils/tensor_numpy.cpp
Outdated
| PyObject *py_strides = PyDict_GetItemString(cuda_dict, "strides"); | ||
| if (py_strides != nullptr && py_strides != Py_None) { | ||
| if (PySequence_Length(py_strides) == -1 || PySequence_Length(py_strides) != sizes.size()) { | ||
| if (PySequence_Length(py_strides) == -1 || PySequence_Length(py_strides) != static_cast<Py_ssize_t>(sizes.size())) { |
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.
Don't we prefer to cast the result of PySequence_Length to size_t?
From a quick search, looks like Py_ssize_t is a int only.
Prerequisite change for enabling `-Werror=sign-compare` across PyTorch repo [ghstack-poisoned]
albanD
left a comment
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.
Thanks for the update!
Summary: Prerequisite change for enabling `-Werror=sign-compare` across PyTorch repo Pull Request resolved: #75079 Approved by: https://github.com/albanD Test Plan: contbuild & OSS CI, see https://hud.pytorch.org/commit/pytorch/pytorch/c593c220ff8ecbadf065acc1bd74661bba2dc2bf Reviewed By: seemethere, b0noI Differential Revision: D35404324 Pulled By: malfet fbshipit-source-id: ae08bf80fd280d0e7aca96a4747dbc888ec4adb4
Stack from ghstack:
-Wsign-compareto list of clang flags #75085c10d/Utils.hpp#75081Prerequisite change for enabling
-Werror=sign-compareacross PyTorch repo