Split#
Split - 13#
Version
name: Split (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
Split a tensor into a list of tensors, along the specified ‘axis’. Lengths of the parts can be specified using input ‘split’. Otherwise, the tensor is split to equal sized parts.
Attributes
axis: Which axis to split on. A negative value means counting dimensions from the back. Accepted range is [-rank, rank-1] where r = rank(input). Default value is
0
.
Inputs
Between 1 and 2 inputs.
input (heterogeneous) - T: The tensor to split
split (optional, heterogeneous) - tensor(int64): Optional length of each output. Values should be >= 0.Sum of the values must be equal to the dim value at ‘axis’ specified.
Outputs
Between 1 and 2147483647 outputs.
outputs (variadic, heterogeneous) - T: One or more outputs forming list of tensors after splitting
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) ): Constrain input and output types to all tensor types.
Examples
1d
input = np.array([1., 2., 3., 4., 5., 6.]).astype(np.float32)
node = onnx.helper.make_node(
'Split',
inputs=['input'],
outputs=['output_1', 'output_2', 'output_3'],
axis=0
)
expected_outputs = [np.array([1., 2.]).astype(np.float32), np.array([3., 4.]).astype(np.float32), np.array([5., 6.]).astype(np.float32)]
expect(node, inputs=[input], outputs=[y for y in expected_outputs], name='test_split_equal_parts_1d')
split = np.array([2, 4]).astype(np.int64)
node = onnx.helper.make_node(
'Split',
inputs=['input', 'split'],
outputs=['output_1', 'output_2'],
axis=0,
)
expected_outputs = [np.array([1., 2.]).astype(np.float32), np.array([3., 4., 5., 6.]).astype(np.float32)]
expect(node, inputs=[input, split], outputs=[y for y in expected_outputs], name='test_split_variable_parts_1d')
2d
input = np.array([[1., 2., 3., 4., 5., 6.],
[7., 8., 9., 10., 11., 12.]]).astype(np.float32)
node = onnx.helper.make_node(
'Split',
inputs=['input'],
outputs=['output_1', 'output_2'],
axis=1
)
expected_outputs = [np.array([[1., 2., 3.], [7., 8., 9.]]).astype(np.float32),
np.array([[4., 5., 6.], [10., 11., 12.]]).astype(np.float32)]
expect(node, inputs=[input], outputs=[y for y in expected_outputs], name='test_split_equal_parts_2d')
split = np.array([2, 4]).astype(np.int64)
node = onnx.helper.make_node(
'Split',
inputs=['input', 'split'],
outputs=['output_1', 'output_2'],
axis=1,
)
expected_outputs = [np.array([[1., 2.], [7., 8.]]).astype(np.float32),
np.array([[3., 4., 5., 6.], [9., 10., 11., 12.]]).astype(np.float32)]
expect(node, inputs=[input, split], outputs=[y for y in expected_outputs], name='test_split_variable_parts_2d')
default_values
input = np.array([1., 2., 3., 4., 5., 6.]).astype(np.float32)
# If axis is not specified, split is applied on default axis 0
node = onnx.helper.make_node(
'Split',
inputs=['input'],
outputs=['output_1', 'output_2', 'output_3']
)
expected_outputs = [np.array([1., 2.]).astype(np.float32), np.array([3., 4.]).astype(np.float32), np.array([5., 6.]).astype(np.float32)]
expect(node, inputs=[input], outputs=[y for y in expected_outputs], name='test_split_equal_parts_default_axis')
split = np.array([2, 4]).astype(np.int64)
node = onnx.helper.make_node(
'Split',
inputs=['input', 'split'],
outputs=['output_1', 'output_2']
)
expected_outputs = [np.array([1., 2.]).astype(np.float32), np.array([3., 4., 5., 6.]).astype(np.float32)]
expect(node, inputs=[input, split], outputs=[y for y in expected_outputs], name='test_split_variable_parts_default_axis')
zero_size_splits
input = np.array([]).astype(np.float32)
# Split emtpy tensor to tensors of size zero
split = np.array([0, 0, 0]).astype(np.int64)
node = onnx.helper.make_node(
'Split',
inputs=['input', 'split'],
outputs=['output_1', 'output_2', 'output_3']
)
expected_outputs = [np.array([]).astype(np.float32), np.array([]).astype(np.float32), np.array([]).astype(np.float32)]
expect(node, inputs=[input, split], outputs=[y for y in expected_outputs], name='test_split_zero_size_splits')
Differences
0 | 0 | Split a tensor into a list of tensors, along the specified | Split a tensor into a list of tensors, along the specified |
1 | 1 | 'axis'. Lengths of the parts can be specified using argument 'split'. |
|
2 | 2 | Otherwise, the tensor is split to equal sized parts. | Otherwise, the tensor is split to equal sized parts. |
3 | 3 |
|
|
4 | 4 | **Attributes** | **Attributes** |
5 | 5 |
|
|
6 | 6 | * **axis**: | * **axis**: |
7 | 7 | Which axis to split on. A negative value means counting dimensions | Which axis to split on. A negative value means counting dimensions |
8 | 8 | from the back. Accepted range is [-rank, rank-1] where r = | from the back. Accepted range is [-rank, rank-1] where r = |
9 | 9 | rank(input). Default value is 0. | rank(input). Default value is 0. |
10 | * **split**: | ||
10 |
| ||
11 | 11 | length of each output. Values should be >= 0. |
|
12 | 12 |
|
|
13 | 13 | **Inputs** |
|
14 | 14 |
|
|
15 | 15 | * **input** (heterogeneous) - **T**: | * **input** (heterogeneous) - **T**: |
16 | The tensor to split | ||
16 | 17 | The tensor to split |
|
18 | Optional length of each output. Values should be >= 0.Sum of the | ||
19 | values must be equal to the dim value at 'axis' specified. | ||
17 | 20 |
|
|
18 | 21 | **Outputs** | **Outputs** |
19 | 22 |
|
|
20 | 23 | Between 1 and 2147483647 outputs. | Between 1 and 2147483647 outputs. |
21 | 24 |
|
|
22 | 25 | * **outputs** (variadic, heterogeneous) - **T**: | * **outputs** (variadic, heterogeneous) - **T**: |
23 | 26 | One or more outputs forming list of tensors after splitting | One or more outputs forming list of tensors after splitting |
24 | 27 |
|
|
25 | 28 | **Type Constraints** | **Type Constraints** |
26 | 29 |
|
|
27 | 30 | * **T** in ( | * **T** in ( |
31 | tensor(bfloat16), | ||
28 | 32 | tensor(bool), | tensor(bool), |
29 | 33 | tensor(complex128), | tensor(complex128), |
30 | 34 | tensor(complex64), | tensor(complex64), |
31 | 35 | tensor(double), | tensor(double), |
32 | 36 | tensor(float), | tensor(float), |
33 | 37 | tensor(float16), | tensor(float16), |
34 | 38 | tensor(int16), | tensor(int16), |
35 | 39 | tensor(int32), | tensor(int32), |
36 | 40 | tensor(int64), | tensor(int64), |
37 | 41 | tensor(int8), | tensor(int8), |
38 | 42 | tensor(string), | tensor(string), |
39 | 43 | tensor(uint16), | tensor(uint16), |
40 | 44 | tensor(uint32), | tensor(uint32), |
41 | 45 | tensor(uint64), | tensor(uint64), |
42 | 46 | tensor(uint8) | tensor(uint8) |
43 | 47 | ): | ): |
44 | 48 | Constrain input and output types to all tensor types. | Constrain input and output types to all tensor types. |
Split - 11#
Version
name: Split (GitHub)
domain: main
since_version: 11
function: False
support_level: SupportType.COMMON
shape inference: True
This version of the operator has been available since version 11.
Summary
Split a tensor into a list of tensors, along the specified ‘axis’. Lengths of the parts can be specified using argument ‘split’. Otherwise, the tensor is split to equal sized parts.
Attributes
axis: Which axis to split on. A negative value means counting dimensions from the back. Accepted range is [-rank, rank-1] where r = rank(input). Default value is
0
.split: length of each output. Values should be >= 0.
Inputs
input (heterogeneous) - T: The tensor to split
Outputs
Between 1 and 2147483647 outputs.
outputs (variadic, heterogeneous) - T: One or more outputs forming list of tensors after splitting
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) ): Constrain input and output types to all tensor types.
Differences
0 | 0 | Split a tensor into a list of tensors, along the specified | Split a tensor into a list of tensors, along the specified |
1 | 1 | 'axis'. Lengths of the parts can be specified using argument 'split'. | 'axis'. Lengths of the parts can be specified using argument 'split'. |
2 | 2 | Otherwise, the tensor is split to equal sized parts. | Otherwise, the tensor is split to equal sized parts. |
3 | 3 |
|
|
4 | 4 | **Attributes** | **Attributes** |
5 | 5 |
|
|
6 | 6 | * **axis**: | * **axis**: |
7 | 7 | Which axis to split on. Default value is 0. |
|
8 | from the back. Accepted range is [-rank, rank-1] where r = | ||
9 | rank(input). Default value is 0. | ||
8 | 10 | * **split**: | * **split**: |
9 | 11 | length of each output |
|
10 | 12 |
|
|
11 | 13 | **Inputs** | **Inputs** |
12 | 14 |
|
|
13 | 15 | * **input** (heterogeneous) - **T**: | * **input** (heterogeneous) - **T**: |
14 | 16 | The tensor to split | The tensor to split |
15 | 17 |
|
|
16 | 18 | **Outputs** | **Outputs** |
17 | 19 |
|
|
18 | 20 | Between 1 and 2147483647 outputs. | Between 1 and 2147483647 outputs. |
19 | 21 |
|
|
20 | 22 | * **outputs** (variadic, heterogeneous) - **T**: | * **outputs** (variadic, heterogeneous) - **T**: |
21 | 23 | One or more outputs forming list of tensors after splitting | One or more outputs forming list of tensors after splitting |
22 | 24 |
|
|
23 | 25 | **Type Constraints** | **Type Constraints** |
24 | 26 |
|
|
25 | 27 | * **T** in ( | * **T** in ( |
26 | 28 | tensor(bool), | tensor(bool), |
27 | 29 | tensor(complex128), | tensor(complex128), |
28 | 30 | tensor(complex64), | tensor(complex64), |
29 | 31 | tensor(double), | tensor(double), |
30 | 32 | tensor(float), | tensor(float), |
31 | 33 | tensor(float16), | tensor(float16), |
32 | 34 | tensor(int16), | tensor(int16), |
33 | 35 | tensor(int32), | tensor(int32), |
34 | 36 | tensor(int64), | tensor(int64), |
35 | 37 | tensor(int8), | tensor(int8), |
36 | 38 | tensor(string), | tensor(string), |
37 | 39 | tensor(uint16), | tensor(uint16), |
38 | 40 | tensor(uint32), | tensor(uint32), |
39 | 41 | tensor(uint64), | tensor(uint64), |
40 | 42 | tensor(uint8) | tensor(uint8) |
41 | 43 | ): | ): |
42 | 44 | Constrain input and output types to all tensor types. | Constrain input and output types to all tensor types. |
Split - 2#
Version
name: Split (GitHub)
domain: main
since_version: 2
function: False
support_level: SupportType.COMMON
shape inference: True
This version of the operator has been available since version 2.
Summary
Split a tensor into a list of tensors, along the specified ‘axis’. Lengths of the parts can be specified using argument ‘split’. Otherwise, the tensor is split to equal sized parts.
Attributes
axis: Which axis to split on. Default value is
0
.split: length of each output
Inputs
input (heterogeneous) - T: The tensor to split
Outputs
Between 1 and 2147483647 outputs.
outputs (variadic, heterogeneous) - T: One or more outputs forming list of tensors after splitting
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) ): Constrain input and output types to all tensor types.
Differences
0 | 0 | Split a tensor into a list of tensors, along the specified | Split a tensor into a list of tensors, along the specified |
1 | 1 | 'axis'. The lengths of the split can be specified using argument 'axis' or |
|
2 | optional second input blob to the operator. Otherwise, the tensor is split | ||
3 | 2 | to equal sized parts. |
|
4 | 3 |
|
|
5 | 4 | **Attributes** | **Attributes** |
6 | 5 |
|
|
7 | 6 | * **axis**: | * **axis**: |
8 | 7 | Which axis to split on |
|
9 | 8 | * **split**: | * **split**: |
10 | 9 | length of each output | length of each output |
11 | 10 |
|
|
12 | 11 | **Inputs** | **Inputs** |
13 | 12 |
|
|
14 | Between 1 and 2 inputs. | ||
15 |
| ||
16 | 13 | * **input** (heterogeneous) - **T**: | * **input** (heterogeneous) - **T**: |
17 | The tensor to split | ||
18 | 14 | * **split** (optional, heterogeneous) - **T**: |
|
19 | Optional list of output lengths (see also arg 'split') | ||
20 | 15 |
|
|
21 | 16 | **Outputs** | **Outputs** |
22 | 17 |
|
|
23 | 18 | Between 1 and 2147483647 outputs. | Between 1 and 2147483647 outputs. |
24 | 19 |
|
|
25 | 20 | * **outputs...** (variadic, heterogeneous) - **T**: |
|
26 | 21 | One or more outputs forming list of tensors after splitting | One or more outputs forming list of tensors after splitting |
27 | 22 |
|
|
28 | 23 | **Type Constraints** | **Type Constraints** |
29 | 24 |
|
|
30 | 25 | * **T** in ( | * **T** in ( |
26 | tensor(bool), | ||
27 | tensor(complex128), | ||
28 | tensor(complex64), | ||
31 | 29 | tensor(double), | tensor(double), |
32 | 30 | tensor(float), | tensor(float), |
33 | 31 | tensor(float16) |
|
32 | tensor(int16), | ||
33 | tensor(int32), | ||
34 | tensor(int64), | ||
35 | tensor(int8), | ||
36 | tensor(string), | ||
37 | tensor(uint16), | ||
38 | tensor(uint32), | ||
39 | tensor(uint64), | ||
40 | tensor(uint8) | ||
34 | 41 | ): | ): |
35 | 42 | Constrain input types to float tensors. |
|
Split - 1#
Version
name: Split (GitHub)
domain: main
since_version: 1
function: False
support_level: SupportType.COMMON
shape inference: False
This version of the operator has been available since version 1.
Summary
Split a tensor into a list of tensors, along the specified ‘axis’. The lengths of the split can be specified using argument ‘axis’ or optional second input blob to the operator. Otherwise, the tensor is split to equal sized parts.
Attributes
axis: Which axis to split on
split: length of each output
Inputs
Between 1 and 2 inputs.
input (heterogeneous) - T: The tensor to split
split (optional, heterogeneous) - T: Optional list of output lengths (see also arg ‘split’)
Outputs
Between 1 and 2147483647 outputs.
outputs… (variadic, heterogeneous) - T: One or more outputs forming list of tensors after splitting
Type Constraints
T in ( tensor(double), tensor(float), tensor(float16) ): Constrain input types to float tensors.