Squeeze - version 23#

This page documents version 23 of operator Squeeze. See Squeeze for the latest version (since version 25).

  • Domain: ai.onnx

  • Since version: 23

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

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

  • axes (tensor(int64)): 1D tensor 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 (T): Reshaped tensor with same data as input.

Type Constraints

  • T: Constrain input and output types to all tensor types up to IRv11. Allowed types: tensor(bfloat16), tensor(bool), tensor(complex128), tensor(complex64), tensor(double), tensor(float), tensor(float16), tensor(float4e2m1), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(int16), tensor(int32), tensor(int4), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint4), tensor(uint64), tensor(uint8).

Examples#

test_cc_generation_attention_persistent

Node:
  Squeeze(Y, axis) -> (logits)
Inputs:
  Y: shape=(1, 2), dtype=int64
    [[0, 1]]
  axis: shape=(1, 1, 0, 2), dtype=float32
    []
  input_2: shape=(1, 1, 0, 2), dtype=float32
    []

Outputs:
  logits: shape=(1, 2, 2), dtype=float32
    [[[2., 0.],
      [1., 2.]]]
  output_1: shape=(1, 1, 2, 2), dtype=float32
    [[[[0., 0.],
       [0., 0.]]]]
  output_2: shape=(1, 1, 2, 2), dtype=float32
    [[[[2., 0.],
       [0., 4.]]]]

test_cc_generation_attention_plain

Node:
  Squeeze(Y, axis) -> (logits)
Inputs:
  Y: shape=(1, 2), dtype=int64
    [[0, 1]]

Outputs:
  logits: shape=(1, 2, 2), dtype=float32
    [[[2., 0.],
      [1., 2.]]]

Differences with previous version (21)#

SchemaDiff: Squeeze (domain 'ai.onnx')

  • old version: 21

  • new version: 23

  • breaking: no

Type constraints:

  • changed ‘T’: added types: [‘tensor(float4e2m1)’]