Table of Contents

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

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

buffer CpuMemoryBuffer

The buffer to get the span from.

Returns

ReadOnlySpan<T>

A read-only span of the specified type.

Type Parameters

T

The 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

buffer CpuMemoryBuffer

The buffer to get the span from.

Returns

Span<T>

A span of the specified type.

Type Parameters

T

The element type.

Exceptions

ArgumentNullException

Thrown when buffer is null.

ArgumentException

Thrown when the buffer size is not compatible with the element type.