Class ReorderingContext

Inheritance Relationships

Base Type

Derived Types

Class Documentation

class ReorderingContext : public sequant::ExportContext

An export context class that implements functionality for reordering indices in tensors for better cache locality during access, assuming the full tensor will be held in memory and all elements will be iterated over.

In other words, this class will use existing tensor symmetries to move the slot belonging to the largest index space into the slot with highest cache-locality (depending on the chosen memory layout).

Subclassed by sequant::ItfContext, sequant::JuliaTensorOperationsGeneratorContext, sequant::PythonEinsumGeneratorContext

Public Functions

inline explicit ReorderingContext(MemoryLayout layout)
inline MemoryLayout memory_layout() const
inline void set_memory_layout(MemoryLayout layout)
virtual bool rewrite(Tensor &tensor) const override

Performs necessary (backend-specific) modifications (if any) on the given Tensor in-place

Parameters:

tensor – The Tensor to be modified

Returns:

Whether any modification has been performed

inline bool rewriting_enabled() const
inline void enable_rewriting(bool enable)

Protected Functions

bool is_less(const IndexSpace &lhs, const IndexSpace &rhs) const
bool is_ordered(const IndexSpace &lhs, const IndexSpace &rhs) const
bool needs_swap(const IndexSpace &lhs, const IndexSpace &rhs) const