mirror of
https://github.com/zama-ai/concrete.git
synced 2026-02-09 03:55:04 -05:00
refactor: replace some operands by attrs in bs/ks
This commit is contained in:
@@ -12,7 +12,7 @@ namespace mlir {
|
||||
namespace concretelang {
|
||||
/// Create a pass to convert `Concrete` dialect to `BConcrete` dialect.
|
||||
std::unique_ptr<OperationPass<ModuleOp>>
|
||||
createConvertConcreteToBConcretePass(bool loopParallelize, bool emitGPUOps);
|
||||
createConvertConcreteToBConcretePass(bool loopParallelize);
|
||||
} // namespace concretelang
|
||||
} // namespace mlir
|
||||
|
||||
|
||||
@@ -78,7 +78,9 @@ def BConcrete_KeySwitchLweBufferOp : BConcrete_Op<"keyswitch_lwe_buffer"> {
|
||||
// LweKeySwitchKeyType:$keyswitch_key,
|
||||
1DTensorOf<[I64]>:$ciphertext,
|
||||
I32Attr:$level,
|
||||
I32Attr:$baseLog
|
||||
I32Attr:$baseLog,
|
||||
I32Attr:$lwe_dim_in,
|
||||
I32Attr:$lwe_dim_out
|
||||
);
|
||||
let results = (outs 1DTensorOf<[I64]>:$result);
|
||||
}
|
||||
@@ -87,12 +89,12 @@ def BConcrete_BootstrapLweBufferOp : BConcrete_Op<"bootstrap_lwe_buffer"> {
|
||||
let arguments = (ins
|
||||
1DTensorOf<[I64]>:$input_ciphertext,
|
||||
1DTensorOf<[I64]>:$lookup_table,
|
||||
I32:$inputLweDim,
|
||||
I32:$polySize,
|
||||
I32:$level,
|
||||
I32:$baseLog,
|
||||
I32:$glweDimension,
|
||||
I32:$outPrecision
|
||||
I32Attr:$inputLweDim,
|
||||
I32Attr:$polySize,
|
||||
I32Attr:$level,
|
||||
I32Attr:$baseLog,
|
||||
I32Attr:$glweDimension,
|
||||
I32Attr:$outPrecision
|
||||
);
|
||||
let results = (outs 1DTensorOf<[I64]>:$result);
|
||||
}
|
||||
@@ -137,12 +139,12 @@ def BConcrete_BootstrapLweBufferAsyncOffloadOp :
|
||||
let arguments = (ins
|
||||
1DTensorOf<[I64]>:$input_ciphertext,
|
||||
1DTensorOf<[I64]>:$lookup_table,
|
||||
I32:$inputLweDim,
|
||||
I32:$polySize,
|
||||
I32:$level,
|
||||
I32:$baseLog,
|
||||
I32:$glweDimension,
|
||||
I32:$outPrecision
|
||||
I32Attr:$inputLweDim,
|
||||
I32Attr:$polySize,
|
||||
I32Attr:$level,
|
||||
I32Attr:$baseLog,
|
||||
I32Attr:$glweDimension,
|
||||
I32Attr:$outPrecision
|
||||
);
|
||||
let results = (outs RT_Future : $result);
|
||||
}
|
||||
@@ -153,35 +155,4 @@ def BConcrete_AwaitFutureOp :
|
||||
let results = (outs 1DTensorOf<[I64]>:$result);
|
||||
}
|
||||
|
||||
// This is a different op in BConcrete just because of the way we are lowering to CAPI
|
||||
// When the CAPI lowering is detached from bufferization, we can remove this op, and lower
|
||||
// to the appropriate CAPI (gpu or cpu) depending on the emitGPUOps compilation option
|
||||
def BConcrete_BootstrapLweGPUBufferOp : BConcrete_Op<"bootstrap_lwe_gpu_buffer"> {
|
||||
let arguments = (ins
|
||||
1DTensorOf<[I64]>:$input_ciphertext,
|
||||
1DTensorOf<[I64]>:$table,
|
||||
I32:$inputLweDim,
|
||||
I32:$polySize,
|
||||
I32:$level,
|
||||
I32:$baseLog,
|
||||
I32:$glweDimension,
|
||||
I32:$outPrecision
|
||||
);
|
||||
let results = (outs 1DTensorOf<[I64]>:$result);
|
||||
}
|
||||
|
||||
// This is a different op in BConcrete just because of the way we are lowering to CAPI
|
||||
// When the CAPI lowering is detached from bufferization, we can remove this op, and lower
|
||||
// to the appropriate CAPI (gpu or cpu) depending on the emitGPUOps compilation option
|
||||
def BConcrete_KeySwitchLweGPUBufferOp : BConcrete_Op<"keyswitch_lwe_gpu_buffer"> {
|
||||
let arguments = (ins
|
||||
1DTensorOf<[I64]>:$ciphertext,
|
||||
I32:$level,
|
||||
I32:$baseLog,
|
||||
I32:$lwe_dim_in,
|
||||
I32:$lwe_dim_out
|
||||
);
|
||||
let results = (outs 1DTensorOf<[I64]>:$result);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -58,12 +58,10 @@ def Concrete_BootstrapLweOp : Concrete_Op<"bootstrap_lwe"> {
|
||||
let arguments = (ins
|
||||
Concrete_LweCiphertextType:$input_ciphertext,
|
||||
1DTensorOf<[I64]>:$lookup_table,
|
||||
I32:$inputLweDim,
|
||||
I32:$polySize,
|
||||
I32:$level,
|
||||
I32:$baseLog,
|
||||
I32:$glweDimension,
|
||||
I32:$outPrecision
|
||||
I32Attr:$level,
|
||||
I32Attr:$baseLog,
|
||||
I32Attr:$polySize,
|
||||
I32Attr:$glweDimension
|
||||
);
|
||||
let results = (outs Concrete_LweCiphertextType:$result);
|
||||
}
|
||||
|
||||
@@ -99,10 +99,9 @@ def TFHE_BootstrapGLWEOp : TFHE_Op<"bootstrap_glwe"> {
|
||||
let arguments = (ins
|
||||
TFHE_GLWECipherTextType : $ciphertext,
|
||||
1DTensorOf<[I64]> : $lookup_table,
|
||||
I32Attr : $inputLweDim,
|
||||
I32Attr : $polySize,
|
||||
I32Attr : $level,
|
||||
I32Attr : $baseLog,
|
||||
I32Attr : $polySize,
|
||||
I32Attr : $glweDimension
|
||||
);
|
||||
|
||||
|
||||
@@ -62,6 +62,8 @@ void memref_keyswitch_lwe_u64(uint64_t *out_allocated, uint64_t *out_aligned,
|
||||
uint64_t out_stride, uint64_t *ct0_allocated,
|
||||
uint64_t *ct0_aligned, uint64_t ct0_offset,
|
||||
uint64_t ct0_size, uint64_t ct0_stride,
|
||||
uint32_t level, uint32_t base_log,
|
||||
uint32_t input_lwe_dim, uint32_t output_lwe_dim,
|
||||
mlir::concretelang::RuntimeContext *context);
|
||||
void *memref_keyswitch_async_lwe_u64(
|
||||
uint64_t *out_allocated, uint64_t *out_aligned, uint64_t out_offset,
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
namespace mlir {
|
||||
namespace concretelang {
|
||||
|
||||
bool getEmitGPUOption();
|
||||
|
||||
/// Compilation context that acts as the root owner of LLVM and MLIR
|
||||
/// data structures directly and indirectly referenced by artefacts
|
||||
/// produced by the `CompilerEngine`.
|
||||
|
||||
@@ -47,7 +47,7 @@ lowerTFHEToConcrete(mlir::MLIRContext &context, mlir::ModuleOp &module,
|
||||
mlir::LogicalResult
|
||||
lowerConcreteToBConcrete(mlir::MLIRContext &context, mlir::ModuleOp &module,
|
||||
std::function<bool(mlir::Pass *)> enablePass,
|
||||
bool parallelizeLoops, bool emitGPUOps);
|
||||
bool parallelizeLoops);
|
||||
|
||||
mlir::LogicalResult
|
||||
optimizeConcrete(mlir::MLIRContext &context, mlir::ModuleOp &module,
|
||||
|
||||
Reference in New Issue
Block a user