Skip to content

Affine set

affine_set

AffineConstraintKind

Bases: Enum

Source code in xdsl/ir/affine/affine_set.py
 7
 8
 9
10
class AffineConstraintKind(Enum):
    ge = ">="
    le = "<="
    eq = "=="

ge = '>=' class-attribute instance-attribute

le = '<=' class-attribute instance-attribute

eq = '==' class-attribute instance-attribute

AffineConstraintExpr dataclass

Source code in xdsl/ir/affine/affine_set.py
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
@dataclass(frozen=True)
class AffineConstraintExpr:
    kind: AffineConstraintKind
    lhs: AffineExpr
    rhs: AffineExpr

    def __init__(
        self,
        kind: AffineConstraintKind,
        lhs: AffineExpr,
        rhs: AffineExpr,
        *,
        canonicalize: bool = True,
    ):
        if canonicalize:
            lhs = lhs - rhs
            rhs = AffineExpr.constant(0)

        object.__setattr__(self, "kind", kind)
        object.__setattr__(self, "lhs", lhs)
        object.__setattr__(self, "rhs", rhs)

    def __str__(self) -> str:
        return f"{self.lhs} {self.kind.value} {self.rhs}"

kind: AffineConstraintKind instance-attribute

lhs: AffineExpr instance-attribute

rhs: AffineExpr instance-attribute

__init__(kind: AffineConstraintKind, lhs: AffineExpr, rhs: AffineExpr, *, canonicalize: bool = True)

Source code in xdsl/ir/affine/affine_set.py
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
def __init__(
    self,
    kind: AffineConstraintKind,
    lhs: AffineExpr,
    rhs: AffineExpr,
    *,
    canonicalize: bool = True,
):
    if canonicalize:
        lhs = lhs - rhs
        rhs = AffineExpr.constant(0)

    object.__setattr__(self, "kind", kind)
    object.__setattr__(self, "lhs", lhs)
    object.__setattr__(self, "rhs", rhs)

__str__() -> str

Source code in xdsl/ir/affine/affine_set.py
35
36
def __str__(self) -> str:
    return f"{self.lhs} {self.kind.value} {self.rhs}"

AffineSet dataclass

AffineMap represents a map from a set of dimensions and symbols to a multi-dimensional affine expression.

Source code in xdsl/ir/affine/affine_set.py
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
@dataclass(frozen=True)
class AffineSet:
    """
    AffineMap represents a map from a set of dimensions and symbols to a
    multi-dimensional affine expression.
    """

    num_dims: int
    num_symbols: int
    constraints: tuple[AffineConstraintExpr, ...]

    def __str__(self) -> str:
        # Create comma seperated list of dims.
        dims = ", ".join("d" + str(i) for i in range(self.num_dims))
        # Create comma seperated list of symbols.
        syms = ["s" + str(i) for i in range(self.num_symbols)]
        syms = ", ".join(syms)
        # Create comma seperated list of results.
        constraints = ", ".join(str(cnstr) for cnstr in self.constraints)
        if self.num_symbols == 0:
            return f"({dims}) : ({constraints})"
        return f"({dims})[{syms}] : ({constraints})"

num_dims: int instance-attribute

num_symbols: int instance-attribute

constraints: tuple[AffineConstraintExpr, ...] instance-attribute

__init__(num_dims: int, num_symbols: int, constraints: tuple[AffineConstraintExpr, ...]) -> None

__str__() -> str

Source code in xdsl/ir/affine/affine_set.py
50
51
52
53
54
55
56
57
58
59
60
def __str__(self) -> str:
    # Create comma seperated list of dims.
    dims = ", ".join("d" + str(i) for i in range(self.num_dims))
    # Create comma seperated list of symbols.
    syms = ["s" + str(i) for i in range(self.num_symbols)]
    syms = ", ".join(syms)
    # Create comma seperated list of results.
    constraints = ", ".join(str(cnstr) for cnstr in self.constraints)
    if self.num_symbols == 0:
        return f"({dims}) : ({constraints})"
    return f"({dims})[{syms}] : ({constraints})"