Skip to content

strata::Scratch

Part of Evaluation and assignment.

template <tensor_like E, typename Memory>
class strata::Scratch;

E itself, and where an evaluation takes the memory of its buffers from.

Memory is a policy or an allocator as a tensor takes, for the buffers of E and of everything under it, up to a Scratch of its own. Read, sliced and walked as E is. Where nothing under it is worth a buffer, the memory goes unused, which is no error: whether a part is buffered is the cost model's call, and may change. Made by scratch.

A slice, a permutation or a block of it is the same operation on E with the same memory, which keeps E as its own view operations give it. For one that can be copied; a Scratch that holds a temporary owner is cut by the nodes of slice, permute and block.

Template parameters

Name Description
E The expression or view evaluated, as it is held.
Memory A memory policy or an allocator.

Members

Scratch

constexpr Scratch(E operand, Memory memory)

Wraps operand together with the memory its buffers come from.

operand

constexpr const E & operand() const noexcept

The wrapped expression.

memory

constexpr const Memory & memory() const noexcept

The policy or allocator the buffers take their memory from.

shape

constexpr decltype(auto) shape() const

The shape of the operand.

cursor

constexpr auto cursor() const

A cursor over the operand's values.

operator[]

template <index_like... Indices>
constexpr value_type operator[](Indices... indices) const

The operand's element at indices.

slice

template <std::size_t... Axes>
constexpr auto slice(const Scratch &scratch, const std::array<std::size_t, sizeof...(Axes)> &indices)

The slice of the operand, with the same memory.

permute

template <std::size_t... Permutation>
constexpr auto permute(const Scratch &scratch)

The permutation of the operand, with the same memory.

block

template <Extent... Sizes>
constexpr auto block(const Scratch &scratch, const Shape<Sizes...> &sizes, const std::array<std::size_t, sizeof...(Sizes)> &corner)

The block of the operand, with the same memory.