Skip to content
fn

split_op

→vector<TensorImplPtr>
int split_op(const int & a, int num_splits, int axis)

Python wrappers

Public Python APIs implemented by this engine symbol.

Split a tensor into a fixed number of equal pieces along an axis.

The size of a along axis must be divisible by num_splits. Each output piece is wired with a SplitSliceBackward node that scatters its gradient back into the correct slice of the input gradient via insert_axis_slice.

See Also

split_at_op, chunk_op, unbind_op.

Parameters

aTensorImplPtr
Input tensor.
num_splitsint64_t
Number of equal pieces. Must divide a.shape[axis] exactly.
axisint
Axis to split along. Supports negative indexing.

Returns

vector<TensorImplPtr>

num_splits tensors, each with shape identical to a except the axis dimension equals a.shape[axis] / num_splits.

Raises

ShapeMismatch
If a.shape[axis] is not divisible by num_splits.