Squeeze#

Squeeze - 13#

Version

  • name: Squeeze (GitHub)

  • domain: main

  • since_version: 13

  • function: False

  • support_level: SupportType.COMMON

  • shape inference: True

This version of the operator has been available since version 13.

Summary

Remove single-dimensional entries from the shape of a tensor. Takes an input axes with a list of axes to squeeze. If axes is not provided, all the single dimensions will be removed from the shape. If an axis is selected with shape entry not equal to one, an error is raised.

Inputs

Between 1 and 2 inputs.

  • data (heterogeneous) - T: Tensors with at least max(dims) dimensions.

  • axes (optional, heterogeneous) - tensor(int64): List of integers indicating the dimensions to squeeze. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(data).

Outputs

  • squeezed (heterogeneous) - T: Reshaped tensor with same data as input.

Type Constraints

  • T in ( tensor(bfloat16), tensor(bool), tensor(complex128), tensor(complex64), tensor(double), tensor(float), tensor(float16), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8) ): Constrain input and output types to all tensor types.

Examples

squeeze

node = onnx.helper.make_node(
    'Squeeze',
    inputs=['x', 'axes'],
    outputs=['y'],
)
x = np.random.randn(1, 3, 4, 5).astype(np.float32)
axes = np.array([0], dtype=np.int64)
y = np.squeeze(x, axis=0)

expect(node, inputs=[x, axes], outputs=[y],
       name='test_squeeze')

squeeze_negative_axes

node = onnx.helper.make_node(
    'Squeeze',
    inputs=['x', 'axes'],
    outputs=['y'],
)
x = np.random.randn(1, 3, 1, 5).astype(np.float32)
axes = np.array([-2], dtype=np.int64)
y = np.squeeze(x, axis=-2)
expect(node, inputs=[x, axes], outputs=[y],
       name='test_squeeze_negative_axes')

Differences

00Remove single-dimensional entries from the shape of a tensor.Remove single-dimensional entries from the shape of a tensor.
11Takes a parameter axes with a list of axes to squeeze.Takes an input axes with a list of axes to squeeze.
22If axes is not provided, all the single dimensions will be removed fromIf axes is not provided, all the single dimensions will be removed from
33the shape. If an axis is selected with shape entry not equal to one, an error is raised.the shape. If an axis is selected with shape entry not equal to one, an error is raised.
44
5**Inputs**
6
7Between 1 and 2 inputs.
8
59**Attributes*** **data** (heterogeneous) - **T**:
6
10 Tensors with at least max(dims) dimensions.
711* **axes**:* **axes** (optional, heterogeneous) - **tensor(int64)**:
812 List of integers indicating the dimensions to squeeze. Negative List of integers indicating the dimensions to squeeze. Negative
913 value means counting dimensions from the back. Accepted range is value means counting dimensions from the back. Accepted range is
1014 [-r, r-1] where r = rank(data). [-r, r-1] where r = rank(data).
1115
12**Inputs**
13
14* **data** (heterogeneous) - **T**:
15 Tensors with at least max(dims) dimensions.
16
1716**Outputs****Outputs**
1817
1918* **squeezed** (heterogeneous) - **T**:* **squeezed** (heterogeneous) - **T**:
2019 Reshaped tensor with same data as input. Reshaped tensor with same data as input.
2120
2221**Type Constraints****Type Constraints**
2322
2423* **T** in (* **T** in (
24 tensor(bfloat16),
2525 tensor(bool), tensor(bool),
2626 tensor(complex128), tensor(complex128),
2727 tensor(complex64), tensor(complex64),
2828 tensor(double), tensor(double),
2929 tensor(float), tensor(float),
3030 tensor(float16), tensor(float16),
3131 tensor(int16), tensor(int16),
3232 tensor(int32), tensor(int32),
3333 tensor(int64), tensor(int64),
3434 tensor(int8), tensor(int8),
3535 tensor(string), tensor(string),
3636 tensor(uint16), tensor(uint16),
3737 tensor(uint32), tensor(uint32),
3838 tensor(uint64), tensor(uint64),
3939 tensor(uint8) tensor(uint8)
4040 ): ):
4141 Constrain input and output types to all tensor types. Constrain input and output types to all tensor types.

