copy(from:sourceOrigin:sourceDimensions:to:destinationOrigin:destinationDimensions:)
Encodes a command to copy data from a slice of the data plane of a tensor into a slice of the data plane of another tensor.
Declaration
func copy(from sourceTensor: any MTLTensor, sourceOrigin: MTLTensorExtents, sourceDimensions: MTLTensorExtents, to destinationTensor: any MTLTensor, destinationOrigin: MTLTensorExtents, destinationDimensions: MTLTensorExtents)Parameters
- sourceTensor:
A tensor instance the method copies data from.
- sourceOrigin:
An array of per-dimension offsets that together locate the first element to copy in
sourceTensor. Each element in this array corresponds to the dimension at the same index insourceDimensions. Each offset value represents the number of elements from the start of that dimension. - sourceDimensions:
An array of per-dimension sizes that together define the extent of the slice to copy from
sourceTensor. Each element in this array corresponds to the dimension at the same index insourceOrigin. Each size value represents the number of elements to include along that dimension, starting from the corresponding offset insourceOrigin. - destinationTensor:
A tensor instance the method copies data to.
- destinationOrigin:
An array of per-dimension offsets that together locate the first element to write in
destinationTensor. Each element in this array corresponds to the dimension at the same index indestinationDimensions. Each offset value represents the number of elements from the start of that dimension. - destinationDimensions:
An array of per-dimension sizes that together define the extent of the slice to write in
destinationTensor. Each element in this array corresponds to the dimension at the same index indestinationOrigin. Each size value represents the number of elements to include along that dimension, starting from the corresponding offset indestinationOrigin.
Discussion
If sourceTensor and destinationTensor are not aliasable, this command applies a reshape operation.
Ensure the first dimension of sourceOrigin, sourceDimensions, destinationOrigin, and destinationDimensions is byte aligned.