Skip to content

Fix Signed-Unsigned Comparison in Tensor Utils #4279

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

Closed
wants to merge 1 commit into from

Conversation

wenxin0319
Copy link
Contributor

Summary:
Resolved warnings caused by comparisons between signed and unsigned integers in tensor_utils.h. Changed the loop index variable i from int to size_t to match the type of sizes.size(), ensuring consistent and safe comparisons. This change eliminates the -Wsign-compare warnings during compilation.

The original error message here:

buck-out/v2/gen/fbcode/b43bb943fef57626/deeplearning/fbgemm/fbgemm_gpu/__fbgemm_gpu_cpu__/buck-headers/fbgemm_gpu/utils/tensor_utils.h:53:20: error: comparison of integers of different signs: 'int' and 'size_t' (aka 'unsigned long') [-Werror,-Wsign-compare]
   53 | for (auto i = 0; i < sizes.size(); ++i) {
      |                  ~ ^ ~~~~~~~~~~~~
buck-out/v2/gen/fbcode/b43bb943fef57626/deeplearning/fbgemm/fbgemm_gpu/__fbgemm_gpu_cpu__/buck-headers/fbgemm_gpu/utils/tensor_utils.h:55:7: error: comparison of integers of different signs: 'int' and 'size_t' (aka 'unsigned long') [-Werror,-Wsign-compare]
   55 | if (i != (sizes.size() - (1))) {
      |     ~ ^   ~~~~~~~~~~~~~~~~~~
2 errors generated.

Differential Revision: D76093914

Copy link

netlify bot commented Jun 6, 2025

Deploy Preview for pytorch-fbgemm-docs ready!

Name Link
🔨 Latest commit 2e9c523
🔍 Latest deploy log https://app.netlify.com/projects/pytorch-fbgemm-docs/deploys/68423a8fee42a70008e5e554
😎 Deploy Preview https://deploy-preview-4279--pytorch-fbgemm-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D76093914

wenxin0319 added a commit to wenxin0319/FBGEMM-1 that referenced this pull request Jun 6, 2025
Summary:

Resolved warnings caused by comparisons between signed and unsigned integers in tensor_utils.h. Changed the loop index variable i from int to size_t to match the type of sizes.size(), ensuring consistent and safe comparisons. This change eliminates the -Wsign-compare warnings during compilation.

The original error message here:
```
buck-out/v2/gen/fbcode/b43bb943fef57626/deeplearning/fbgemm/fbgemm_gpu/__fbgemm_gpu_cpu__/buck-headers/fbgemm_gpu/utils/tensor_utils.h:53:20: error: comparison of integers of different signs: 'int' and 'size_t' (aka 'unsigned long') [-Werror,-Wsign-compare]
   53 | for (auto i = 0; i < sizes.size(); ++i) {
      |                  ~ ^ ~~~~~~~~~~~~
buck-out/v2/gen/fbcode/b43bb943fef57626/deeplearning/fbgemm/fbgemm_gpu/__fbgemm_gpu_cpu__/buck-headers/fbgemm_gpu/utils/tensor_utils.h:55:7: error: comparison of integers of different signs: 'int' and 'size_t' (aka 'unsigned long') [-Werror,-Wsign-compare]
   55 | if (i != (sizes.size() - (1))) {
      |     ~ ^   ~~~~~~~~~~~~~~~~~~
2 errors generated.
```

Differential Revision: D76093914
wenxin0319 added a commit to wenxin0319/FBGEMM-1 that referenced this pull request Jun 6, 2025
Summary:

Resolved warnings caused by comparisons between signed and unsigned integers in tensor_utils.h. Changed the loop index variable i from int to size_t to match the type of sizes.size(), ensuring consistent and safe comparisons. This change eliminates the -Wsign-compare warnings during compilation.

The original error message here:
```
buck-out/v2/gen/fbcode/b43bb943fef57626/deeplearning/fbgemm/fbgemm_gpu/__fbgemm_gpu_cpu__/buck-headers/fbgemm_gpu/utils/tensor_utils.h:53:20: error: comparison of integers of different signs: 'int' and 'size_t' (aka 'unsigned long') [-Werror,-Wsign-compare]
   53 | for (auto i = 0; i < sizes.size(); ++i) {
      |                  ~ ^ ~~~~~~~~~~~~
buck-out/v2/gen/fbcode/b43bb943fef57626/deeplearning/fbgemm/fbgemm_gpu/__fbgemm_gpu_cpu__/buck-headers/fbgemm_gpu/utils/tensor_utils.h:55:7: error: comparison of integers of different signs: 'int' and 'size_t' (aka 'unsigned long') [-Werror,-Wsign-compare]
   55 | if (i != (sizes.size() - (1))) {
      |     ~ ^   ~~~~~~~~~~~~~~~~~~
2 errors generated.
```

Differential Revision: D76093914
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D76093914

wenxin0319 added a commit to wenxin0319/FBGEMM-1 that referenced this pull request Jun 6, 2025
Summary:
Pull Request resolved: pytorch#4279

Resolved warnings caused by comparisons between signed and unsigned integers in tensor_utils.h. Changed the loop index variable i from int to size_t to match the type of sizes.size(), ensuring consistent and safe comparisons. This change eliminates the -Wsign-compare warnings during compilation.

The original error message here:
```
buck-out/v2/gen/fbcode/b43bb943fef57626/deeplearning/fbgemm/fbgemm_gpu/__fbgemm_gpu_cpu__/buck-headers/fbgemm_gpu/utils/tensor_utils.h:53:20: error: comparison of integers of different signs: 'int' and 'size_t' (aka 'unsigned long') [-Werror,-Wsign-compare]
   53 | for (auto i = 0; i < sizes.size(); ++i) {
      |                  ~ ^ ~~~~~~~~~~~~
buck-out/v2/gen/fbcode/b43bb943fef57626/deeplearning/fbgemm/fbgemm_gpu/__fbgemm_gpu_cpu__/buck-headers/fbgemm_gpu/utils/tensor_utils.h:55:7: error: comparison of integers of different signs: 'int' and 'size_t' (aka 'unsigned long') [-Werror,-Wsign-compare]
   55 | if (i != (sizes.size() - (1))) {
      |     ~ ^   ~~~~~~~~~~~~~~~~~~
2 errors generated.
```

Differential Revision: D76093914
Summary:
X-link: facebookresearch/FBGEMM#1357

Pull Request resolved: pytorch#4279

Resolved warnings caused by comparisons between signed and unsigned integers in tensor_utils.h. Changed the loop index variable i from int to size_t to match the type of sizes.size(), ensuring consistent and safe comparisons. This change eliminates the -Wsign-compare warnings during compilation.

The original error message here:
```
buck-out/v2/gen/fbcode/b43bb943fef57626/deeplearning/fbgemm/fbgemm_gpu/__fbgemm_gpu_cpu__/buck-headers/fbgemm_gpu/utils/tensor_utils.h:53:20: error: comparison of integers of different signs: 'int' and 'size_t' (aka 'unsigned long') [-Werror,-Wsign-compare]
   53 | for (auto i = 0; i < sizes.size(); ++i) {
      |                  ~ ^ ~~~~~~~~~~~~
buck-out/v2/gen/fbcode/b43bb943fef57626/deeplearning/fbgemm/fbgemm_gpu/__fbgemm_gpu_cpu__/buck-headers/fbgemm_gpu/utils/tensor_utils.h:55:7: error: comparison of integers of different signs: 'int' and 'size_t' (aka 'unsigned long') [-Werror,-Wsign-compare]
   55 | if (i != (sizes.size() - (1))) {
      |     ~ ^   ~~~~~~~~~~~~~~~~~~
2 errors generated.
```

Differential Revision: D76093914
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D76093914

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in f002739.

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.

2 participants