# Shape#

## Shape - 15#

Version

• name: Shape (GitHub)

• domain: main

• since_version: 15

• function: False

• support_level: SupportType.COMMON

• shape inference: True

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

Summary

Takes a tensor as input and outputs an 1D int64 tensor containing the shape of the input tensor. Optional attributes start and end can be used to compute a slice of the input tensor’s shape. If start axis is omitted, the slice starts from axis 0. The end axis, if specified, is exclusive (and the returned value will not include the size of that axis). If the end axis is omitted, the axes upto the last one will be included. Negative axes indicate counting back from the last axis. Note that axes will be clamped to the range [0, r-1], where r is the rank of the input tensor if they are out-of-range (after adding r in the case of negative axis). Thus, specifying any end value > r is equivalent to specifying an end value of r, and specifying any start value < -r is equivalent to specifying a start value of 0.

For example: Input tensor with shape: [2, 3, 4] No attributes specified. Output: [2, 3, 4]

Input tensor with shape: [2, 3, 4] start: -1 Output: 

Input tensor with shape: [2, 3, 4] end: -1 Output: [2, 3]

Input tensor with shape: [2, 3, 4] start: 1 end: 2 Output: 

Attributes

• end: (Optional) Ending axis for slicing the shape. Negative value means counting dimensions from the back. If omitted, sizes of all axes upto (including) the last one will be included.

• start: (Optional) Starting axis for slicing the shape. Default value is 0.Negative value means counting dimensions from the back. Default value is `0`.

Inputs

• data (heterogeneous) - T: An input tensor.

Outputs

• shape (heterogeneous) - T1: Shape of the input tensor

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) ): Input tensor can be of arbitrary type.

• T1 in ( tensor(int64) ): Constrain output to int64 tensor.

Examples

default

```x = np.array([
[1, 2, 3],
[4, 5, 6],
]).astype(np.float32)
test_shape('_example', x)  # preserve names of original test cases

x = np.random.randn(3, 4, 5).astype(np.float32)

test_shape('', x)  # preserve names of original test cases

test_shape('_start_1', x, start=1)

test_shape('_end_1', x, end=1)

test_shape('_start_negative_1', x, start=-1)

test_shape('_end_negative_1', x, end=-1)

test_shape('_start_1_end_negative_1', x, start=1, end=-1)

test_shape('_start_1_end_2', x, start=1, end=2)

test_shape('_clip_start', x, start=-10)

test_shape('_clip_end', x, end=10)
```

Differences

 `0` `0` `Takes a tensor as input and outputs an 1D int64 tensor containing the shape of the input tensor.` `Takes a tensor as input and outputs an 1D int64 tensor containing the shape of the input tensor.` `1` `Optional attributes start and end can be used to compute a slice of the input tensor's shape.` `2` `If start axis is omitted, the slice starts from axis 0.` `3` `The end axis, if specified, is exclusive (and the returned value will not include the size of that axis).` `4` `If the end axis is omitted, the axes upto the last one will be included.` `5` `Negative axes indicate counting back from the last axis.` `6` `Note that axes will be clamped to the range [0, r-1], where r is the` `7` `rank of the input tensor if they are out-of-range (after adding r in the case of` `8` `negative axis). Thus, specifying any end value > r is equivalent to specifying an end` `9` `value of r, and specifying any start value < -r is equivalent to specifying a start` `10` `value of 0.` `1` `11` `12` `For example:` `13` `Input tensor with shape: [2, 3, 4]` `14` `No attributes specified.` `15` `Output: [2, 3, 4]` `16` `17` `Input tensor with shape: [2, 3, 4]` `18` `start: -1` `19` `Output: ` `20` `21` `Input tensor with shape: [2, 3, 4]` `22` `end: -1` `23` `Output: [2, 3]` `24` `25` `Input tensor with shape: [2, 3, 4]` `26` `start: 1` `27` `end: 2` `28` `Output: ` `29` `30` `**Attributes**` `31` `32` `* **end**:` `33` ` (Optional) Ending axis for slicing the shape. Negative value means` `34` ` counting dimensions from the back. If omitted, sizes of all axes` `35` ` upto (including) the last one will be included.` `36` `* **start**:` `37` ` (Optional) Starting axis for slicing the shape. Default value is` `38` ` 0.Negative value means counting dimensions from the back. Default value is 0.` `39` `2` `40` `**Inputs**` `**Inputs**` `3` `41` `4` `42` `* **data** (heterogeneous) - **T**:` `* **data** (heterogeneous) - **T**:` `5` `43` ` An input tensor.` ` An input tensor.` `6` `44` `7` `45` `**Outputs**` `**Outputs**` `8` `46` `9` `47` `* **shape** (heterogeneous) - **T1**:` `* **shape** (heterogeneous) - **T1**:` `10` `48` ` Shape of the input tensor` ` Shape of the input tensor` `11` `49` `12` `50` `**Type Constraints**` `**Type Constraints**` `13` `51` `14` `52` `* **T** in (` `* **T** in (` `15` `53` ` tensor(bfloat16),` ` tensor(bfloat16),` `16` `54` ` tensor(bool),` ` tensor(bool),` `17` `55` ` tensor(complex128),` ` tensor(complex128),` `18` `56` ` tensor(complex64),` ` tensor(complex64),` `19` `57` ` tensor(double),` ` tensor(double),` `20` `58` ` tensor(float),` ` tensor(float),` `21` `59` ` tensor(float16),` ` tensor(float16),` `22` `60` ` tensor(int16),` ` tensor(int16),` `23` `61` ` tensor(int32),` ` tensor(int32),` `24` `62` ` tensor(int64),` ` tensor(int64),` `25` `63` ` tensor(int8),` ` tensor(int8),` `26` `64` ` tensor(string),` ` tensor(string),` `27` `65` ` tensor(uint16),` ` tensor(uint16),` `28` `66` ` tensor(uint32),` ` tensor(uint32),` `29` `67` ` tensor(uint64),` ` tensor(uint64),` `30` `68` ` tensor(uint8)` ` tensor(uint8)` `31` `69` ` ):` ` ):` `32` `70` ` Input tensor can be of arbitrary type.` ` Input tensor can be of arbitrary type.` `33` `71` `* **T1** in (` `* **T1** in (` `34` `72` ` tensor(int64)` ` tensor(int64)` `35` `73` ` ):` ` ):` `36` `74` ` Constrain output to int64 tensor.` ` Constrain output to int64 tensor.`

