Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
[TVMScript] Add object path tracing to StructuralEqual #12101
[TVMScript] Add object path tracing to StructuralEqual #12101
Changes from 2 commits
4c28f15
0187ef8
d2fbcf3
7b1679f
9146b33
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Just curious - do you think it would make more sense to move those two methods to the cc file? The primary concern I'm having is that
CompareAttributeValues
is a templated method whose instantiation is all inside a cc file. If we care about visibility, we could introduce a friend classSEqualReducerHelper
which has those two methods as static membersThere 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.
What is the actual concern about having a function template declared in the header?
I don't have a strong opinion, can move these to a helper friend class if you prefer it that way.
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.
There is no concrete problem in this particular case AFAICT - because template instantiation is only defined and used in a single cc file.
On the other hand, in more generic usecases, we would prefer template instantiation being defined in header files so that it's discoverable by the compiler when multiple cc files refer to this method.
Therefore, it's somehow a personal preference (so it's subjective, not any general requirement) that I either define both instantiation and declaration in header file, or both in cc files
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.
I think I mostly understand your point, but I'm missing one thing: why is this specific to function templates? For example, the non-template helper function
GetPathsFromAttrAddressesAndStoreMismatch
just above is also private but we have to put its declaration in the header file, because it is a static function in our class (which we need because of C++ visibility rules).Even if we go with the
SEqualReducerHelper
approach, we still need to leak some details in the header file because we need to either declare it as a static class or as a friend class.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.
Yeah my personal (again it's just subjective) preference is that we hide anything that's not intended to be publicly used, except for non-static methods when it requires some boilerplate code (adding helper friend classes / methods). If a method is in a header file, I would prefer to document it more or less to make it easier for others to catch up