Contents

transfer(to:)

Transfer the contents to the destination multi-array.

Declaration

func transfer(to destinationMultiArray: MLMultiArray)

Parameters

  • destinationMultiArray:

    The transfer destination.

Discussion

Numeric data will be up or down casted as needed. It can transfer to a multi-array with different layout (strides).

let sourceMultiArray: MLMultiArray = ... // shape is [2, 3] and data type is Float64

let newStrides = [4, 1]
let destinationMultiArray = MLMultiArray(shape: [2, 3], 
                                         dataType: .float32, 
                                         strides: newStrides)
sourceMultiArray.transfer(to: destinationMultiArray)
NSArray<NSNumber *> *shape = @[@2, @3];
NSArray<NSNumber *> *sourceStrides = @[@3, @1];
NSArray<NSNumber *> *destinationStrides = @[@4, @1];
MLMultiArray *source = [[MLMultiArray alloc] initWithShape:shape
                                                  dataType:MLMultiArrayDataTypeDouble
                                                   strides:sourceStrides];
// Initialize source...

MLMultiArray *destination = [[MLMultiArray alloc] initWithShape:shape
                                                       dataType:MLMultiArrayDataTypeFloat32
                                                        strides:destinationStrides];
[source transferToMultiArray:destination];