.. _l-onnx-doc-Size: ==== Size ==== .. contents:: :local: .. _l-onnx-op-size-13: 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** .. raw:: html
00Takes 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.
11
22**Inputs****Inputs**
33
44* **data** (heterogeneous) - **T**:* **data** (heterogeneous) - **T**:
55 An input tensor. An input tensor.
66
77**Outputs****Outputs**
88
99* **size** (heterogeneous) - **T1**:* **size** (heterogeneous) - **T1**:
1010 Total number of elements of the input tensor Total number of elements of the input tensor
1111
1212**Type Constraints****Type Constraints**
1313
1414* **T** in (* **T** in (
15 tensor(bfloat16),
1516 tensor(bool), tensor(bool),
1617 tensor(complex128), tensor(complex128),
1718 tensor(complex64), tensor(complex64),
1819 tensor(double), tensor(double),
1920 tensor(float), tensor(float),
2021 tensor(float16), tensor(float16),
2122 tensor(int16), tensor(int16),
2223 tensor(int32), tensor(int32),
2324 tensor(int64), tensor(int64),
2425 tensor(int8), tensor(int8),
2526 tensor(string), tensor(string),
2627 tensor(uint16), tensor(uint16),
2728 tensor(uint32), tensor(uint32),
2829 tensor(uint64), tensor(uint64),
2930 tensor(uint8) tensor(uint8)
3031 ): ):
3132 Input tensor can be of arbitrary type. Input tensor can be of arbitrary type.
3233* **T1** in (* **T1** in (
3334 tensor(int64) tensor(int64)
3435 ): ):
3536 Constrain output to int64 tensor, which should be a scalar though. Constrain output to int64 tensor, which should be a scalar though.
.. _l-onnx-op-size-1: 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.