Skip to content

[mlir:python] Add a mechanism to register upstream dialects from Python #74245

Open
@hawkinsp

Description

@hawkinsp

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 to 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

Metadata

Metadata

Assignees

Labels

enhancementImproving things as opposed to bug fixing, e.g. new or missing featuremlir:pythonMLIR Python bindings

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions