refactor(encodings): raise plaintext/lut encodings higher up in the pipeline

This commit is contained in:
aPere3
2022-11-10 14:57:48 +01:00
committed by Alexandre Péré
parent 7226c89cf1
commit 2fd9b6f0e3
94 changed files with 2731 additions and 2040 deletions

View File

@@ -311,31 +311,14 @@ CompilerEngine::compile(llvm::SourceMgr &sm, Target target, OptionalLib lib) {
if (target == Target::FHE)
return std::move(res);
// FHE -> TFHE
if (mlir::concretelang::pipeline::lowerFHEToTFHE(mlirContext, module,
res.fheContext, enablePass)
// FHELinalg -> FHE
if (mlir::concretelang::pipeline::lowerFHELinalgToFHE(
mlirContext, module, res.fheContext, enablePass, loopParallelize,
options.batchConcreteOps)
.failed()) {
return errorDiag("Lowering from FHE to TFHE failed");
return errorDiag("Lowering from FHELinalg to FHE failed");
}
if (target == Target::TFHE)
return std::move(res);
// TFHE -> Concrete
if (mlir::concretelang::pipeline::lowerTFHEToConcrete(
mlirContext, module, res.fheContext, this->enablePass)
.failed()) {
return errorDiag("Lowering from TFHE to Concrete failed");
}
// Optimizing Concrete
if (this->compilerOptions.optimizeConcrete &&
mlir::concretelang::pipeline::optimizeConcrete(mlirContext, module,
this->enablePass)
.failed()) {
return errorDiag("Optimizing Concrete failed");
}
if (target == Target::CONCRETE)
if (target == Target::FHE_NO_LINALG)
return std::move(res);
// Generate client parameters if requested
@@ -371,19 +354,33 @@ CompilerEngine::compile(llvm::SourceMgr &sm, Target target, OptionalLib lib) {
}
}
// Concrete with linalg ops -> Concrete with loop ops
if (mlir::concretelang::pipeline::lowerConcreteLinalgToLoops(
mlirContext, module, this->enablePass, loopParallelize,
options.batchConcreteOps)
// FHE -> TFHE
if (mlir::concretelang::pipeline::lowerFHEToTFHE(mlirContext, module,
res.fheContext, enablePass)
.failed()) {
return StreamStringError(
"Lowering from Concrete with linalg ops to Concrete with loops failed");
return errorDiag("Lowering from FHE to TFHE failed");
}
if (target == Target::TFHE)
return std::move(res);
// TFHE -> Concrete
if (mlir::concretelang::pipeline::lowerTFHEToConcrete(
mlirContext, module, res.fheContext, this->enablePass)
.failed()) {
return errorDiag("Lowering from TFHE to Concrete failed");
}
if (target == Target::CONCRETEWITHLOOPS) {
return std::move(res);
// Optimizing Concrete
if (this->compilerOptions.optimizeConcrete &&
mlir::concretelang::pipeline::optimizeConcrete(mlirContext, module,
this->enablePass)
.failed()) {
return errorDiag("Optimizing Concrete failed");
}
if (target == Target::CONCRETE)
return std::move(res);
// Concrete -> BConcrete
if (mlir::concretelang::pipeline::lowerConcreteToBConcrete(
mlirContext, module, this->enablePass, loopParallelize)