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))
>>> # (shape of a, shape of b, new shape)
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, …]]]

tensorcircuit.simplify.infer_new_size(a: Node, b: Node, include_old: bool = True) Any[source]¶
tensorcircuit.simplify.pseudo_contract_between(a: Node, b: Node, **kws: Any) Node[source]¶

Contract between Node a and b, with correct shape only and no calculation

Parameters:
  • a (tn.Node) – [description]

  • b (tn.Node) – [description]

Returns:

[description]

Return type:

tn.Node