Class CpuMemoryBufferExtensions
- Namespace
- DotCompute.Backends.CPU.Extensions
- Assembly
- DotCompute.Backends.CPU.dll
Extension methods for CpuMemoryBuffer to provide generic access methods required by the memory manager and backward compatibility.
public static class CpuMemoryBufferExtensions
- Inheritance
-
CpuMemoryBufferExtensions
- Inherited Members
Methods
CreateView<T>(CpuMemoryBuffer, int, int)
Creates a view of the buffer with the specified offset and length. This provides backward compatibility for code expecting this method.
public static CpuMemoryBufferTyped<T> CreateView<T>(this CpuMemoryBuffer buffer, int offset, int length) where T : unmanaged
Parameters
bufferCpuMemoryBufferThe buffer to create a view from.
offsetintThe element offset.
lengthintThe number of elements in the view.
Returns
- CpuMemoryBufferTyped<T>
A buffer view with the specified range.
Type Parameters
TThe element type.
Exceptions
- ArgumentNullException
Thrown when buffer is null.
GetReadOnlySpan<T>(CpuMemoryBuffer)
Gets a typed read-only span from a CpuMemoryBuffer by casting the underlying byte span.
public static ReadOnlySpan<T> GetReadOnlySpan<T>(this CpuMemoryBuffer buffer) where T : unmanaged
Parameters
bufferCpuMemoryBufferThe buffer to get the span from.
Returns
- ReadOnlySpan<T>
A read-only span of the specified type.
Type Parameters
TThe element type.
Exceptions
- ArgumentNullException
Thrown when buffer is null.
- ArgumentException
Thrown when the buffer size is not compatible with the element type.
GetSpan<T>(CpuMemoryBuffer)
Gets a typed span from a CpuMemoryBuffer by casting the underlying byte span.
public static Span<T> GetSpan<T>(this CpuMemoryBuffer buffer) where T : unmanaged
Parameters
bufferCpuMemoryBufferThe buffer to get the span from.
Returns
- Span<T>
A span of the specified type.
Type Parameters
TThe element type.
Exceptions
- ArgumentNullException
Thrown when buffer is null.
- ArgumentException
Thrown when the buffer size is not compatible with the element type.