fhelium.backend.rns.automorphism
Coefficient indexing and RNS execution of polynomial automorphisms.
coefficient_galois_gather_indices
function View source
def coefficient_galois_gather_indices(ring_dimension: int, galois_element: int, device: str | torch.device='cpu') -> tuple[torch.Tensor, torch.Tensor]: ...Return gathers implementing
The returned device tensors have shapes [coefficient] with dtypes torch.int32 and torch.int8. For an integral coefficient-domain residue tensor [..., coefficient], destination j reads source_indices[j] and multiplies by source_sign[j]. No RNS limb or batch axis is represented in the tables, so the gather broadcasts across both without mutation.
apply_coefficient_galois_automorphism
function View source
def apply_coefficient_galois_automorphism(residues: torch.Tensor, galois_element: int, moduli: torch.Tensor) -> torch.Tensor: ...Return non-aliasing coefficient residues for
residues has integral [*batch, limb, coefficient] layout on one device in either standard or Montgomery representation. The gather and sign change preserve that representation and prime-row order. moduli is a same-dtype/device vector containing the modulus for each limb; reducing against it maps signed gather results into
NativeCoefficientAutomorphismImplementation
class View source
NativeCoefficientAutomorphismImplementation(name: str = 'native-coefficient-automorphism', supports_in_place: bool = False, operation_types: tuple[type[Operation], ...] = (rns.CoefficientAutomorphismOp,))Apply one coefficient-domain Galois automorphism through the native op.
Attributes
| Name | Type | Default/value |
|---|---|---|
name | str | 'native-coefficient-automorphism' |
supports_in_place | bool | False |
operation_types | tuple[type[Operation], ...] | (rns.CoefficientAutomorphismOp,) |
resource_requirements
method
def resource_requirements(invocation: OperationInvocation) -> tuple[ResourceRequirement, ...]: ...execute
method
def execute(invocation: OperationInvocation, values: tuple[torch.Tensor, ...], resources: tuple[BoundResource, ...], *, in_place: bool) -> tuple[torch.Tensor, ...]: ...