fhelium.backend.triton._expressions
Component expression graphs and indexed loads for Triton code generation.
ARITHMETIC_OPS
constant View source
python
ARITHMETIC_OPS = (ckks.AddCompressedPlaintextOp, ckks.MultiplyCompressedPlaintextOp, rns.AddStandardOp, rns.SubtractStandardOp, rns.NegateStandardOp, rns.MontgomeryMultiplyOp, rns.AddMontgomeryLazyOp, rns.MultiplyPlaintextOp, rns.AddPlaintextOp, rns.StandardToMontgomeryOp, rns.MontgomeryToStandardOp)1
STRUCTURAL_OPS
constant View source
python
STRUCTURAL_OPS = (rns.ExtractComponentOp, rns.PackTwoComponentsOp, rns.PackThreeComponentsOp)1
NTT_OPS
constant View source
python
NTT_OPS = (ntt.CoefficientStandardToNttMontgomeryOp, ntt.CoefficientMontgomeryToNttMontgomeryOp, ntt.NttMontgomeryToCoefficientStandardOp, ntt.NttMontgomeryToCoefficientMontgomeryOp)1
SUPPORTED_OPERATIONS
constant View source
python
SUPPORTED_OPERATIONS = ARITHMETIC_OPS + STRUCTURAL_OPS + (rns.KeySwitchDigitProductOp,)1
Expr
class View source
python
Expr(op: str, args: tuple[Expr, ...] = (), data: tuple[int, ...] = ())1
Attributes
| Name | Type | Default/value |
|---|---|---|
op | str | |
args | tuple[Expr, ...] | () |
data | tuple[int, ...] | () |
InputLayout
class View source
python
InputLayout(shape: tuple[int, ...], strides: tuple[int, ...], component_axis: bool = False)1
Attributes
| Name | Type | Default/value |
|---|---|---|
shape | tuple[int, ...] | |
strides | tuple[int, ...] | |
component_axis | bool | False |
components
property
python
components: int1
batch_shape
property
python
batch_shape: tuple[int, ...]1
ValueExpr
class View source
python
ValueExpr(components: tuple[Expr, ...], shape: tuple[int, ...], component_axis: bool, root: int, view: tuple[int, ...] = ())1
Attributes
| Name | Type | Default/value |
|---|---|---|
components | tuple[Expr, ...] | |
shape | tuple[int, ...] | |
component_axis | bool | |
root | int | |
view | tuple[int, ...] | () |
batch_shape
property
python
batch_shape: tuple[int, ...]1
Anchor
class View source
python
Anchor(operation: Operation, source: ValueExpr, result: ValueExpr, table_indices: tuple[int, ...])1
Attributes
| Name | Type | Default/value |
|---|---|---|
operation | Operation | |
source | ValueExpr | |
result | ValueExpr | |
table_indices | tuple[int, ...] |
BoundGraph
class View source
python
BoundGraph(layouts: tuple[InputLayout, ...], outputs: tuple[ValueExpr, ...], roots: Mapping[int, ValueExpr], anchors: tuple[Anchor, ...] = ())1
Attributes
| Name | Type | Default/value |
|---|---|---|
layouts | tuple[InputLayout, ...] | |
outputs | tuple[ValueExpr, ...] | |
roots | Mapping[int, ValueExpr] | |
anchors | tuple[Anchor, ...] | () |
batch_count
property
python
batch_count: int1
component_axis
function View source
python
def component_axis(value_type: object) -> bool: ...1
ExpressionGraph
class View source
python
ExpressionGraph(operation: fusion.FusedOp)1
Bind a region's SSA DAG to input shapes without specializing data values.
Attributes
| Name | Type | Default/value |
|---|---|---|
operation | fusion.FusedOp |
table_arguments
property
python
table_arguments: tuple[SSAValue, ...]1
tensor_types
property
python
tensor_types: tuple[object, ...]1
input_indices
property
python
input_indices: tuple[tuple[int, ...], tuple[int, ...]]1
parameter_index
property
python
parameter_index: int1
key_inputs
property
python
key_inputs: tuple[tuple[int, int, int], ...]1
bind
method
python
def bind(layouts: tuple[InputLayout, ...]) -> BoundGraph: ...1
compact_value
function View source
python
def compact_value(operation_type, operands, root, *, layout, ntt_plaintext=False): ...1
Bind compact plaintext indexing and arithmetic to the ciphertext extent.
arithmetic_value
function View source
python
def arithmetic_value(operation_type: type[Operation], operands: list[ValueExpr], root: int, *, ntt_plaintext: bool=False) -> ValueExpr: ...1
Emitter
class View source
python
Emitter(layouts: tuple[InputLayout, ...], lines: list[str] = field(default_factory=list), cache: dict[tuple[Expr, str, str, str, str], str] = field(default_factory=dict))1
Emit an expression at arbitrary coefficient, prime-row and batch indices.
Attributes
| Name | Type | Default/value |
|---|---|---|
layouts | tuple[InputLayout, ...] | |
lines | list[str] | field(default_factory=list) |
cache | dict[tuple[Expr, str, str, str, str], str] | field(default_factory=dict) |
emit
method
python
def emit(expr: Expr, index: str, row: str, batch: str, overrides: Mapping[Expr, str] | None=None, mask: str='mask') -> str: ...1