Skip to main content

Module contract

Module contract 

Source
Expand description

Multi-tensor contraction with optimal contraction order.

This module provides functions to contract multiple tensors efficiently using einsum optimization via the tensorbackend (tenferro-backed implementation).

This module works with concrete types (DynIndex, TensorDynLen) only.

§Main Functions

§Diag Tensor Handling

Diagonal tensors are materialized as dense native operands for contraction, so numeric einsum labels must keep uncontracted logical axes distinct. Diagonal/structured equality metadata is propagated separately onto the result when the contraction leaves equal axes behind.

Structs§

AxisUnionFind
Union-Find data structure for grouping axis IDs.
ContractionOptions
Options for multi-tensor contraction.

Functions§

build_diag_union
Build a union-find structure from a collection of tensors.
collect_sizes
Collect dimension sizes for remapped IDs.
contract_connected
Contract multiple tensors that form a connected graph.
contract_connected_with_options
Contract a connected tensor network with additional options.
contract_multi
Contract multiple tensors into a single tensor, handling disconnected components.
contract_multi_owned
Contract multiple owned tensors into a single tensor.
contract_multi_with_options
Contract multiple tensors into a single tensor with additional options.
print_and_reset_contract_profile
Print and clear the aggregated multi-tensor contraction profile.
remap_output_ids
Remap output IDs using the union-find structure.
remap_tensor_ids
Remap tensor indices using the union-find structure.
reset_contract_profile
Reset the aggregated multi-tensor contraction profile.