-
Notifications
You must be signed in to change notification settings - Fork 560
Improve error handling and message of lowering helper functions. #9722
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
base: master
Are you sure you want to change the base?
Conversation
| // 3. In the presence of a dynamic shape in the input, we are unable to map | ||
| // it to any of the dimensions of the output | ||
| // | ||
| static absl::StatusOr<std::optional<DynamicReshapeInfo>> |
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.
Do we still need optional<>? Can we just return an error instead of nullopt?
| // 2. The return value of `get_printable_data(el)` | ||
| template <class T, class FStar, class FPrint = T (*)(T)> | ||
| std::string SpanToStringWithStar( | ||
| absl::Span<const T> span, FStar&& needs_star, |
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.
Per https://google.github.io/styleguide/cppguide.html#Rvalue_references, avoid Rvalue references here and below.
| // For each element, this function will append to the output string: | ||
| // 1. A star (*), if `needs_star(el)` returns true | ||
| // 2. The return value of `get_printable_data(el)` | ||
| template <class T, class FStar, class FPrint = T (*)(T)> |
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.
Style: rename FStar to NeedStar, rename FPrint to FormatElement.
| // For each element, this function will append to the output string: | ||
| // 1. A star (*), if `needs_star(el)` returns true | ||
| // 2. The return value of `get_printable_data(el)` | ||
| template <class T, class FStar, class FPrint = T (*)(T)> |
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.
Why does FPrint return a T instead of a string?
| // 1. The `needs_star` function will also depend on the index of the element | ||
| // 2. It will always print the element, instead of the index (i.e. the | ||
| // `get_printable_data` is already set) | ||
| template <class F> |
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.
Rename F to NeedStar?
Similar comments for other function templates: make the template type argument names descriptive.
This PR improves the error handling and error message of some lowering helper functions found in
helpers.{h,cpp}C++ files.Key Changes:
Safe*versions of the functions:FlattenDynamicReshapeGetDynamicReshapeInfoCheckAtMostOneDynamicDimension()function, a version ofGetDynamicDimensionwith improved error handling and messagesshapeparameter fromSafeFlatten()