Class MemoryStack

Class Documentation

class MemoryStack

Simulates the memory stack of a backend that only supports stack-like allocations: an object can only be released if it was the most recently allocated object that is still allocated.

Public Functions

void set_batch_indices(std::span<const Index> indices)

Sets the indices that distinguish otherwise equal tensors (batching).

void allocate(const Tensor &tensor)
void allocate(const Variable &variable)
void release(const Tensor &tensor, std::string_view action)
Parameters:

action – Name of the action causing the release (for diagnostics)

Throws:

Exception – if the tensor is not the top of the stack

void release(const Variable &variable, std::string_view action)
Parameters:

action – Name of the action causing the release (for diagnostics)

Throws:

Exception – if the variable is not the top of the stack

void require_empty() const
Throws:

Exception – if there are objects that have not been released