Function sequant::opt::detail::batchable_mode_list¶
Defined in File single_term_detail.hpp
Function Documentation¶
-
inline container::vector<Index> sequant::opt::detail::batchable_mode_list(TensorNetwork const &network, std::function<bool(Index const&)> const &is_batchable, std::function<bool(Index const&)> const &is_batchable_external = {})¶
Collects the distinct batchable indices (in appearance order) across all tensors in
network.Iterates over every tensor slot (bra, ket, and aux) and appends an index to the result the first time it is seen and
is_batchablereturns true for it. The returned list assigns each index a stable bit position: index at positionkis bitkof a sliced-set bitmaskB.In addition to the top-level slots, two more passes admit pure-occupied indices that
is_batchablenever sees:the pure-occupied protoindices of composite (CSV/PNO/OSV tensor-of-tensor) legs. A composite leg carries its external occupied indices only as protoindices — they never appear as a top-level bra/ket/aux slot — so the slot scan alone drops them.
an explicit pure-occupied index that is open (external) on the network root, i.e. a member of
network.ext_indices(). Such an index is a genuine top-level slot, butis_batchableis typically scoped to a non-occupied space (e.g. DF/RI aux), so it would otherwise never be admitted as a batching candidate. Contracted (internal) occupied indices — those that connect two or more tensors — are not open on the root and so are never admitted by this pass.
Admitting either lets the batched DP slice that external-occ external mode (mirrored in subset_open_aux). Both passes are guarded by index space (only pure-occupied indices are admitted) so PAO/aux/internal-occ recognition is unchanged.
Candidate batchable modes: every index (and protoindex) whose space is batchable in either role.
Batchability is role-based and caller-defined, keeping this layer domain-generic (no index-space kind is named here):
is_batchableadmits a space batchable when the mode is contracted (summed at some node);is_batchable_externaladmits a space batchable when the mode is external (open on the term root — a spectator carried to the result).
This returns the union of both roles. Each mode’s actual role is resolved by PeakBatchedModel::build_context from the root open set, which then drops any mode its role’s predicate rejects — e.g. a mode admitted only as external but appearing contracted is not batchable, which keeps the 2^m search space free of modes that can never be batched in the role they occur in. Protoindices are candidates too: they become plain outer modes in the array view.
- Parameters:
network – The TensorNetwork to scan.
is_batchable – Predicate returning true for indices in a batchable space (e.g. a DF/RI auxiliary space).
- Returns:
Ordered, deduplicated list of batchable indices.