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