mirror of
https://github.com/luxfhe/torus.git
synced 2026-10-30 17:07:26 +00:00
The MLIR dialect, its conversion passes (TFHEToConcrete, ConcreteToCAPI, ConcreteToLLVM), the optimizer component, the compiler binary, the Rust crate and the program_info parameter file all still carried the upstream project's name. They now carry this one's. Two things deliberately keep the word, because in them it is not the name. mlir::OpTrait CRTP parameters mean "the derived type", so they are spelled Derived and OpTy — LLVM's other conventional spelling for the same idiom. concreteShape is a capnp field: renaming it would change the serialized protocol, and the prose describing it is ordinary English. This also repairs references the earlier partial rename left dangling: Security.cpp included concrete/curves.gen.h and the directory is torus/, torus-cpu.h included concrete-num_complex.h, the Torus dialect CMakeLists named ConcreteOps.td, and compiler/setup.py asked find_namespace_packages for a "concrete" package that no longer exists — so it built without the package it ships.
7.2 KiB
7.2 KiB
module torus.fhe.mlir.processors.assign_bit_widths
Declaration of AssignBitWidths graph processor.
class AssignBitWidths
AssignBitWidths graph processor, to assign proper bit-widths to be compatible with FHE.
There are two modes:
- Single Precision, where all encrypted values have the same precision.
- Multi Precision, where encrypted values can have different precisions.
There is preference list for comparison strategies.
- Strategies will be traversed in order and bit-widths will be assigned according to the first available strategy.
method __init__
__init__(
single_precision: bool,
composition_rules: list[CompositionRule],
comparison_strategy_preference: list[ComparisonStrategy],
bitwise_strategy_preference: list[BitwiseStrategy],
shifts_with_promotion: bool,
multivariate_strategy_preference: list[MultivariateStrategy],
min_max_strategy_preference: list[MinMaxStrategy]
)
method apply_many
apply_many(graphs: dict[str, Graph])
class AdditionalConstraints
AdditionalConstraints class to customize bit-width assignment step easily.
method __init__
__init__(
optimizer: Optimize,
graph: Graph,
bit_widths: dict[Node, Int],
comparison_strategy_preference: list[ComparisonStrategy],
bitwise_strategy_preference: list[BitwiseStrategy],
shifts_with_promotion: bool,
multivariate_strategy_preference: list[MultivariateStrategy],
min_max_strategy_preference: list[MinMaxStrategy]
)
method all_inputs_are_encrypted
all_inputs_are_encrypted(node: Node, preds: list[Node]) → bool
method bitwise
bitwise(node: Node, preds: list[Node])
method comparison
comparison(node: Node, preds: list[Node])
method constraint
constraint(node: Node, constraint: BoolRef)
method generate_for
generate_for(node: Node, bit_width: <function Int at ADDRESS>)
Generate additional constraints for a node.
Args: node (Node): node to generate constraints for
bit_width (z3.Int): symbolic bit-width which will be assigned to node once constraints are solved
method has_overflow_protection
has_overflow_protection(node: Node, preds: list[Node]) → bool
method inputs_and_output_share_precision
inputs_and_output_share_precision(node: Node, preds: list[Node])
method inputs_require_one_more_bit
inputs_require_one_more_bit(node: Node, preds: list[Node])
method inputs_share_precision
inputs_share_precision(node: Node, preds: list[Node])
method min_max
min_max(node: Node, preds: list[Node])
method minimum_maximum
minimum_maximum(node: Node, preds: list[Node])
method multivariate
multivariate(node: Node, preds: list[Node])
method some_inputs_are_clear
some_inputs_are_clear(node: Node, preds: list[Node]) → bool