FilesLast commitLast update
25 days ago
8 months ago
25 days ago
23 days ago
25 days ago
10 months ago
25 days ago
10 days ago
README

Squeeze

English | 简体中文

Product Support Status

Product Supported
Ascend 950PR&950DT products √
Atlas A3 products √
Atlas A2 products √
Atlas 200I/500 A2 inference products √
Atlas inference products √
Atlas training products √

Function Description

API function: removes dimensions whose size is 1 from a tensor. Example:

If axis is empty, all dimensions whose size is 1 are removed:

>>> x = tf.constant([[[1], [2]], [[3], [4]]])   # shape (2, 2, 1)
>>> tf.squeeze(x).shape
(2, 2)

If axis is specified, only the specified dimensions whose size is 1 are removed:

>>> x = tf.constant([[[1], [2]], [[3], [4]]])   # shape (2, 2, 1)
>>> tf.squeeze(x, [2]).shape
(2, 2)
>>> tf.squeeze(x, [0]).shape
(2, 1)

Parameter Description

Parameter Name Input/Output/Attribute Description Data Type Data Format
x Input Input tensor to be squeezed BOOL, FLOAT16, FLOAT, INT4, INT8, UINT8, INT16, UINT16, INT32, UINT32, INT64, UINT64, DOUBLE, COMPLEX64 ND, FRACTAL_NZ
axis Optional attribute
  • List of dimensions to be removed. The value ranges from [-rank(x), rank(x))
  • If it is not specified or is empty, all dimensions whose size is 1 are removed
  • If it is specified, only the specified dimensions are removed, and the size of each specified dimension must be 1
  • The default value is []
LIST_INT64 -
y Output Squeezed output tensor, whose data type is the same as that of the input x BOOL, FLOAT16, FLOAT, INT4, INT8, UINT8, INT16, UINT16, INT32, UINT32, INT64, UINT64, DOUBLE, COMPLEX64 ND, FRACTAL_NZ

Constraint Description

  • If axis is specified, the size of the dimension corresponding to axis must be 1. Otherwise, the operator fails to execute.
  • If the input has a dynamic shape (containing -1) and axis is empty, whether the -1 dimension is 1 cannot be determined, and the output shape is set to -2.

Invocation Description

Invocation Method Sample Code Description
Graph-mode invocation test_geir_squeeze Invokes the Squeeze operator by building a graph through the operator IR.