# Size#

## Size - 13#

Version

• name: Size (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 a int64 scalar that equals to the total number of elements of the input tensor.

Inputs

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

Outputs

• size (heterogeneous) - T1: Total number of elements 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, which should be a scalar though.

Examples

default

```node = onnx.helper.make_node(
"Size",
inputs=["x"],
outputs=["y"],
)

x = np.array(
[
[1, 2, 3],
[4, 5, 6],
]
).astype(np.float32)
y = np.array(6).astype(np.int64)

expect(node, inputs=[x], outputs=[y], name="test_size_example")

x = np.random.randn(3, 4, 5).astype(np.float32)
y = np.array(x.size).astype(np.int64)

expect(node, inputs=[x], outputs=[y], name="test_size")
```

Differences

 `0` `0` `Takes a tensor as input and outputs a int64 scalar that equals to the total number of elements of the input tensor.` `Takes a tensor as input and outputs a int64 scalar that equals to the total number of elements 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` `* **size** (heterogeneous) - **T1**:` `* **size** (heterogeneous) - **T1**:` `10` `10` ` Total number of elements of the input tensor` ` Total number of elements 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, which should be a scalar though.` ` Constrain output to int64 tensor, which should be a scalar though.`

## Size - 1#

Version

• name: Size (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 a int64 scalar that equals to the total number of elements of the input tensor.

Inputs

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

Outputs

• size (heterogeneous) - T1: Total number of elements 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, which should be a scalar though.