Template Class JuliaTensorOperationsGenerator

Inheritance Relationships

Base Type

Derived Types

Class Documentation

template<typename Context = JuliaTensorOperationsGeneratorContext>
class JuliaTensorOperationsGenerator : public sequant::Generator<JuliaTensorOperationsGeneratorContext>

Generator for producing Julia code using the ITensor framework

Subclassed by sequant::JuliaITensorGenerator< Context >, sequant::JuliaTensorKitGenerator< Context >

Public Functions

JuliaTensorOperationsGenerator() = default
~JuliaTensorOperationsGenerator() = default
inline virtual std::string get_format_name() const override
Returns:

The name of the format this generator will produce (i.e. the name of the programming language and/or framework)

inline virtual bool supports_named_sections() const override
Returns:

Whether this generator supports named sections

inline virtual bool requires_named_sections() const override
Returns:

Whether this generator requires names (that is, it can’t deal with code outside of named sections)

inline virtual DeclarationScope index_declaration_scope() const override
Returns:

The scope at which this generator would like declare indices

inline virtual DeclarationScope variable_declaration_scope() const override
Returns:

The scope at which this generator would like declare variables

inline virtual DeclarationScope tensor_declaration_scope() const override
Returns:

The scope at which this generator would like declare tensors

inline virtual PrunableScalars prunable_scalars() const override
Returns:

What kinds of scalars may be pruned from the expression tree in order to avoid binary computation steps for them. Instead, all pruned scalars will be multiplied with whatever binary expression remains after pruning. This means that scalar pruning may lead to non-binary expressions that need to be exported by this generator.

inline virtual std::string represent(const Index &idx, const Context&) const override
Returns:

A backend-specific string representation of the given Index

inline virtual std::string represent(const Tensor &tensor, const Context &ctx) const override
Returns:

A backend-specific string representation of the given Tensor

inline virtual std::string represent(const Variable &variable, const Context&) const override
Returns:

A backend-specific string representation of the given Variable

inline virtual std::string represent(const Constant &constant, const Context&) const override
Returns:

A backend-specific string representation of the given Constant

inline virtual void create(const Tensor &tensor, bool zero_init, const Context &ctx) override

Semantic callback for creating the given tensor. This is expected to make the created tensor available for further use.

inline virtual void load(const Tensor &tensor, bool set_to_zero, const Context &ctx) override

Semantic callback for loading the given tensor. Loading implies making the tensor available for subsequent use (e.g. by reading it from disk in order to bring it into RAM).

inline virtual void set_to_zero(const Tensor &tensor, const Context &ctx) override

Semantic callback for setting the given tensor to zero.

inline virtual void unload(const Tensor &tensor, const Context &ctx) override

Semantic callback for unloading the given tensor. This is expected to discard the tensor without saving its current value. However, the tensor must still be loadable afterwards.

inline virtual void destroy(const Tensor &tensor, const Context &ctx) override

Semantic callback for destroying the given tensor. Destroying means that this tensor will never be needed again and is no longer required to be loadable.

inline virtual void persist(const Tensor &tensor, const Context &ctx) override

Semantic callback for persisting the given tensor. Persisting means that the current value of the tensor is stored in some way that makes its value available at a later time.

inline virtual void create(const Variable &variable, bool zero_init, const Context &ctx) override

Semantic callback for creating the given variable. This is expected to make the created variable available for further use.

inline virtual void load(const Variable &variable, bool set_to_zero, const Context &ctx) override

Semantic callback for loading the given variable. Loading implies making the variable available for subsequent use (e.g. by reading it from disk in order to bring it into RAM).

inline virtual void set_to_zero(const Variable &variable, const Context &ctx) override

Semantic callback for setting the given variable to zero.

inline virtual void unload(const Variable &variable, const Context &ctx) override

Semantic callback for unloading the given variable. This is expected to discard the variable without saving its current value. However, the variable must still be loadable afterwards.

inline virtual void destroy(const Variable &variable, const Context &ctx) override

Semantic callback for destroying the given variable. Destroying means that this variable will never be needed again and is no longer required to be loadable.

inline virtual void persist(const Variable &variable, const Context &ctx) override

Semantic callback for persisting the given variable. Persisting means that the current value of the variable is stored in some way that makes its value available at a later time.

inline virtual void compute(const Expr &expression, const Tensor &result, const Context &ctx) override

Semantic callback for encoding the computation of the given expression. The result is expected to be written into the provided Tensor.

inline virtual void compute(const Expr &expression, const Variable &result, const Context &ctx) override

Semantic callback for encoding the computation of the given expression. The result is expected to be written into the provided Variable.

inline virtual void declare(const Index&, const Context&) override

Semantic callback for declaring the provided Index.

inline virtual void declare(const Variable&, UsageSet, const Context&) override

Semantic callback for declaring the provided Variable

Parameters:
inline virtual void declare(const Tensor&, UsageSet, const Context&) override

Semantic callback for declaring the provided Tensor

Parameters:
  • variable – The Tensor to declare

  • usage – A UsageSet describing how the Tensor will be used in the code

inline virtual void all_indices_declared(std::size_t, const Context&) override

Callback signalling that all indices have been declared

Parameters:

amount – The amount of indices that have been declared

inline virtual void all_variables_declared(std::size_t, const Context&) override

Callback signalling that all variables have been declared

Parameters:

amount – The amount of variables that have been declared

inline virtual void all_tensors_declared(std::size_t, const Context&) override

Callback signalling that all tensors have been declared

Parameters:

amount – The amount of tensors that have been declared

inline virtual void begin_declarations(DeclarationScope, const Context&) override

Callback signalling that we now start declarations for the given scope.

inline virtual void end_declarations(DeclarationScope, const Context&) override

Callback signalling that all declarations for the given scope have been performed

inline virtual void insert_comment(const std::string &comment, const Context&) override

Semantic callback for inserting a comment at the current position in the generated code

Parameters:

comment – The comment to insert

inline virtual void begin_named_section(std::string_view, const Context&) override

Semantic callback that we are starting a new named section

Parameters:

name – The name of the named section

inline virtual void end_named_section(std::string_view, const Context&) override

Semantic callback to signal that we have reached the end of the current named section

Parameters:

name – The name of the named section that is ending now

inline virtual void begin_expression(const Context&) override

Callback signalling that we now begin export of a new (high-level) expression

inline virtual void end_expression(const Context&) override

Callback signalling that the export of the current (high-level) expression is finished

inline virtual void begin_export(const Context&) override

Callback signalling that we now begin with the export process.

inline virtual void end_export(const Context&) override

Callback signalling that the export process is finished.

inline virtual std::string get_generated_code() const override
Returns:

The generated code that corresponds to all semantic actions encountered during the current export

Protected Functions

inline std::string to_julia_expr(const Expr &expr, const Context &ctx) const
inline std::string tensor_name(const Tensor &tensor, const Context &ctx) const
inline std::string zero_initialization(const Tensor &tensor, const Context &ctx) const

Protected Attributes

std::string m_generated