Skip to content

Commit 494d645

Browse files
p-wysockimitruskarkazants
authored
Add specification for SegmentMax-16 (openvinotoolkit#28103)
### Details: - Specification for `tf.math.segment_max` (https://www.tensorflow.org/api_docs/python/tf/math/segment_max) ### Related PRs: - openvinotoolkit#28698 - openvinotoolkit#28788 ### Tickets: - CVS-158914 --------- Signed-off-by: p-wysocki <przemyslaw.wysocki@intel.com> Co-authored-by: Katarzyna Mitrus <katarzyna.mitrus@intel.com> Co-authored-by: Roman Kazantsev <roman.kazantsev@intel.com>
1 parent 7fab505 commit 494d645

File tree

1 file changed

+133
-0
lines changed
  • docs/articles_en/documentation/openvino-ir-format/operation-sets/operation-specs/arithmetic

1 file changed

+133
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
SegmentMax
2+
==========
3+
4+
5+
.. meta::
6+
:description: Learn about SegmentMax-16 - an arithmetic operation which computes the maximum values along segments of a tensor.
7+
8+
**Versioned name**: *SegmentMax-16*
9+
10+
**Category**: *Arithmetic*
11+
12+
**Short description**: *SegmentMax-16* operation finds the maximum value in each specified segment of the ``input`` tensor.
13+
14+
**Detailed description**
15+
16+
For each index in ``segment_ids`` the operator gets values from ``data`` input tensor and calculates the maximum value for each segment.
17+
18+
For example ``segments_ids`` with value ``[0,0,0,1,1,3,5,5]`` defines 4 non-empty segments. ``num_segments`` is not given. When coupled with a 1D data tensor ``data``, the segments are as follows:
19+
20+
* Segment_0: ``[data[0], data[1], data[2]]``
21+
* Segment_1: ``[data[3], data[4]]``
22+
* Segment_2: ``[]``
23+
* Segment_3: ``[data[5]]``
24+
* Segment_4: ``[]``
25+
* Segment_5: ``[data[6], data[7]]``
26+
27+
When there are no values in a segment, ``output[segment]`` is defined by ``fill_mode`` attribute.
28+
29+
For ``fill_mode`` equal to ``ZERO`` , the operation output would be ``[max(Segment_0), max(Segment_1), 0, max(Segment_3), 0, max(Segment_5)]``.
30+
31+
**Attributes**:
32+
33+
* **1**: *fill_mode*
34+
35+
* **Description**: Responsible for the value assigned to segments which are empty. **Required.**
36+
* **Range of values**: Name of the mode in string format:
37+
38+
* ``ZERO`` - the empty segments are filled with zeros.
39+
* ``LOWEST`` - the empty segments are filled with the lowest value of the data type *T*.
40+
* **Type**: ``string``
41+
42+
**Inputs**
43+
44+
* **1**: ``data`` - ND tensor of type *T*, the numerical data on which SegmentMax operation will be performed. **Required.**
45+
46+
* **2**: ``segment_ids`` - 1D Tensor of sorted non-negative numbers of type *T_IDX1*. Its size is equal to the size of the first dimension of the ``data`` input tensor. **Required.**
47+
48+
* **3**: ``num_segments`` - A scalar value of type *T_IDX2* representing the segments count. If ``num_segments < max(segment_ids) + 1`` then the extra segments defined in ``segment_ids`` are not included in the output. If If ``num_segments > max(segment_ids) + 1`` then the output is padded with empty segments. Defaults to ``max(segment_ids) + 1``. **Optional.**
49+
50+
**Outputs**
51+
52+
* **1**: The output tensor has same rank and dimensions as the ``data`` input tensor except for the first dimension which is equal to the value of ``num_segments``.
53+
54+
**Types**
55+
56+
* *T*: any supported numerical data type.
57+
* *T_IDX1*, *T_IDX2*: ``int64`` or ``int32``.
58+
59+
**Examples**
60+
61+
*Example 1: num_segments < max(segment_ids) + 1*
62+
63+
.. code-block:: xml
64+
:force:
65+
66+
<layer ... type="SegmentMax" ... >
67+
<data empty_segment_value="ZERO">
68+
<input>
69+
<port id="0" precision="F32"> <!-- data -->
70+
<dim>5</dim>
71+
</port>
72+
<port id="1" precision="I32"> <!-- segment_ids with 4 segments: [0, 0, 2, 3, 3] -->
73+
<dim>5</dim>
74+
</port>
75+
<port id="2" precision="I64"> <!-- number of segments: 2 -->
76+
<dim>0</dim>
77+
</port>
78+
</input>
79+
<output>
80+
<port id="3" precision="F32">
81+
<dim>2</dim>
82+
</port>
83+
</output>
84+
</layer>
85+
86+
*Example 2: num_segments > max(segment_ids) + 1*
87+
88+
.. code-block:: xml
89+
:force:
90+
91+
<layer ... type="SegmentMax" ... >
92+
<data empty_segment_value="ZERO">
93+
<input>
94+
<port id="0" precision="F32"> <!-- data -->
95+
<dim>5</dim>
96+
</port>
97+
<port id="1" precision="I32"> <!-- segment_ids with 4 segments: [0, 0, 2, 3, 3] -->
98+
<dim>5</dim>
99+
</port>
100+
<port id="2" precision="I64"> <!-- number of segments: 8 -->
101+
<dim>0</dim>
102+
</port>
103+
</input>
104+
<output>
105+
<port id="3" precision="F32">
106+
<dim>8</dim>
107+
</port>
108+
</output>
109+
</layer>
110+
111+
*Example 3: 2D input data, no num_segments*
112+
113+
.. code-block:: xml
114+
:force:
115+
116+
<layer ... type="SegmentMax" ... >
117+
<data empty_segment_value="LOWEST">
118+
<input>
119+
<port id="0" precision="I32"> <!-- data -->
120+
<dim>3</dim>
121+
<dim>4</dim>
122+
</port>
123+
<port id="1" precision="I64"> <!-- segment_ids with 2 segments: [0, 1, 1] -->
124+
<dim>3</dim>
125+
</port>
126+
</input>
127+
<output>
128+
<port id="2" precision="I32">
129+
<dim>2</dim>
130+
<dim>4</dim>
131+
</port>
132+
</output>
133+
</layer>

0 commit comments

Comments
 (0)