Skip to content

Conversation

@mhucka
Copy link
Member

@mhucka mhucka commented Jan 4, 2025

Many files produced many type mismatch warnings with both clang 17 and gcc 14 on a Debian 6.10.11 x86_64 system. This commit fixes almost all the ones I'm seeing in the TFQ code base.

Some other warnings still arise in other code and modules. Those warnings don't appear to be things we can easily work around short of creating a lot of patch files (at significant cost in time and testing). For those, I'm currently relying on setting compiler options (e.g., -Wno-unused-function for warnings about unused functions) narrowed in scope to the problematic package using Bazel's --per_file_copt and --host_per_file_copt flags. Those flags are not in this PR.

Note: this PR should be applied after PR #837.

mhucka added 3 commits January 4, 2025 22:22
Many files produced many type mismatch warnings with both clang 17 and
gcc 14 on a Debian 6.10.11 x86_64 system. This commit fixes almost all
the ones I'm seeing in the TFQ code base.

Some other warnings still arise in other code and modules. Those
warnings don't appear to be things we can easily work around short of
creating a lot of patch files (at significant cost in time and
testing). For those, I'm currently relying on setting compiler options
(e.g., `-Wno-unused-function` for warnings about unused functions)
narrowed in scope to the problematic package using Bazel's
`--per_file_copt` and `--host_per_file_copt` flags. Those flags are
not in this commit; they need to be made part of the TFQ
`configure.sh` script.
@mhucka mhucka marked this pull request as ready for review January 5, 2025 01:54
@mhucka mhucka added kind/chore Maintenance & housekeeping tasks area/health Involves general matters of project configuration, health, maintenance, and similar concerns labels Jan 5, 2025
@mhucka mhucka self-assigned this Jan 5, 2025
Copy link
Collaborator

@MichaelBroughton MichaelBroughton left a comment

Choose a reason for hiding this comment

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

Looks good. Hopefully this gets rid of some of the type warning headaches. It does seem like our use of size_t vs int in loops now will be more inconsistent overall, but if that gets us fewer warnings, I guess it's a step in the right direction.

for (int i = start; i < end; i++) {
for (int j = 0; j < n_symbols; j++) {
for (int k = 0; k < output_results.at(i).at(j).size(); k++) {
for (size_t k = 0; k < output_results.at(i).at(j).size(); k++) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do just k and not i, j as well ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, that's because k is the only one being compared to a .size() value; i and j are used as indexes.

for (size_t k = 0; k < output_results.at(i).at(j).size(); k++) {
output_tensor(i, j, k) = output_results.at(i).at(j).at(k);
}
for (int k = output_results.at(i).at(j).size();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not here ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree this one looks inconsistent. It's because in this case, the value of k is being compared to largest_single_symbol on the next line, and that variable is an int.

The weird thing is k is initialized by setting its value to the output of size(), and yet the compiler isn't complaining about that part. I don't have a good explanation for that.

Although the compiler didn't flag them, a couple of declarations
that were changed to size_t in a previous commit should probably have
const declarations, to be consistent with other changes in the same
function.
mhucka added 3 commits January 9, 2025 16:50
One of the `size_t` → `int` changes was wrong and led to a test
failure.

I would prefer to edit the commit itself; however, that would require
force-pushing to the TFQ repo, and I'm not sure if that will break the
code review comments in the PR in GitHub. So I'm making the change in
a separate commit.
@mhucka mhucka merged commit e28d106 into tensorflow:master Jan 10, 2025
6 of 7 checks passed
@mhucka mhucka mentioned this pull request Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/health Involves general matters of project configuration, health, maintenance, and similar concerns kind/chore Maintenance & housekeeping tasks

Development

Successfully merging this pull request may close these issues.

2 participants