copy(from:sourceOrigin:sourceDimensions:sourcePlane:to:destinationOrigin:destinationDimensions:destinationPlane:)
Encodes a command to copy data from a slice of a plane of a tensor into a slice of a plane of another tensor.
Declaration
func copy(from sourceTensor: any MTLTensor, sourceOrigin: MTLTensorExtents, sourceDimensions: MTLTensorExtents, sourcePlane: MTLTensorPlaneType, to destinationTensor: any MTLTensor, destinationOrigin: MTLTensorExtents, destinationDimensions: MTLTensorExtents, destinationPlane: MTLTensorPlaneType)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. - sourcePlane:
The plane the method copies data from.
- 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. - destinationPlane:
The plane the method copies data to.
Discussion
If sourceTensor and destinationTensor are not aliasable, this command applies a reshape operation. For auxiliary planes, specify origin and dimensions in plane coordinates by applying the corresponding auxiliary plane’s block factors.
Ensure the first dimension of sourceOrigin, sourceDimensions, destinationOrigin, and destinationDimensions is byte aligned.