Table of Contents

Struct TensorRental<T>

Namespace
AiDotNet.JitCompiler.Memory
Assembly
AiDotNet.dll

Provides a scoped rental of a tensor buffer that automatically returns to the pool.

public readonly struct TensorRental<T> : IDisposable

Type Parameters

T

The element type of the tensor.

Implements
Inherited Members

Remarks

For Beginners: A convenient way to use pooled buffers with automatic cleanup.

Instead of manually calling Rent and Return, use this with a 'using' statement:

Example: using (var rental = new TensorRental<float>(pool, 1000)) { // Use rental.Buffer for computation // Buffer is automatically returned when leaving this block }

Constructors

TensorRental(TensorPool, int)

Creates a new tensor rental.

public TensorRental(TensorPool pool, int totalElements)

Parameters

pool TensorPool

The pool to rent from.

totalElements int

Number of elements needed.

Properties

Buffer

The rented buffer.

public T[] Buffer { get; }

Property Value

T[]

Methods

Dispose()

Returns the buffer to the pool.

public void Dispose()