closedRange(_:stride:)
Slice the tensor at the specified dimension.
Declaration
static func closedRange(_ range: ClosedRange<Int>, stride: Int = 1) -> any MLTensorRangeExpressionDiscussion
For example:
let x = MLTensor(randomNormal: [1, 3, 28, 28], scalarType: Float.self)
let y = x[..., 0...2] // or x[..., .closedRange(0...2, stride: 1)]
y.shape // is [1, 3, 28, 3]