Contents

squeezingShape()

Returns a new squeezed shaped array.

Declaration

func squeezingShape() -> MLShapedArraySlice<Scalar>

Discussion

The new shape removes 1s in the original shape.

let original = MLShapedArraySlice<Int32>(scalars: 0..., shape: [1, 2, 1, 2])
let squeezed = original.squeezed()
squeezed.shape // [2, 2]

When all the dimensions of the original shape is one, the resultant shaped array is a scalar.

let original = MLShapedArray<Int32>(scalars: 42, shape: [1, 1])
let squeezed = original.squeezed()
squeezed.scalar // 42

See Also

Shaping the array slice