-
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 squeeze v15 op spec #26989
Add squeeze v15 op spec #26989
Changes from 1 commit
1590cbe
0f44d06
6b3aa51
8369fbe
5b7950a
5f5302f
fa1f478
d59a9af
4e5e05f
a485969
5d1c730
f11340f
bcfd4d2
f4ca4fb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,104 @@ | ||||||
Squeeze | ||||||
======= | ||||||
|
||||||
|
||||||
.. meta:: | ||||||
:description: Learn about Squeeze-15 - a shape manipulation operation, which | ||||||
can be performed on one required and one optional input tensor. | ||||||
|
||||||
**Versioned name**: *Squeeze-15* | ||||||
|
||||||
**Category**: *Shape manipulation* | ||||||
|
||||||
**Short description**: *Squeeze* removes dimensions equal to 1 from the first input tensor. | ||||||
|
||||||
**Detailed description**: *Squeeze* can be used with or without the second input tensor. | ||||||
|
||||||
* If only the first input is provided, every dimension that is equal to 1 will be removed from it. | ||||||
* With the second input provided, each value is an index of a dimension from the first tensor that is to be removed. Specified dimension should be equal to 1, otherwise it will be ignored and copied as is. | ||||||
Dimension indices can be specified directly, or by negative indices (counting dimensions from the end). | ||||||
|
||||||
.. note:: | ||||||
|
||||||
Behavior before 2024.3 OpenVINO release: Error is raised when dimension to squeeze is not compatible with 1. | ||||||
mmikolajcz marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
.. note:: | ||||||
|
||||||
- If index of the dimension to squeeze is provided as a constant input and it points to a dynamic dimension that might be `1`, then the dimension is considered as squeezable. Therefore the rank of the output shape will be reduced, but not dynamic. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||||||
- If the input with indices is empty or not provided, dynamic dimension compatible with `1` leads to dynamic rank of the output shape. | ||||||
|
||||||
|
||||||
**Attributes**: | ||||||
* *allow_axis_skip* | ||||||
mmikolajcz marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we expect exception raised when There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It could be implemented to throw, but the intention is to keep the v0::Squeeze compatible behavior when There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks that this mode is also helpful for TF Squeeze op (https://www.tensorflow.org/api_docs/python/tf/raw_ops/Squeeze) when axis = []. For such case, I can compute axes for our Squeeze using |
||||||
* **Description**: Shape inference result dynamic rank if selected axis has value 1 in range of its dynamic. | ||||||
mlukasze marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
* **Range of values**: ``false`` or ``true`` | ||||||
* **Type**: ``boolean`` | ||||||
* **Required**: *no* | ||||||
mmikolajcz marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
**Inputs**: | ||||||
|
||||||
* **1**: Multidimensional input tensor of type *T*. **Required.** | ||||||
|
||||||
* **2**: Scalar or 1D tensor of type *T_INT* with indices of dimensions to squeeze. Values could be negative (have to be from range ``[-R, R-1]``, where ``R`` is the rank of the first input). **Optional.** | ||||||
|
||||||
**Outputs**: | ||||||
|
||||||
* **1**: Tensor with squeezed values of type *T*. | ||||||
|
||||||
**Types** | ||||||
|
||||||
* *T*: any numeric type. | ||||||
|
||||||
* *T_INT*: any supported integer type. | ||||||
|
||||||
**Example** | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add attribute value to example IR. Consider adding additional examples that will show differences between attribute values and maybe examples of dynamic rank or ignored non-1 dimensions There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||||||
|
||||||
*Example 1: squeeze 4D tensor to a 2D tensor* | ||||||
|
||||||
.. code-block:: xml | ||||||
:force: | ||||||
|
||||||
<layer ... type="Squeeze"> | ||||||
<input> | ||||||
<port id="0"> | ||||||
<dim>1</dim> | ||||||
<dim>3</dim> | ||||||
<dim>1</dim> | ||||||
<dim>2</dim> | ||||||
</port> | ||||||
</input> | ||||||
<input> | ||||||
<port id="1"> | ||||||
<dim>2</dim> <!-- value [0, 2] --> | ||||||
</port> | ||||||
</input> | ||||||
<output> | ||||||
<port id="2"> | ||||||
<dim>3</dim> | ||||||
<dim>2</dim> | ||||||
</port> | ||||||
</output> | ||||||
</layer> | ||||||
|
||||||
*Example 2: squeeze 1D tensor with 1 element to a 0D tensor (constant)* | ||||||
|
||||||
.. code-block:: xml | ||||||
:force: | ||||||
|
||||||
<layer ... type="Squeeze"> | ||||||
<input> | ||||||
<port id="0"> | ||||||
<dim>1</dim> | ||||||
</port> | ||||||
</input> | ||||||
<input> | ||||||
<port id="1"> | ||||||
<dim>1</dim> <!-- value is [0] --> | ||||||
</port> | ||||||
</input> | ||||||
<output> | ||||||
<port id="2"> | ||||||
</port> | ||||||
</output> | ||||||
</layer> |
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 do we require such version? Is there similar operation in frameworks like PyTorch, TF, ONNX? Can we refer a link to such operation?
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.
It's needed for alignment with torch, more details can be found in the internal ticket: 143585.