fhelium.backend.fusion
Describe fhelium_rns.fused regions for fusion implementations.
A FusedRegion is the dataflow of one fused region: its inputs are the distinct Tensors the region reads, in operand order of the lowered call, its operations are RNS and NTT operations in program order and its outputs are the values the region returns. Each value carries the storage and residue facts that code generation reads; each operation carries its name, attribute values and the residue structure registered for it in fhelium.ir._operations.
FusedRegion
class View source
FusedRegion(inputs: tuple[RegionValue, ...], operations: tuple[RegionOperation, ...], outputs: tuple[RegionValue, ...], implementation: str)Dataflow of one fhelium_rns.fused region and the fusion implementation it names.
Attributes
| Name | Type | Default/value |
|---|---|---|
inputs | tuple[RegionValue, ...] | |
operations | tuple[RegionOperation, ...] | |
outputs | tuple[RegionValue, ...] | |
implementation | str |
add
method
def add(name: str, operands: Sequence[RegionValue], results: Sequence[tuple[ValueKind, Mapping[str, object]]], attributes: Mapping[str, object]) -> RegionOperation: ...Append an operation whose results have the given kinds and states.
key
method
def key() -> tuple[object, ...]: ...Return a hashable description of the region.
Regions with equal keys name the same implementation and have the same value kinds and states, operation names and attributes, and dataflow, so one prepared fusion serves both.
escapes
method
def escapes(value: RegionValue) -> bool: ...Whether value is a region output.
RegionOperation
class View source
RegionOperation(name: str, operands: tuple[RegionValue, ...], results: tuple[RegionValue, ...], attributes: Mapping[str, object])One operation of a fused region with its attribute values and registered residue structure.
Attributes
| Name | Type | Default/value |
|---|---|---|
name | str | |
operands | tuple[RegionValue, ...] | |
results | tuple[RegionValue, ...] | |
attributes | Mapping[str, object] | |
structure | OperationStructure | None | field(init=False) |
RegionValue
class View source
RegionValue(kind: ValueKind, state: Mapping[str, object], owner: RegionOperation | None=None)One value of a fused region.
state holds the facts known for the value: shape, strides, dtype and device of its storage, and residue facts such as prime_ids, ring_dimension, batch_shape, components (present when storage has a leading component axis), polynomial_domain and residue_representation. owner is the operation that defines the value, or None for a region input; uses lists its consumers as (operation, operand index).
component_axis
property
component_axis: boolWhether storage has a leading ciphertext component axis.
shape
property
shape: tuple[int, ...] | NoneValueKind
type alias View source
ValueKind = Literal['polynomial', 'compressed', 'key', 'parameters', 'table']