Squeeze - 11#

Version

  • name: Squeeze (GitHub)

  • domain: main

  • since_version: 11

  • function: False

  • support_level: SupportType.COMMON

  • shape inference: True

This version of the operator has been available since version 11.

Summary

Remove single-dimensional entries from the shape of a tensor. Takes a parameter axes with a list of axes to squeeze. If axes is not provided, all the single dimensions will be removed from the shape. If an axis is selected with shape entry not equal to one, an error is raised.

Attributes

  • axes: List of integers indicating the dimensions to squeeze. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(data).

Inputs

  • data (heterogeneous) - T: Tensors with at least max(dims) dimensions.

Outputs

  • squeezed (heterogeneous) - T: Reshaped tensor with same data as input.

Type Constraints

  • T in ( tensor(bool), tensor(complex128), tensor(complex64), tensor(double), tensor(float), tensor(float16), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8) ): Constrain input and output types to all tensor types.

Differences

00Remove single-dimensional entries from the shape of a tensor.Remove single-dimensional entries from the shape of a tensor.
11Takes a parameter axes with a list of axes to squeeze.Takes a parameter axes with a list of axes to squeeze.
22If axes is not provided, all the single dimensions will be removed fromIf axes is not provided, all the single dimensions will be removed from
33the shape. If an axis is selected with shape entry not equal to one, an error is raised.the shape. If an axis is selected with shape entry not equal to one, an error is raised.
44
55**Attributes****Attributes**
66
77* **axes**:* **axes**:
88 List of non-negative integers, indicate the dimensions to squeeze. List of integers indicating the dimensions to squeeze. Negative
9 value means counting dimensions from the back. Accepted range is
10 [-r, r-1] where r = rank(data).
911
1012**Inputs****Inputs**
1113
1214* **data** (heterogeneous) - **T**:* **data** (heterogeneous) - **T**:
1315 Tensors with at least max(dims) dimensions. Tensors with at least max(dims) dimensions.
1416
1517**Outputs****Outputs**
1618
1719* **squeezed** (heterogeneous) - **T**:* **squeezed** (heterogeneous) - **T**:
1820 Reshaped tensor with same data as input. Reshaped tensor with same data as input.
1921
2022**Type Constraints****Type Constraints**
2123
2224* **T** in (* **T** in (
2325 tensor(bool), tensor(bool),
2426 tensor(complex128), tensor(complex128),
2527 tensor(complex64), tensor(complex64),
2628 tensor(double), tensor(double),
2729 tensor(float), tensor(float),
2830 tensor(float16), tensor(float16),
2931 tensor(int16), tensor(int16),
3032 tensor(int32), tensor(int32),
3133 tensor(int64), tensor(int64),
3234 tensor(int8), tensor(int8),
3335 tensor(string), tensor(string),
3436 tensor(uint16), tensor(uint16),
3537 tensor(uint32), tensor(uint32),
3638 tensor(uint64), tensor(uint64),
3739 tensor(uint8) tensor(uint8)
3840 ): ):
3941 Constrain input and output types to all tensor types. Constrain input and output types to all tensor types.

Squeeze - 1#

Version

  • name: Squeeze (GitHub)

  • domain: main

  • since_version: 1

  • function: False

  • support_level: SupportType.COMMON

  • shape inference: True

This version of the operator has been available since version 1.

Summary

Remove single-dimensional entries from the shape of a tensor. Takes a parameter axes with a list of axes to squeeze. If axes is not provided, all the single dimensions will be removed from the shape. If an axis is selected with shape entry not equal to one, an error is raised.

Attributes

  • axes: List of non-negative integers, indicate the dimensions to squeeze.

Inputs

  • data (heterogeneous) - T: Tensors with at least max(dims) dimensions.

Outputs

  • squeezed (heterogeneous) - T: Reshaped tensor with same data as input.

Type Constraints

  • T in ( tensor(bool), tensor(complex128), tensor(complex64), tensor(double), tensor(float), tensor(float16), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8) ): Constrain input and output types to all tensor types.