Contents

copy(sourceTensor:sourceOrigin:sourceDimensions:destinationTensor: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(sourceTensor: any MTLTensor, sourceOrigin: MTLTensorExtents, sourceDimensions: MTLTensorExtents, 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 in sourceDimensions. 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 in sourceOrigin. Each size value represents the number of elements to include along that dimension, starting from the corresponding offset in sourceOrigin.

  • 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 in destinationDimensions. 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 in destinationOrigin. Each size value represents the number of elements to include along that dimension, starting from the corresponding offset in destinationOrigin.

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.

See Also

Encoding texture copy commands