Class PythonEinsumGeneratorContext

Inheritance Relationships

Base Type

Derived Types

Class Documentation

class PythonEinsumGeneratorContext : public sequant::ExportContext

Base context class for Python einsum generators.

Subclassed by sequant::NumPyEinsumGeneratorContext, sequant::PyTorchEinsumGeneratorContext

Public Types

using ShapeMap = std::map<IndexSpace, std::string>
using TagMap = std::map<IndexSpace, std::string>

Public Functions

PythonEinsumGeneratorContext() = default
~PythonEinsumGeneratorContext() = default
inline PythonEinsumGeneratorContext(ShapeMap index_shapes)
inline bool generate_imports() const

Get whether to generate import statements.

inline void set_generate_imports(bool value)

Set whether to generate import statements.

inline MemoryLayout memory_layout() const

Get the memory layout for tensors.

inline void set_memory_layout(MemoryLayout layout)

Set the memory layout for tensors.

inline std::string get_shape(const IndexSpace &space) const

Get the dimension/shape for a given index space.

inline std::string get_shape_tuple(const Tensor &tensor) const

Get the shape tuple for a tensor.

inline void set_shape(const IndexSpace &space, std::string shape)

Set the dimension/shape for a given index space.

inline std::string get_tag(const IndexSpace &space) const

Get the tag for a given index space Tags are appended to tensor names to distinguish different blocks

inline void set_tag(const IndexSpace &space, std::string tag)

Set the tag for a given index space.

Protected Attributes

ShapeMap m_index_shapes
TagMap m_tags
bool m_generate_imports = true
MemoryLayout m_memory_layout = MemoryLayout::ColumnMajor