google / google/heir

Add a way to pass textual MLIR into the compiler from the Python frontend

Open
#1,444 0 comments 1 reaction 1 assignee Claimed by @AlexanderViand-Intel View on GitHub
python frontend
Dominant language
MLIR
Stars
906
Forks
171
Avg merge
4d 12h
Merged PRs (30d)
32

Description

For debugging, and to support jupyter notebook demos like the ones available via `heir_play`, the frontend should be able to take in textual MLIR as a string, essentially skipping most of the "Frontend" parts, but still allowing you to use a backend.

E.g., in addition to
```python
@compile()
def foo(x: Secret[I16], y: Secret[I16]):
return (x + y) * (x - y) + (x * y)

foo.setup()
enc_x = foo.encrypt_x(7)
enc_y = foo.encrypt_y(8)
result_enc = foo.eval(enc_x, enc_y)
result = foo.decrypt_result(result_enc)
```

We should also support
```python
ssa ="""
func.func @foo(%x: i16 {secret.secret}, %y: i16 {secret.secret}) -> (i16) {
%0 = arith.addi %x, %y : i16
%1 = arith.subi %x, %y : i16
%2 = arith.muli %0, %1 : i16
%3 = arith.muli %x, %y : i16
%4 = arith.addi %2, %3 : i16
func.return %4 : i16
}"""

foo = compile_ssa(ssa)

foo.setup()
enc_x = foo.encrypt_x(7)
enc_y = foo.encrypt_y(8)
result_enc = foo.eval(enc_x, enc_y)
result = foo.decrypt_result(result_enc)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.