-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Add SegmentMax-16
reference implementation
#28788
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: p-wysocki <[email protected]>
Signed-off-by: p-wysocki <[email protected]>
Signed-off-by: p-wysocki <[email protected]>
…into segmentmax_core Signed-off-by: p-wysocki <[email protected]>
Signed-off-by: p-wysocki <[email protected]>
Signed-off-by: p-wysocki <[email protected]>
Signed-off-by: p-wysocki <[email protected]>
Signed-off-by: p-wysocki <[email protected]>
Signed-off-by: p-wysocki <[email protected]>
Signed-off-by: p-wysocki <[email protected]>
Signed-off-by: p-wysocki <[email protected]>
Signed-off-by: p-wysocki <[email protected]>
Signed-off-by: p-wysocki <[email protected]>
Signed-off-by: p-wysocki <[email protected]>
Signed-off-by: p-wysocki <[email protected]>
Signed-off-by: p-wysocki <[email protected]>
Signed-off-by: p-wysocki <[email protected]>
…into segmentmax_core Signed-off-by: p-wysocki <[email protected]>
Signed-off-by: p-wysocki <[email protected]>
Signed-off-by: p-wysocki <[email protected]>
Signed-off-by: p-wysocki <[email protected]>
Signed-off-by: p-wysocki <[email protected]>
Signed-off-by: p-wysocki <[email protected]>
@@ -20,6 +20,12 @@ enum class PadMode { CONSTANT = 0, EDGE, REFLECT, SYMMETRIC }; | |||
OPENVINO_API | |||
std::ostream& operator<<(std::ostream& s, const PadMode& type); | |||
|
|||
/// \brief Fill modes for the `SegmentMax` operator. |
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.
If this is specific for SegmentMax op only, then it should be placed in the op dedicated namespace and file.
Otherwise generalize the comment.
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 a chance to extend it and reuse it with other ops in the future like SegmentMin
/// \brief Fill modes for the `SegmentMax` operator. | |
/// \brief Fill modes to set default value for operators like `SegmentMax`. |
But if it's preferred to use a separate enums for such ops, it should be inside the SegmentMax class/namespace/file.
const size_t inner_dim_size = | ||
std::accumulate(data_shape.begin() + 1, data_shape.end(), 1, std::multiplies<size_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.
const size_t inner_dim_size = | |
std::accumulate(data_shape.begin() + 1, data_shape.end(), 1, std::multiplies<size_t>()); | |
const auto inner_dim_size = shape_size(data_shape.begin() +1, data_shape.end()); |
std::vector<std::vector<T>> max_values(num_segments, | ||
std::vector<T>(inner_dim_size, std::numeric_limits<T>::lowest())); |
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.
Can be input data copy avoided and set max values in the result tensor instead?
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.
Looks promising. Let's merge the PR with op class first.
template <typename T, typename T_idx> | ||
void segment_max(const T* data, | ||
const Shape& data_shape, | ||
const T_idx* segment_ids, |
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.
To avoid additional type specialization for int32 and int64 (in favour of smaller binary size) there is a common approach to upcast the i32 to i64, and use only i64 in the ref instead of T_idx
.
But as this reference implementation is not used in the evaluate from the op class, it's not crucial.
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.
An example here
Details:
SegmentMax-16
to Core #28698, it's currently merged into this PRRelated PRs:
SegmentMax-16
#28103SegmentMax-16
to Core #28698Tickets: