-
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 specification for SegmentMax-16
#28103
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]>
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.
Let us have EmbeddingSegmentsMax
similar to EmbeddingSegmentsSum
.
It should also have default index (defining default value for empty segment)
...ocumentation/openvino-ir-format/operation-sets/operation-specs/arithmetic/segment-max-16.rst
Outdated
Show resolved
Hide resolved
|
||
* **1**: *data* | ||
|
||
* **Description**: The numerical data on which SegmentMax operation will be performed. **Required.** |
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.
please define input shapes and output shape for each input and describe what dimensions are equal
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.
data
can have any rank and dimensions, so it's described as ND of any numerical type. segment_ids
are specified to be a 1D tensor of non-negative, sorted integer numbers of size equal to the size of the first dimension of the input tensor.
Could you please specify what's missing? I think the shapes are covered, but I may be missing something.
|
Signed-off-by: p-wysocki <[email protected]>
...ocumentation/openvino-ir-format/operation-sets/operation-specs/arithmetic/segment-max-16.rst
Outdated
Show resolved
Hide resolved
...ocumentation/openvino-ir-format/operation-sets/operation-specs/arithmetic/segment-max-16.rst
Outdated
Show resolved
Hide resolved
...ocumentation/openvino-ir-format/operation-sets/operation-specs/arithmetic/segment-max-16.rst
Outdated
Show resolved
Hide resolved
* **2**: *segment_ids* | ||
|
||
* **Description**: Controls how the data is divided into segments. **Required.** | ||
* **Range of values**: 1D tensor of non-negative, sorted integer numbers. Its size is equal to the size of the first dimension of the input tensor. |
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 can see that unsorted segment_ids
may lead to error or undefined behavior (implementation specific, depends on the hardware).
Should we specify a common behavior for OV op?
Can be clarified at the plugin implementation stage.
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 assumed that we'll verify the orderliness of segment_ids
during shape inference and raise an error if needed. We can always remove that check from shape inference later and unify the behavior, but I suppose for now the op will be enabled in CPU with reusage of reference implementation.
...ocumentation/openvino-ir-format/operation-sets/operation-specs/arithmetic/segment-max-16.rst
Outdated
Show resolved
Hide resolved
...ocumentation/openvino-ir-format/operation-sets/operation-specs/arithmetic/segment-max-16.rst
Outdated
Show resolved
Hide resolved
...ocumentation/openvino-ir-format/operation-sets/operation-specs/arithmetic/segment-max-16.rst
Outdated
Show resolved
Hide resolved
…ts/operation-specs/arithmetic/segment-max-16.rst Co-authored-by: Katarzyna Mitrus <[email protected]>
Signed-off-by: p-wysocki <[email protected]>
I added an attribute for the default value. |
...ocumentation/openvino-ir-format/operation-sets/operation-specs/arithmetic/segment-max-16.rst
Outdated
Show resolved
Hide resolved
…ts/operation-specs/arithmetic/segment-max-16.rst
...ocumentation/openvino-ir-format/operation-sets/operation-specs/arithmetic/segment-max-16.rst
Outdated
Show resolved
Hide resolved
…ts/operation-specs/arithmetic/segment-max-16.rst
* **1**: *empty_segment_value* | ||
|
||
* **Description**: The value assigned to segments which are empty. **Required.** | ||
* **Range of values**: A scalar. | ||
* **Type**: *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.
let us have it as an input. it will be more convenient if this value is not constant to compute.
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.
After some discussion with @mitruska I modified the empty_segment_value
to still be an attribute, but now is called fill_mode
and is of type string
. The reason is that it's not an input to the TF operation, but a way to differentiate between SegmentMax and SegmentMaxV2. It allows us to create one operator and enable both of these.
The reason why its type has been changed to string
is that the value LOWEST
inserts the lower limit of type T
into empty segments, and that lower value should be calculated at runtime because we may not know the type during operator conversion and some precision transformations may break the op.
What do you think? Can it stay as an attribute in its current form?
...ocumentation/openvino-ir-format/operation-sets/operation-specs/arithmetic/segment-max-16.rst
Outdated
Show resolved
Hide resolved
...ocumentation/openvino-ir-format/operation-sets/operation-specs/arithmetic/segment-max-16.rst
Outdated
Show resolved
Hide resolved
…ts/operation-specs/arithmetic/segment-max-16.rst Co-authored-by: Roman Kazantsev <[email protected]>
…ts/operation-specs/arithmetic/segment-max-16.rst Co-authored-by: Roman Kazantsev <[email protected]>
Signed-off-by: p-wysocki <[email protected]>
* **1**: *empty_segment_value* | ||
|
||
* **Description**: The value assigned to segments which are empty. **Required.** | ||
* **Range of values**: Name of the mode in string format: | ||
|
||
* ``ZERO`` - the empty segments are filled with zeros. | ||
* ``LOWEST`` - the empty segments are filled with the lowest value of the data type *T*. | ||
* **Type**: ``string`` |
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.
Let it be a constant input (the fourth one) of type T please. It will be more flexible for future use cases.
Attribute is injected in IR and no way to change it in run-time
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.
Since one of the values is LOWEST
, which means the lowest value of type T
, wouldn't this require custom behavior for graph type conversions? Setting that value dynamically during runtime could be safer.
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 don't know but I don't exclude that this operation can be used in some decompositions to express some new FW operation. If we make an attribute for it, we create additional constraints. I think we don't need addtional constraints and let it make more flexible.
...ocumentation/openvino-ir-format/operation-sets/operation-specs/arithmetic/segment-max-16.rst
Outdated
Show resolved
Hide resolved
...ocumentation/openvino-ir-format/operation-sets/operation-specs/arithmetic/segment-max-16.rst
Outdated
Show resolved
Hide resolved
Signed-off-by: p-wysocki <[email protected]>
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.
still propose to avoid the attribute that can be input. Attribute is a constraint
Details:
tf.math.segment_max
(https://www.tensorflow.org/api_docs/python/tf/math/segment_max)Related PRs:
SegmentMax-16
to Core #28698Tickets: