-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[mlir][python] allow upstream dialect registration #74252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#ifndef MLIR_C_REMAINING_DIALECTS_H | ||
#define MLIR_C_REMAINING_DIALECTS_H | ||
|
||
#include "mlir-c/IR.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#define MLIR_DEFINE_CAPI_DIALECT_REGISTRATION_(NAMESPACE) \ | ||
MLIR_CAPI_EXPORTED MlirDialectHandle mlirGetDialectHandle__##NAMESPACE##__(); | ||
|
||
#define FORALL_DIALECTS(_) \ | ||
_(acc) \ | ||
_(affine) \ | ||
_(amx) \ | ||
_(arm_neon) \ | ||
_(arm_sme) \ | ||
_(arm_sve) \ | ||
_(bufferization) \ | ||
_(complex) \ | ||
_(dlti) \ | ||
_(emitc) \ | ||
_(index) \ | ||
_(irdl) \ | ||
_(mesh) \ | ||
_(spirv) \ | ||
_(tosa) \ | ||
_(ub) \ | ||
_(x86vector) | ||
|
||
FORALL_DIALECTS(MLIR_DEFINE_CAPI_DIALECT_REGISTRATION_) | ||
|
||
#undef MLIR_DEFINE_CAPI_DIALECT_REGISTRATION_ | ||
#undef FORALL_DIALECTS | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif // MLIR_C_REMAINING_DIALECTS_H |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#include "mlir-c/Dialect/RemainingDialects.h" | ||
|
||
#include "mlir/CAPI/Registration.h" | ||
#include "mlir/InitAllDialects.h" | ||
|
||
using namespace mlir; | ||
|
||
#define MLIR_DEFINE_CAPI_DIALECT_REGISTRATION_(NAMESPACE, NAME) \ | ||
MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(NAME, NAMESPACE, \ | ||
NAMESPACE::NAME##Dialect) | ||
|
||
#define FORALL_DIALECTS(_) \ | ||
_(acc, OpenACC) \ | ||
_(affine, Affine) \ | ||
_(amx, AMX) \ | ||
_(arith, Arith) \ | ||
_(arm_neon, ArmNeon) \ | ||
_(arm_sme, ArmSME) \ | ||
_(arm_sve, ArmSVE) \ | ||
_(bufferization, Bufferization) \ | ||
_(complex, Complex) \ | ||
_(emitc, EmitC) \ | ||
_(index, Index) \ | ||
_(irdl, IRDL) \ | ||
_(mesh, Mesh) \ | ||
_(spirv, SPIRV) \ | ||
_(tosa, Tosa) \ | ||
_(ub, UB) \ | ||
_(x86vector, X86Vector) | ||
|
||
FORALL_DIALECTS(MLIR_DEFINE_CAPI_DIALECT_REGISTRATION_) | ||
|
||
#undef MLIR_DEFINE_CAPI_DIALECT_REGISTRATION_ | ||
#undef FORALL_DIALECTS | ||
|
||
static void mlirDialectRegistryInsertDLTIDialect(MlirDialectRegistry registry) { | ||
unwrap(registry)->insert<mlir::DLTIDialect>(); | ||
} | ||
|
||
static MlirDialect mlirContextLoadDLTIDialect(MlirContext context) { | ||
return wrap(unwrap(context)->getOrLoadDialect<mlir::DLTIDialect>()); | ||
} | ||
|
||
static MlirStringRef mlirDLTIDialectGetNamespace() { | ||
return wrap(mlir::DLTIDialect::getDialectNamespace()); | ||
} | ||
|
||
MlirDialectHandle mlirGetDialectHandle__dlti__() { | ||
static MlirDialectRegistrationHooks hooks = { | ||
mlirDialectRegistryInsertDLTIDialect, mlirContextLoadDLTIDialect, | ||
mlirDLTIDialectGetNamespace}; | ||
return MlirDialectHandle{&hooks}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -423,7 +423,30 @@ declare_mlir_python_extension(MLIRPythonExtension.Core | |
MLIRCAPIInterfaces | ||
|
||
# Dialects | ||
MLIRCAPIAMDGPU | ||
MLIRCAPIArith | ||
MLIRCAPIAsync | ||
MLIRCAPIControlFlow | ||
MLIRCAPIFunc | ||
MLIRCAPIGPU | ||
MLIRCAPILLVM | ||
MLIRCAPILinalg | ||
MLIRCAPIMLProgram | ||
MLIRCAPIMath | ||
MLIRCAPIMemRef | ||
MLIRCAPINVGPU | ||
MLIRCAPINVVM | ||
MLIRCAPIOpenMP | ||
MLIRCAPIPDL | ||
MLIRCAPIQuant | ||
MLIRCAPIROCDL | ||
MLIRCAPISCF | ||
MLIRCAPIShape | ||
MLIRCAPISparseTensor | ||
MLIRCAPITensor | ||
MLIRCAPITransformDialect | ||
MLIRCAPIVector | ||
MLIRCAPIRemainingDialects | ||
Comment on lines
425
to
+449
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we want "Core" bindings to depend on all dialects... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The issue is that right now most of the dialects don't have their own pybind modules. I was trying to avoid introducing 20 new modules that just have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah. I need to activate some old caches for this, but I think it was this issue that kept me from doing this the first time around. If we can get the dependency dag such that |
||
) | ||
|
||
# This extension exposes an API to register all dialects, extensions, and passes | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just dead code (or, alternatively, an IWYU failure somewhere else...)