Contents

partialRangeUpTo(_:stride:)

Slice the tensor at the specified dimension.

Declaration

static func partialRangeUpTo(_ range: PartialRangeThrough<Int>, stride: Int = 1) -> any MLTensorRangeExpression

Discussion

For example:

let x = MLTensor(randomNormal: [1, 3, 28, 28], scalarType: Float.self)
let y = x[..., ...3] // or x[..., .partialRangeThrough(...3, stride: 1)]
y.shape // is [1, 3, 28, 4]

See Also

Slicing the tensor