MemoryOperatorsType
public protocol MemoryOperatorsType
Memory manager for a device
-
Undocumented
Declaration
Swift
associatedtype Device : DeviceType where Self == Self.Device.Memory -
Undocumented
Declaration
Swift
associatedtype RawBuffer : Hashable -
Allocates a buffer with capacity for the amount of elements in the given shape
Declaration
Swift
static func allocateBuffer<Element>(withShape shape: [Int], type: Element.Type) -> ShapedBuffer<Element, Device>Parameters
shapeShape of the buffer to allocate
typeType of elements in the buffer
-
Releases all resources associated with the given buffer
Declaration
Swift
static func free<Element>(_ buffer: ShapedBuffer<Element, Device>)Parameters
bufferBuffer to release
-
Copies values from the given host buffer to the memory of the device
Declaration
Parameters
sourceSource buffer
destinationDevice buffer
countNumber of elements to copy
-
Copies values from the given device buffer to the given host buffer
Declaration
Parameters
sourceDevice buffer
destinationHost buffer
countNumber of elements to copy
-
Retrieves a slice of values from the given buffer
Declaration
Parameters
sliceIndex
bufferBuffer to read from
shapeShape of the buffer
Return Value
The result buffer, a boolean indicating whether the result buffer is a copy (true) or a pointer in the same memory region (false) and the shape of the result.
-
Retrieves a slice of values from the given buffer
Declaration
Parameters
sliceIndex
bufferBuffer to read from
shapeShape of the buffer
Return Value
The result buffer, a boolean indicating whether the result buffer is a copy (true) or a pointer in the same memory region (false) and the shape of the result.
-
Writes a slice into a target buffer
Declaration
Parameters
sliceSlice index
bufferBuffer to write to
dstShapeShape of the destination buffer
sourceBuffer to read from
sourceShapeShape of the source buffer
-
Writes a slice into a target buffer
Declaration
Parameters
sliceSlice index
bufferBuffer to write to
dstShapeShape of the destination buffer
sourceBuffer to read from
sourceShapeShape of the source buffer
-
Returns a buffer that uses the same region of memory but is advanced by the given number of elements
Declaration
Parameters
bufferParent buffer
advancementNumber of elements to advance the start index by
View on GitHub
MemoryOperatorsType Protocol Reference