replace(sliceOrigin:sliceDimensions:plane:withBytes:strides:)
Replaces a slice of a plane of this tensor with data from a pointer you provide.
Declaration
func replace(sliceOrigin: MTLTensorExtents, sliceDimensions: MTLTensorExtents, plane: MTLTensorPlaneType, withBytes bytes: UnsafeRawPointer, strides: MTLTensorExtents)Parameters
- sliceOrigin:
An array of per-dimension offsets that together locate the first element to write to in the tensor. Each element in this array corresponds to the dimension at the same index in
sliceDimensions. Each offset value represents the number of elements from the start of that dimension. - sliceDimensions:
An array of per-dimension sizes that together define the extent of the slice to write to in the tensor. Each element in this array corresponds to the dimension at the same index in
sliceOrigin. Each size value represents the number of elements to include along that dimension, starting from the corresponding offset insliceOrigin. - plane:
The plane the method writes data to.
- bytes:
A pointer to bytes of data to copy into the slice.
- strides:
An array of strides, in elements, that describes the layout of the data in
bytes.
Discussion
When writing to auxiliary planes, specify sliceOrigin and sliceDimensions in plane coordinates by applying the auxiliary plane’s block factors.
Create the tensor with storageModeShared for CPU access via this method. Strides must be monotonically non-decreasing: for any i > 0, strides[i] >= strides[i-1] * dimensions[i-1].
The first dimension of sliceOrigin and sliceDimensions must be byte aligned.