Skip to content

quad

quad ¤

QuadGraph(shape) ¤

Constructs a Quad Graph region graph.

See
  • Unifying and understanding overparameterized circuit representations via low-rank tensor decompositions. 🔗 Mari, Antonio, Gennaro Vessio, and Antonio Vergari. In The 6th Workshop on Tractable Probabilistic Modeling. 2023.

Parameters:

Name Type Description Default
shape tuple[int, int, int]

The image shape \((C, H, W)\), where \(H\) is the height, \(W\) is the width, and \(C\) is the number of channels.

required

Returns:

Name Type Description
RegionGraph RegionGraph

A Quad Graph region graph.

Raises:

Type Description
ValueError

The image shape is not valid.

Source code in cirkit/templates/region_graph/algorithms/quad.py
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
def QuadGraph(shape: tuple[int, int, int]) -> RegionGraph:
    r"""Constructs a Quad Graph region graph.

    See:
        - *Unifying and understanding overparameterized circuit representations via low-rank tensor decompositions.* [🔗](https://openreview.net/forum?id=1btutFdIya)
          Mari, Antonio, Gennaro Vessio, and Antonio Vergari.
          In The 6th Workshop on Tractable Probabilistic Modeling. 2023.

    Args:
        shape: The image shape $(C, H, W)$, where $H$ is the height, $W$ is the width,
            and $C$ is the number of channels.

    Returns:
        RegionGraph: A Quad Graph region graph.

    Raises:
        ValueError: The image shape is not valid.
    """
    return _QuadBuilder(shape, is_tree=False)

QuadTree(shape, *, num_patch_splits=2) ¤

Constructs a Quad Tree region graph.

See
  • Unifying and understanding overparameterized circuit representations via low-rank tensor decompositions. 🔗 Mari, Antonio, Gennaro Vessio, and Antonio Vergari. In The 6th Workshop on Tractable Probabilistic Modeling. 2023.

Parameters:

Name Type Description Default
shape tuple[int, int, int]

The image shape \((C, H, W)\), where \(H\) is the height, \(W\) is the width, and \(C\) is the number of channels.

required
num_patch_splits int

The number of splits per patitioning, it can be either 2 or 4.

2

Returns:

Name Type Description
RegionGraph RegionGraph

A Quad Tree region graph.

Raises:

Type Description
ValueError

The image shape is not valid.

ValueError

The number of patches to split is not valid.

Source code in cirkit/templates/region_graph/algorithms/quad.py
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
def QuadTree(shape: tuple[int, int, int], *, num_patch_splits: int = 2) -> RegionGraph:
    r"""Constructs a Quad Tree region graph.

    See:
        - *Unifying and understanding overparameterized circuit representations via low-rank tensor decompositions.* [🔗](https://openreview.net/forum?id=1btutFdIya)
          Mari, Antonio, Gennaro Vessio, and Antonio Vergari.
          In The 6th Workshop on Tractable Probabilistic Modeling. 2023.

    Args:
        shape: The image shape $(C, H, W)$, where $H$ is the height, $W$ is the width,
            and $C$ is the number of channels.
        num_patch_splits: The number of splits per patitioning, it can be either 2 or 4.

    Returns:
        RegionGraph: A Quad Tree region graph.

    Raises:
        ValueError: The image shape is not valid.
        ValueError: The number of patches to split is not valid.
    """
    return _QuadBuilder(shape, is_tree=True, num_patch_splits=num_patch_splits)