google / google/heir

Support different flavor of lowering in `--mlir-to-<scheme>`

Open
#1,420 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
MLIR
Stars
906
Forks
171
Avg merge
4d 12h
Merged PRs (30d)
32

Description

Passes in `mlir-to-` have multiple places that are tailored for different backends, like

* `modulus-switch-before-first-mul` in `secret-insert-mgmt`, which is only for Openfhe FLEXIBLEAUTOEXT mode
* `validate-noise` noise models for Lattigo as Lattigo has a different public key encryption technique, see https://github.com/google/heir/pull/1374#issuecomment-2646153253
* `AddAndKeySwitchCountAnalysis`, which is only for Openfhe
* `optimize-relinearization` which has an option on whether supporting mixed degree op, see also https://github.com/google/heir/pull/1295#issuecomment-2616340672 and #1169

A `--mlir-to-=flavor=lattigo --scheme-to-lattigo` can make full potential of these passes, yet this is quite redundant.

Another option is to mark the backend in module, but when we want to switch to another backend we have to modify the string in IR, which is inconvenient

```mlir
module attributes {backend.lattigo} {...}
```

Yet another solution is to add a pass to select the backend in the beginning like

```bash
--openfhe --mlir-to-scheme --to-backend
```
where `--openfhe` just modify the module attribute to `backend.openfhe`.

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.