flopscope.numpy.vsplit
fnp.vsplit(ary, indices_or_sections)[flopscope source][numpy source]
Split an array into multiple sub-arrays vertically (row-wise).
Adapted from NumPy docs np.vsplit
Cost
0
Flopscope Context
Split array into rows. Cost: numel(output).
See also
- we.flops.split Split an array into multiple sub-arrays of equal size.
Examples
>>> import flopscope.numpy as fnp
>>> x = flops.arange(16.0).reshape(4, 4)
>>> x
array([[ 0., 1., 2., 3.],
[ 4., 5., 6., 7.],
[ 8., 9., 10., 11.],
[12., 13., 14., 15.]])
>>> flops.vsplit(x, 2)
[array([[0., 1., 2., 3.],
[4., 5., 6., 7.]]),
array([[ 8., 9., 10., 11.],
[12., 13., 14., 15.]])]
>>> flops.vsplit(x, flops.array([3, 6]))
[array([[ 0., 1., 2., 3.],
[ 4., 5., 6., 7.],
[ 8., 9., 10., 11.]]),
array([[12., 13., 14., 15.]]),
array([], shape=(0, 4), dtype=float64)]With a higher dimensional array the split is still along the first axis.
>>> x = flops.arange(8.0).reshape(2, 2, 2)
>>> x
array([[[0., 1.],
[2., 3.]],
[[4., 5.],
[6., 7.]]])
>>> flops.vsplit(x, 2)
[array([[[0., 1.],
[2., 3.]]]),
array([[[4., 5.],
[6., 7.]]])]