cast(like:)
Casts the elements of the tensor to the scalar type of the given array.
Declaration
func cast(like other: MLTensor) -> MLTensorParameters
- other:
The other tensor whose scalar type is used for the cast.
Return Value
A new tensor with its contents cast to the scalar type of other.
Discussion
For example:
let x = MLTensor([1, 2, 3], scalarType: Float.self)
let y = MLTensor([1, 2, 3], scalarType: Int32.self)
let z = y.cast(like: x)
z.scalarType // is Float