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
PoC: For Each (Range) Index #552
base: dev
Are you sure you want to change the base?
Conversation
idk this is messy
@samayala22 The reason why input, output iterator types are templated is that applications may mix the use of stateful iterators, constant, or non-stateful iterators. For example:
|
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.
This is a topic of interest to me. So here are a couple of comments.
// Function: make_for_each_index_task | ||
template <typename B, typename E, typename S, typename C, typename P = DefaultPartitioner> | ||
TF_FORCE_INLINE auto make_for_each_index_task(B b, E e, S s, C c, P part = P()){ | ||
template <typename T, typename C, typename P = DefaultPartitioner> | ||
TF_FORCE_INLINE auto make_for_each_index_task(T b, T e, C c, P part = P()){ |
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.
The comment in the PR is specifically about this part of the patch. The begin and end iterators, b
and e
may sometimes be of different types and I think it is useful to retain the ability to have different types as was there before.
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.
Separately, though, I think it is important to keep the original interface for backward compatibility. Perhaps you want to overload the function by providing a second version that takes the two-argument function (instead of modifying the existing function)? You can use std::enable_if_t
to ensure the right one gets called.
|
||
static_assert(std::is_integral<T_t>::value, "Begin and end values must be an integral type."); | ||
static_assert( | ||
std::disjunction<is_index_func<T_t, C>, is_range_func<T_t, C>>::value, |
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.
This might be easier to read as follows :-)
std::disjunction<is_index_func<T_t, C>, is_range_func<T_t, C>>::value, | |
is_index_func<T_t, C>::value || is_range_func<T_t, C>::value, |
Proof of concept for feature proposed in #551
A few notes:
Minimal example code of the new functionality: