Class EvalExpr¶
Defined in File eval_expr.hpp
Inheritance Relationships¶
Derived Types¶
public sequant::ExportExpr(Class ExportExpr)public sequant::eval::dryrun::EvalExprDryRun(Class EvalExprDryRun)
Class Documentation¶
-
class EvalExpr¶
The EvalExpr is a building block of binary trees used to evaluate expressions.
The EvalExpr class itself is not a proper node of the binary tree. It is rather a data that a node should hold.
Subclassed by sequant::ExportExpr, sequant::eval::dryrun::EvalExprDryRun
Public Types
-
using index_vector = Index::index_vector¶
Public Functions
- Parameters:
op – Evaluation operation resulting to this object.
res – Evaluation result type that will be produced.
expr – A SeQuant expression corresponding to
res.ixs – Canonical indices used for annotating the result’s modes if
resis tensor type. Possibly empty for non-tensorrestype.phase – Phase that was part of the tensor network canonicalization. Considered for reusing sub-expressions.
hash – A hash value that is equal for two EvalExpr objects that produce the same evaluated result modulo the
phase.connectivity – The graph representing the connectivity. May be null to indicate that no graph is present/necessary.
-
const std::optional<EvalOp> &op_type() const noexcept¶
- Returns:
Operation type of this expression, or null if this is a primary expression.
-
ResultType result_type() const noexcept¶
- Returns:
The ResultType of the evaluation performed on this node.
-
size_t hash_value() const noexcept¶
Compute the hash value of this EvalExpr object.
The hash value is computed during construction of the object by also looking at the hash values of the EvalExpr objects if passed.
- Returns:
The hash value of this EvalExpr object.
-
bool tot() const noexcept¶
- Returns:
True if this EvalExpr object contains a SeQuant tensor with proto-indices, false otherwise.
-
std::wstring to_latex() const noexcept¶
- Returns:
Returns the result of calling to_latex() on the ExprPtr object contained by this object.
-
Expr::type_id_type type_id() const noexcept¶
- Returns:
The type id of the Expr held by this object.
-
bool is_tensor() const noexcept¶
-
bool is_scalar() const noexcept¶
-
bool is_primary() const noexcept¶
- Returns:
True if this is a primary expression (i.e. a leaf on expression tree)
-
bool is_product() const noexcept¶
- Returns:
True if this expression is a product.
-
bool is_sum() const noexcept¶
- Returns:
True if this expression is a sum.
-
bool is_adjoint() const noexcept¶
- Returns:
True if this expression is an adjoint (unary) node.
-
Tensor const &as_tensor() const¶
Calls to<Tensor>() on ExprPtr held by this object.
- Returns:
Tensor const&
-
Constant const &as_constant() const¶
Calls to<Constant>() on ExprPtr held by this object.
- Returns:
Constant const&.
-
Variable const &as_variable() const¶
Calls to<Variable>() on ExprPtr held by this object.
- Returns:
Variable const&
-
Power const &as_power() const¶
Calls to<Power>() on ExprPtr held by this object.
- Returns:
Power const&
-
std::string label() const noexcept¶
Get the label for this object useful for logging.
-
std::string indices_annot() const noexcept¶
- Returns:
A string usable as TiledArray annotation if is_tensor() true, empty string otherwise.
-
index_vector const &canon_indices() const noexcept¶
- Returns:
Canonically ordered indices — non-empty if this object represents a tensor result.
-
std::int8_t canon_phase() const noexcept¶
- Returns:
The canonicalization phase (+1 or -1).
-
bool has_connectivity_graph() const noexcept¶
See also
- Returns:
Whether this expression has a connectivity graph
-
const bliss::Graph &connectivity_graph() const noexcept¶
See also
Note
If has_connectivity_graph returns false, this function must not be called
- Returns:
The graph representing the connectivity of two factors in a product
-
std::shared_ptr<bliss::Graph> copy_connectivity_graph() const noexcept¶
- Returns:
A copy of the graph representing the connectivity of two factors in a product
-
inline container::svector<std::pair<Index, BatchModeType>> const &node_slice_mask() const noexcept¶
Batchable indices the single-term optimizer chose to slice at this node (its DP
aprime), each tagged with itsBatchModeType. Empty unless set bybinarizefromBinarizationOptions::node_batch_axes(itself populated fromOptimizeOptions::term_batch_axesby the optimizer). The runtime batched evaluator slices exactly these indices at this node.
-
inline void set_node_slice_mask(container::svector<std::pair<Index, BatchModeType>> modes) noexcept¶
Sets the batch modes for this node; see
node_slice_mask.
-
inline container::svector<std::pair<Index, BatchModeType>> const &batch_loops_opened_here() const noexcept¶
Batch loops opened at this node: the subset of
node_slice_mask()for which this node is the loop-open site (the outermost node introducing the physical batch loop), as opposed to a deeper node that only carries the sliced mode. Empty unless set bybinarizefromNodeBatchAnnotation::opened_here. Unlikenode_slice_mask()— which the runtime consults per node to slice that node’s operands, and which the DP stamps on every carrying node — this names each physical loop exactly once, so a consumer reconstructing the enclosing-loop nest (e.g.peak_profile'sOccurrenceRec::ectx) does not multi-count one loop as one-per-carrying-node.
-
inline void set_batch_loops_opened_here(container::svector<std::pair<Index, BatchModeType>> modes) noexcept¶
Sets the loop-open modes for this node; see
batch_loops_opened_here.
-
inline container::svector<Index> const &sliced_modes() const noexcept¶
Canonical batch modes that slice this node in every occurrence (the cross-occurrence meet; see
stamp_lifetime_masks). Empty => all-full (block-agnostic, run-scope). Proto-aware: a composite slot contributes its proto indices. Set bystamp_lifetime_masks; empty by default (off path).
-
inline void set_sliced_modes(container::svector<Index> m) noexcept¶
Sets the cross-occurrence sliced-mode mask; see
sliced_modes.
-
inline bool mask_all_full() const noexcept¶
Whether this node’s sliced-mode mask is empty (all modes full / block-agnostic). Equivalent to
sliced_modes().empty().
-
inline container::svector<Index> const &occurrence_home() const noexcept¶
The batch modes that slice this occurrence of the node: the loops opened at or above it that live on its own result slots. The value’s home in the table-driven engine (explicit-cells design section 11,
home_scope/value_key_of), stamped per occurrence bystamp_occurrence_homes— not the cross-occurrence meet (sliced_modes), which folds occurrences by node identity and by label and serves the forest-descent path’s residency. Empty = whole.
-
inline void set_occurrence_home(container::svector<Index> m) noexcept¶
Sets this occurrence’s home; see
occurrence_home.
-
inline std::size_t value_key() const noexcept¶
This occurrence’s value key (explicit-cells design section 11): node id + (position, loop slot) of every home-sliced position + the operands’ keys, stamped by
compute_dag_boulevardonce loop instances are numbered; 0 = not stamped (value_key_ofthen falls back to the structural key).
-
inline void set_value_key(std::size_t k) noexcept¶
Sets this occurrence’s value key; see
value_key.
-
inline bool accumulate_in_place() const noexcept¶
Whether this
Sumnode’s result should be accumulated in place into its left operand rather than materialized as a fresh value. Set bybinarizeon the accumulation-chainSumnodes produced when an N-arySumis folded into binarySumnodes: for a chain(((t1+t2)+t3)+t4), every binarySum'sleft operand is the running accumulator (the chain seed or a prior chainSum), so every chainSumis markedtrue. Never set based on the right operand. Defaultfalse(off path, behavior-neutral).
-
inline void set_accumulate_in_place(bool v) noexcept¶
Sets the in-place accumulation flag; see
accumulate_in_place.
-
inline std::size_t batch_effective_count() const noexcept¶
Emitted effective use count of this contraction node: the number of times its value is (re)referenced across the enclosing batch loops it does not carry.
1(the default and the order-blind / off-path value) means the node is used once (no across-loop reuse). SeeNodeBatchAnnotation::effective_count.
-
inline bool batch_order_aware() const noexcept¶
Whether the order-aware cost model emitted this node — the per-level placement order-aware gate.
false(default, off path) means the node is never hoisted. SeeNodeBatchAnnotation::order_aware.
-
inline void set_batch_order_aware(bool v) noexcept¶
Sets the order-aware placement gate; see
batch_order_aware.
-
inline void set_batch_effective_count(std::size_t count) noexcept¶
Sets the effective use count; see
batch_effective_count.
Protected Attributes
-
ResultType result_type_¶
-
index_vector canon_indices_¶
-
std::int8_t canon_phase_ = {1}¶
-
size_t hash_value_¶
-
std::shared_ptr<bliss::Graph> connectivity_¶
-
container::svector<std::pair<Index, BatchModeType>> node_slice_mask_ = {}¶
See
node_slice_mask.
-
container::svector<std::pair<Index, BatchModeType>> batch_loops_opened_here_ = {}¶
See
batch_loops_opened_here.
-
std::size_t value_key_ = 0¶
-
bool batch_order_aware_ = false¶
See
batch_order_aware.
-
std::size_t batch_effective_count_ = 1¶
See
batch_effective_count.
-
bool accumulate_in_place_ = false¶
See
accumulate_in_place.
Friends
- friend struct EvalOpSetter
-
using index_vector = Index::index_vector¶