Class ExportContext¶
Defined in File context.hpp
Inheritance Relationships¶
Derived Types¶
public sequant::JuliaTensorOperationsGeneratorContext(Class JuliaTensorOperationsGeneratorContext)public sequant::PythonEinsumGeneratorContext(Class PythonEinsumGeneratorContext)public sequant::ReorderingContext(Class ReorderingContext)public sequant::TextGeneratorContext(Struct TextGeneratorContext)
Class Documentation¶
-
class ExportContext¶
The ExportContext is intended to provide context during export operations. This task is achieved by two core tasks:
Acting as a meta-information storage. Before export starts, certain meta information are collected and stored on the context object.
Providing a customization point for users to influence any export behavior that is not universal for a given backend. In this sense, the context object can be seen as a configuration storage system. The context object has to be user-provided when initiating an export and is passed down to every single function during the export context. Hence, it acts as a communication channel down into the export process.
Subclassed by sequant::JuliaTensorOperationsGeneratorContext, sequant::PythonEinsumGeneratorContext, sequant::ReorderingContext, sequant::TextGeneratorContext
Public Types
-
using TensorStrategyMap = std::map<Tensor, StrategyPair, TensorBlockLessThanComparator>¶
-
using VariableStrategyMap = std::map<Variable, StrategyPair>¶
Public Functions
-
ExportContext() = default¶
-
ExportContext(TensorStrategyMap tensorMap, VariableStrategyMap variableMap = {})¶
-
ExportContext(VariableStrategyMap map)¶
-
virtual ~ExportContext()¶
-
virtual LoadStrategy loadStrategy(const Tensor &tensor) const¶
See also
- Returns:
The LoadStrategy for the given tensor
-
virtual LoadStrategy loadStrategy(const Variable &variable) const¶
See also
- Returns:
The LoadStrategy for the given variable
-
virtual void setLoadStrategy(const Tensor &tensor, LoadStrategy strategy, const std::optional<std::size_t> &expression_id = {})¶
Sets the LoadStrategy for the given tensor
See also
See also
- Parameters:
tensor – The Tensor to set the strategy for
strategy – The LoadStrategy to set
expression_id – The expression for which to set the strategy for. If left unspecified, the strategy will become global. The expression ID is the ID of the root of the associated ExportNode
-
virtual void setLoadStrategy(const Variable &variable, LoadStrategy strategy, const std::optional<std::size_t> &expression_id = {})¶
Sets the LoadStrategy for the given variable
See also
See also
- Parameters:
variable – The Variable to set the strategy for
strategy – The LoadStrategy to set
expression_id – The expression for which to set the strategy for. If left unspecified, the strategy will become global. The expression ID is the ID of the root of the associated ExportNode
-
virtual ZeroStrategy zeroStrategy(const Tensor &tensor) const¶
See also
- Returns:
The ZeroStrategy for the given tensor
-
virtual ZeroStrategy zeroStrategy(const Variable &variable) const¶
See also
- Returns:
The ZeroStrategy for the given variable
-
virtual void setZeroStrategy(const Tensor &tensor, ZeroStrategy strategy, const std::optional<std::size_t> &expression_id = {})¶
Sets the ZeroStrategy for the given tensor
See also
See also
- Parameters:
tensor – The Tensor to set the strategy for
strategy – The ZeroStrategy to set
expression_id – The expression for which to set the strategy for. If left unspecified, the strategy will become global. The expression ID is the ID of the root of the associated ExportNode
-
virtual void setZeroStrategy(const Variable &variable, ZeroStrategy strategy, const std::optional<std::size_t> &expression_id = {})¶
Sets the ZeroStrategy for the given variable
See also
See also
- Parameters:
variable – The Variable to set the strategy for
strategy – The ZeroStrategy to set
expression_id – The expression for which to set the strategy for. If left unspecified, the strategy will become global. The expression ID is the ID of the root of the associated ExportNode
-
virtual bool rewrite(Tensor &tensor) const¶
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
-
virtual bool rewrite(Variable &variable) const¶
Performs necessary (backend-specific) modifications (if any) on the given Variable in-place
- Parameters:
variable – The Variable to be modified
- Returns:
Whether any modification has been performed
-
virtual bool inside_named_section() const¶
- Returns:
Whether the current export workflow is generating code inside a named section
-
virtual const std::string ¤t_section_name() const¶
- Returns:
The name of the current section. If not inside a named section, this function will throw.
-
virtual void set_current_section_name(std::string name)¶
Sets the name of the section that subsequent export shall be for. Implicitly notifies the context that from now on we’re in a named section.
- Parameters:
name – The name of the current section
-
virtual void clear_current_section_name()¶
Resets the current section name. Implicitly notifies the context that we’re no longer inside a named section.
-
virtual bool has_current_expression_id() const¶
- Returns:
Whether or not the ID of the current expression is available
-
virtual std::size_t current_expression_id() const¶
- Returns:
The ID of the current expression. If none is available, this function will throw.
-
virtual void set_current_expression_id(std::size_t id)¶
Sets the current expression ID
- Parameters:
id – The ID of the current expression
-
virtual void clear_current_expression_id()¶
Resets the ID of the current expression.