Skip to content
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

Use switch case without default in LiteralToValue #17279

Closed

Conversation

apivovarov
Copy link
Contributor

Recommendation:

Missing switch cases are a compiler error, so having a switch without a default case is preferable when possible

Change:

in xla/mlir/tools/mlir_replay/public/execution_trace_utils.cc :: LiteralToValue(Literal) -> InterpreterValue
This PR removes IsTuple(), IsToken(), IsArray(), IsF8Type() and refactors the code to use single switch case block.

Copy link
Member

@reedwm reedwm left a comment

Choose a reason for hiding this comment

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

Thank you for the PR! However, I prefer the way you did this in #17170. It is nice having the compiler verify you covered all types, but it also has the issue where if new types are added, they have to be added to this switch statement. In general when adding a new type, you have to modify very many places (as you are doing in #16585), so we should try reducing the number of places where each type needs to be listed separately. So I'll close this PR.

@reedwm reedwm closed this Sep 17, 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.

2 participants