tensorcircuit.simplify¶
Tensornetwork Simplification
- tensorcircuit.simplify.infer_new_shape(a: Node, b: Node, include_old: bool = True) Any[source]¶
Get the new shape of two nodes, also supporting to return original shapes of two nodes.
- Example:
a = tn.Node(np.ones([2, 3, 5])) b = tn.Node(np.ones([3, 5, 7])) a[1] ^ b[0] a[2] ^ b[1] tc.simplify.infer_new_shape(a, b) # ((2, 7), (2, 3, 5), (3, 5, 7)) # return order: (new_shape, shape_of_a, shape_of_b)
- Parameters:
a (tn.Node) – node one
b (tn.Node) – node two
include_old (bool) – Whether to include original shape of two nodes, default is True.
- Returns:
The new shape of the two nodes.
- Return type:
Union[Tuple[int, …], Tuple[Tuple[int, …], Tuple[int, …], Tuple[int, …]]]