Skip to content

Conversation

@Hzfengsy
Copy link
Member

This PR fixes the following compile warnings with clang-17:

[build] warning: unknown command tag name [-Wdocumentation-unknown-command]
[build]    90 |    *     @R.function
[build]       |          ^~

[build] warning: 'tvm::codegen::CodeGenWebGPU::AddFunction' hides overloaded virtual function [-Woverloaded-virtual]
[build]    52 |   runtime::FunctionInfo AddFunction(const PrimFunc& f, bool skip_readonly_decl);  // NOLINT(*)
[build]       |

cc @Lunderberg @tqchen

This PR fixes the following compile warnings:
```
[build] warning: unknown command tag name [-Wdocumentation-unknown-command]
[build]    90 |    *     @R.function
[build]       |          ^~

[build] warning: 'tvm::codegen::CodeGenWebGPU::AddFunction' hides overloaded virtual function [-Woverloaded-virtual]
[build]    52 |   runtime::FunctionInfo AddFunction(const PrimFunc& f, bool skip_readonly_decl);  // NOLINT(*)
[build]       |
```
Copy link
Contributor

@Lunderberg Lunderberg 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, and thank you for the fix. I have one question about a warning that should perhaps be fixed in a different manner, but that can be in a follow-up PR.

explicit CodeGenWebGPU(Target target);
// overrides
std::string Finish() final;
using CodeGenC::AddFunction;
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume this is for silencing a warning about shadowing CodeGenC::AddFunction? If so, could we instead remove the skip_readonly_decl argument altogether?

The CodeGenWebGPU::AddFunction method is only ever called here, and it is always passed false. I'm wondering if it should be part of the CodeGenWebGPU constructor instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for your comment, but I'm not sure if it helps. As stack overflow says, the warning happens if the functions have the same names but different signatures.

Indeed, there are different solutions, like renaming CodeGenWebGPU::AddFunction. Meanwhile, I think it's also fine to use using CodeGenC::AddFunction;, as the compiler will import the function automatically and implicitly.

I have no personal preference. I would love to follow up if you have a strong opinion on a specific solution :)

Copy link
Contributor

Choose a reason for hiding this comment

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

My main concern is because CodeGenC::AddFunction is a virtual function. The CodeGenWebGPU::AddFunction shadows CodeGenC::AddFunction, but doesn't override it due to the different signature. Calls made to this function through a base class pointer CodegenC* my_codegen = get_codegen(); my_codegen->AddFunction(...) would therefore call CodeGenC::AddFunction not CodeGenWebGPU::AddFunction.

I don't think there are any calls to AddFunction through a base class pointer, but its something that could cause unexpected breakage in the future.

@tqchen tqchen merged commit 67bd739 into apache:main Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants