Skip to content

registry

registry ¤

LayerOptMatch = GraphOptMatch[TorchLayer] module-attribute ¤

LayerOptPattern = type[LayerOptPatternDefn] module-attribute ¤

LayerOptPatternDefn = GraphOptPatternDefn[TorchLayer] module-attribute ¤

ParameterOptMatch = GraphOptMatch[TorchParameterNode] module-attribute ¤

ParameterOptPattern = type[ParameterOptPatternDefn] module-attribute ¤

ParameterOptPatternDefn = GraphOptPatternDefn[TorchParameterNode] module-attribute ¤

LayerOptApplyFunc ¤

Bases: Protocol

Source code in cirkit/backend/torch/optimization/registry.py
29
30
31
32
class LayerOptApplyFunc(Protocol):
    def __call__(
        self, compiler: "TorchCompiler", match: LayerOptMatch
    ) -> tuple[TorchLayer, ...]: ...

__call__(compiler, match) ¤

Source code in cirkit/backend/torch/optimization/registry.py
30
31
32
def __call__(
    self, compiler: "TorchCompiler", match: LayerOptMatch
) -> tuple[TorchLayer, ...]: ...

LayerOptRegistry ¤

Bases: CompilerRegistry[LayerOptPattern, LayerOptApplyFunc]

Source code in cirkit/backend/torch/optimization/registry.py
44
45
46
47
48
49
50
class LayerOptRegistry(CompilerRegistry[LayerOptPattern, LayerOptApplyFunc]):
    @classmethod
    def _validate_rule_function(cls, func: LayerOptApplyFunc) -> bool:
        ann = func.__annotations__.copy()
        del ann["return"]
        args = tuple(ann.keys())
        return ann[args[-1]] == LayerOptMatch

ParameterOptApplyFunc ¤

Bases: Protocol

Protocol defining the signature of a parameter optimization rule.

Source code in cirkit/backend/torch/optimization/registry.py
21
22
23
24
25
26
class ParameterOptApplyFunc(Protocol):
    """Protocol defining the signature of a parameter optimization rule."""

    def __call__(
        self, compiler: "TorchCompiler", match: ParameterOptMatch
    ) -> tuple[TorchParameterNode, ...]: ...

__call__(compiler, match) ¤

Source code in cirkit/backend/torch/optimization/registry.py
24
25
26
def __call__(
    self, compiler: "TorchCompiler", match: ParameterOptMatch
) -> tuple[TorchParameterNode, ...]: ...

ParameterOptRegistry ¤

Bases: CompilerRegistry[ParameterOptPattern, ParameterOptApplyFunc]

Source code in cirkit/backend/torch/optimization/registry.py
35
36
37
38
39
40
41
class ParameterOptRegistry(CompilerRegistry[ParameterOptPattern, ParameterOptApplyFunc]):
    @classmethod
    def _validate_rule_function(cls, func: ParameterOptApplyFunc) -> bool:
        ann = func.__annotations__.copy()
        del ann["return"]
        args = tuple(ann.keys())
        return ann[args[-1]] == ParameterOptMatch