<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/74245>74245</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[mlir:python] Add a mechanism to register upstream dialects from Python
</td>
</tr>
<tr>
<th>Labels</th>
<td>
mlir
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
hawkinsp
</td>
</tr>
</table>
<pre>
Currently there seem to be two ways to register the upstream dialects in a build of MLIR Python:
a) use `mlirRegisterEverything`, which works, but links in many dialects and transforms that might not be necessary.
b) define a `_site_initialize` module, which works, but requires that you write a custom pybind11 module.
Wouldn't it be nice if one could do neither (a) nor (b), and instead just explicitly register dialects like `arith` with a `ir.Context` from Python, without having write a C++ Python extension to do so?
I'm imagining adding an API along the lines of:
```
arith.register_dialect(context)
```
to the generated code for a dialect, but I don't much mind exactly what the API is, so long as it exists. That appears to be the pattern often used by out-of-tree dialects.
@stellaraccident
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx0lFFv4zYMxz-N8kI0sGU3Th780GsXoMAGHA4D9ljQFm3zKkueRDfxPv0gx83usA0I5DiRSP74_4sYI_eOqFaPX9Tjyw5nGXyoB7y8s4vTrvFmqZ_nEMiJXUAGCgSRaATx0BDIxcMFl5heA_UchULaBfMUJRCOYBgttRKBHSA0M1sDvoPffn39Bl8XGbxTxZPKXlT2hEqfYI4E6pCNlsO3LeAvHxQWGdj16pAp_QyXgdsBLj68x_TazAKW3fuaY0S3_JMUnQEJ6GLnwxhBBhQYuR8EnJcE4KilGDEs-1sNTarBUMeOAFMhb5GF3tixMFr-i9Qhg9Gb2dL_VBLoz5kDbckWP8MlsKRo7RzFjzAtDTuT51uYLfFt_cPP1jilKwG-1cctAXfgHUGb_gTjwREnJUDp49oz59fvqfZURYJmF4XQwPc5CtB1stxyUvAu0r1Flt_XjmNgGRLdhWW4sXPYP3sndJX0exf8-ClZQmcZ_Cww4Ae7_g75rPQXpb9sG4GuQi6yd8khxkP0qjj_SPyqdDUCj9izS3HQmPXh4OnrK6D1rl8NZdlRBN_d3bKth2z73CyUIPafkG8bpNLHduPQp_88d1vFr6l6chRQyEDrDUHnAyDcQ91UfgXjbzqNczvAyM4AXbFNPb4k4VOgRMCrMaKHlQRj0pWuHCXu4fe0EaeJMMTPCzUQTChCwYHvhFy6EAaaBfwsD757kEB0F-8n76gyi0LWYsC2ZUNOYGfqwpyKE-6ozqssP-iyPJW7oa6wOGZHU52yjE45ZVmnq65sD6XBU0GHase1znSR66zIK33Mi32bH6suy9BUhzI_tpUqMxqR7d7aj3HvQ7_jGGeqq1KXjzuLDdm4ThWt011WWqf5Euq0_aGZ-6jKzK5tuAcQFrtOovVA8TTdvPb4Ak_GAMJI7YCO4_jTtPn3pPnBqLs52HoQmWLyjT4rfe5ZhrnZt35U-pxyb4-HKfjvq8LnlSQqfV5h_g4AAP__V0izIg">