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

00Split a tensor into a list of tensors, along the specifiedSplit a tensor into a list of tensors, along the specified
11'axis'. Lengths of the parts can be specified using argument 'split'.'axis'. Lengths of the parts can be specified using input 'split'.
22Otherwise, the tensor is split to equal sized parts.Otherwise, the tensor is split to equal sized parts.
33
44**Attributes****Attributes**
55
66* **axis**:* **axis**:
77 Which axis to split on. A negative value means counting dimensions Which axis to split on. A negative value means counting dimensions
88 from the back. Accepted range is [-rank, rank-1] where r = from the back. Accepted range is [-rank, rank-1] where r =
99 rank(input). Default value is 0. rank(input). Default value is 0.
10* **split**:
10
1111 length of each output. Values should be >= 0.**Inputs**
1212
1313**Inputs**Between 1 and 2 inputs.
1414
1515* **input** (heterogeneous) - **T**:* **input** (heterogeneous) - **T**:
16 The tensor to split
1617 The tensor to split* **split** (optional, heterogeneous) - **tensor(int64)**:
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.
1720
1821**Outputs****Outputs**
1922
2023Between 1 and 2147483647 outputs.Between 1 and 2147483647 outputs.
2124
2225* **outputs** (variadic, heterogeneous) - **T**:* **outputs** (variadic, heterogeneous) - **T**:
2326 One or more outputs forming list of tensors after splitting One or more outputs forming list of tensors after splitting
2427
2528**Type Constraints****Type Constraints**
2629
2730* **T** in (* **T** in (
31 tensor(bfloat16),
2832 tensor(bool), tensor(bool),
2933 tensor(complex128), tensor(complex128),
3034 tensor(complex64), tensor(complex64),
3135 tensor(double), tensor(double),
3236 tensor(float), tensor(float),
3337 tensor(float16), tensor(float16),
3438 tensor(int16), tensor(int16),
3539 tensor(int32), tensor(int32),
3640 tensor(int64), tensor(int64),
3741 tensor(int8), tensor(int8),
3842 tensor(string), tensor(string),
3943 tensor(uint16), tensor(uint16),
4044 tensor(uint32), tensor(uint32),
4145 tensor(uint64), tensor(uint64),
4246 tensor(uint8) tensor(uint8)
4347 ): ):
4448 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

00Split a tensor into a list of tensors, along the specifiedSplit a tensor into a list of tensors, along the specified
11'axis'. Lengths of the parts can be specified using argument 'split'.'axis'. Lengths of the parts can be specified using argument 'split'.
22Otherwise, the tensor is split to equal sized parts.Otherwise, the tensor is split to equal sized parts.
33
44**Attributes****Attributes**
55
66* **axis**:* **axis**:
77 Which axis to split on. Default value is 0. Which axis to split on. A negative value means counting dimensions
8 from the back. Accepted range is [-rank, rank-1] where r =
9 rank(input). Default value is 0.
810* **split**:* **split**:
911 length of each output length of each output. Values should be >= 0.
1012
1113**Inputs****Inputs**
1214
1315* **input** (heterogeneous) - **T**:* **input** (heterogeneous) - **T**:
1416 The tensor to split The tensor to split
1517
1618**Outputs****Outputs**
1719
1820Between 1 and 2147483647 outputs.Between 1 and 2147483647 outputs.
1921
2022* **outputs** (variadic, heterogeneous) - **T**:* **outputs** (variadic, heterogeneous) - **T**:
2123 One or more outputs forming list of tensors after splitting One or more outputs forming list of tensors after splitting
2224
2325**Type Constraints****Type Constraints**
2426
2527* **T** in (* **T** in (
2628 tensor(bool), tensor(bool),
2729 tensor(complex128), tensor(complex128),
2830 tensor(complex64), tensor(complex64),
2931 tensor(double), tensor(double),
3032 tensor(float), tensor(float),
3133 tensor(float16), tensor(float16),
3234 tensor(int16), tensor(int16),
3335 tensor(int32), tensor(int32),
3436 tensor(int64), tensor(int64),
3537 tensor(int8), tensor(int8),
3638 tensor(string), tensor(string),
3739 tensor(uint16), tensor(uint16),
3840 tensor(uint32), tensor(uint32),
3941 tensor(uint64), tensor(uint64),
4042 tensor(uint8) tensor(uint8)
4143 ): ):
4244 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

00Split a tensor into a list of tensors, along the specifiedSplit a tensor into a list of tensors, along the specified
11'axis'. The lengths of the split can be specified using argument 'axis' or'axis'. Lengths of the parts can be specified using argument 'split'.
2optional second input blob to the operator. Otherwise, the tensor is split
32to equal sized parts.Otherwise, the tensor is split to equal sized parts.
43
54**Attributes****Attributes**
65
76* **axis**:* **axis**:
87 Which axis to split on Which axis to split on. Default value is 0.
98* **split**:* **split**:
109 length of each output length of each output
1110
1211**Inputs****Inputs**
1312
14Between 1 and 2 inputs.
15
1613* **input** (heterogeneous) - **T**:* **input** (heterogeneous) - **T**:
17 The tensor to split
1814* **split** (optional, heterogeneous) - **T**: The tensor to split
19 Optional list of output lengths (see also arg 'split')
2015
2116**Outputs****Outputs**
2217
2318Between 1 and 2147483647 outputs.Between 1 and 2147483647 outputs.
2419
2520* **outputs...** (variadic, heterogeneous) - **T**:* **outputs** (variadic, heterogeneous) - **T**:
2621 One or more outputs forming list of tensors after splitting One or more outputs forming list of tensors after splitting
2722
2823**Type Constraints****Type Constraints**
2924
3025* **T** in (* **T** in (
26 tensor(bool),
27 tensor(complex128),
28 tensor(complex64),
3129 tensor(double), tensor(double),
3230 tensor(float), tensor(float),
3331 tensor(float16) 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)
3441 ): ):
3542 Constrain input types to float tensors. Constrain input and output types to all tensor types.

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.