Skip to content

Commit

Permalink
refactor(compiler): Re-implement TFHE multi-parameter parametrization…
Browse files Browse the repository at this point in the history
… with type inference

The current pass applying the parameters determined by the optimizer
to the IR propagates the parametrized TFHE types to operations not
directly tagged with an optimizer ID only under certain conditions. In
particular, it does not always properly propagate types into nested
regions (e.g., of `scf.for` loops).

This burdens preceding transformations that are applied in between the
invocation of the optimizer and the parametrization pass with
data-flow analysis and book-keeping in order to tag newly inserted
operations with the right optimizer IDs that ensure proper
parametrization.

This commit replaces the current parametrization pass with a new pass
that propagates parametrized TFHE types up and down def-use chains
using type inference and a proper rewriter. The pass is limited to the
operations supported by `TFHEParametrizationTypeResolver::resolve`.
  • Loading branch information
andidr committed Feb 7, 2024
1 parent 4835567 commit 670b95e
Show file tree
Hide file tree
Showing 5 changed files with 849 additions and 479 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
namespace mlir {
namespace concretelang {
std::unique_ptr<mlir::OperationPass<>> createTFHEOptimizationPass();
std::unique_ptr<mlir::OperationPass<>>
std::unique_ptr<mlir::OperationPass<mlir::ModuleOp>>
createTFHECircuitSolutionParametrizationPass(
concrete_optimizer::dag::CircuitSolution);
std::optional<concrete_optimizer::dag::CircuitSolution>);
} // namespace concretelang
} // namespace mlir

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def TFHEOptimization : Pass<"tfhe-optimization"> {
let dependentDialects = [ "mlir::concretelang::TFHE::TFHEDialect" ];
}

def TFHECircuitSolutionParametrization : Pass<"tfhe-circuit-solution-parametrization"> {
def TFHECircuitSolutionParametrization : Pass<"tfhe-circuit-solution-parametrization", "mlir::ModuleOp"> {
let summary = "Parametrize TFHE with a circuit solution given by the optimizer";
let constructor = "mlir::concretelang::createTFHECircuitSolutionParametrizationPass()";
let options = [];
Expand Down
Loading

0 comments on commit 670b95e

Please sign in to comment.