Support different flavor of lowering in `--mlir-to-<scheme>`
- 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
Assessment
This issue has not been assessed yet.