cast(to:)
Casts the elements of the tensor to the given scalar type.
Declaration
func cast<Scalar>(to scalarType: Scalar.Type) -> MLTensor where Scalar : MLTensorScalarParameters
- scalarType:
The destination scalar type.
Return Value
A new tensor with its contents cast to the given scalar type.
Discussion
For example:
let x = MLTensor([1, 2, 3], scalarType: Int32.self)
let y = x.cast(to: Float.self)
y.scalarType // is Float