## Shape - 13#

Version

• name: Shape (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

Takes a tensor as input and outputs an 1D int64 tensor containing the shape of the input tensor.

Inputs

• data (heterogeneous) - T: An input tensor.

Outputs

• shape (heterogeneous) - T1: Shape of the input tensor

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) ): Input tensor can be of arbitrary type.

• T1 in ( tensor(int64) ): Constrain output to int64 tensor.

Differences

 `0` `0` `Takes a tensor as input and outputs an 1D int64 tensor containing the shape of the input tensor.` `Takes a tensor as input and outputs an 1D int64 tensor containing the shape of the input tensor.` `1` `1` `2` `2` `**Inputs**` `**Inputs**` `3` `3` `4` `4` `* **data** (heterogeneous) - **T**:` `* **data** (heterogeneous) - **T**:` `5` `5` ` An input tensor.` ` An input tensor.` `6` `6` `7` `7` `**Outputs**` `**Outputs**` `8` `8` `9` `9` `* **shape** (heterogeneous) - **T1**:` `* **shape** (heterogeneous) - **T1**:` `10` `10` ` Shape of the input tensor` ` Shape of the input tensor` `11` `11` `12` `12` `**Type Constraints**` `**Type Constraints**` `13` `13` `14` `14` `* **T** in (` `* **T** in (` `15` ` tensor(bfloat16),` `15` `16` ` tensor(bool),` ` tensor(bool),` `16` `17` ` tensor(complex128),` ` tensor(complex128),` `17` `18` ` tensor(complex64),` ` tensor(complex64),` `18` `19` ` tensor(double),` ` tensor(double),` `19` `20` ` tensor(float),` ` tensor(float),` `20` `21` ` tensor(float16),` ` tensor(float16),` `21` `22` ` tensor(int16),` ` tensor(int16),` `22` `23` ` tensor(int32),` ` tensor(int32),` `23` `24` ` tensor(int64),` ` tensor(int64),` `24` `25` ` tensor(int8),` ` tensor(int8),` `25` `26` ` tensor(string),` ` tensor(string),` `26` `27` ` tensor(uint16),` ` tensor(uint16),` `27` `28` ` tensor(uint32),` ` tensor(uint32),` `28` `29` ` tensor(uint64),` ` tensor(uint64),` `29` `30` ` tensor(uint8)` ` tensor(uint8)` `30` `31` ` ):` ` ):` `31` `32` ` Input tensor can be of arbitrary type.` ` Input tensor can be of arbitrary type.` `32` `33` `* **T1** in (` `* **T1** in (` `33` `34` ` tensor(int64)` ` tensor(int64)` `34` `35` ` ):` ` ):` `35` `36` ` Constrain output to int64 tensor.` ` Constrain output to int64 tensor.`

## Shape - 1#

Version

• name: Shape (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

Takes a tensor as input and outputs an 1D int64 tensor containing the shape of the input tensor.

Inputs

• data (heterogeneous) - T: An input tensor.

Outputs

• shape (heterogeneous) - T1: Shape of the input tensor

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) ): Input tensor can be of arbitrary type.

• T1 in ( tensor(int64) ): Constrain output to int64 tensor.