mirror of
https://github.com/zama-ai/concrete.git
synced 2026-02-09 12:15:09 -05:00
refactor(python): rework the bindings with latest MLIR version
- Go through CAPI for python bindings - Consuming LLVM errors in CAPI: fixes previous issue which made this impossible in the python bindings
This commit is contained in:
@@ -11,14 +11,29 @@ def main():
|
||||
zamalang.register_dialects(ctx)
|
||||
|
||||
module = Module.create()
|
||||
eint16 = hlfhe.EncryptedIntegerType.get(ctx, 16)
|
||||
eint6 = hlfhe.EncryptedIntegerType.get(ctx, 6)
|
||||
with InsertionPoint(module.body):
|
||||
func_types = [RankedTensorType.get((10, 10), eint16) for _ in range(2)]
|
||||
func_types = [MemRefType.get((10, 10), eint6) for _ in range(2)]
|
||||
@builtin.FuncOp.from_py_func(*func_types)
|
||||
def fhe_circuit(*arg):
|
||||
def main(*arg):
|
||||
return arg[0]
|
||||
|
||||
print(module)
|
||||
m = """
|
||||
func @main(%arg0: !HLFHE.eint<2>) -> !HLFHE.eint<2> {
|
||||
%0 = constant 1 : i3
|
||||
%1 = "HLFHE.add_eint_int"(%arg0, %0): (!HLFHE.eint<2>, i3) -> (!HLFHE.eint<2>)
|
||||
return %1: !HLFHE.eint<2>
|
||||
}"""
|
||||
## Working when HFLFHE and MLIR aren't linked
|
||||
zamalang.compiler.round_trip("module{}")
|
||||
zamalang.compiler.round_trip(str(module))
|
||||
## END OF WORKING
|
||||
## Doesn't work yet for both modules
|
||||
engine = zamalang.CompilerEngine()
|
||||
engine.compile_fhe(m)
|
||||
# engine.compile_fhe(str(module))
|
||||
print(engine.run(2))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user