MLIR
23.0.0git
lib
Bindings
Python
DialectIRDL.cpp
Go to the documentation of this file.
1
//===--- DialectIRDL.cpp - Pybind module for IRDL dialect API support ---===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
9
#include "
mlir-c/Dialect/IRDL.h
"
10
#include "
mlir-c/IR.h
"
11
#include "
mlir-c/Support.h
"
12
#include "
mlir/Bindings/Python/IRCore.h
"
13
#include "
mlir/Bindings/Python/Nanobind.h
"
14
#include "
mlir/Bindings/Python/NanobindAdaptors.h
"
15
16
namespace
nb
=
nanobind
;
17
using namespace
mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN
;
18
using namespace
mlir::python::nanobind_adaptors
;
19
20
static
void
populateDialectIRDLSubmodule
(nb::module_ &m) {
21
m.def(
22
"load_dialects"
,
23
[](
PyModule
&module) {
24
if
(
mlirLogicalResultIsFailure
(
mlirLoadIRDLDialects
(module.
get
())))
25
throw
std::runtime_error(
26
"failed to load IRDL dialects from the input module"
);
27
},
28
nb::arg(
"module"
),
"Load IRDL dialects from the given module."
);
29
}
30
31
NB_MODULE
(_mlirDialectsIRDL, m) {
32
m.doc() =
"MLIR IRDL dialect."
;
33
34
populateDialectIRDLSubmodule
(m);
35
}
NB_MODULE
NB_MODULE(_mlirDialectsIRDL, m)
Definition
DialectIRDL.cpp:31
populateDialectIRDLSubmodule
static void populateDialectIRDLSubmodule(nb::module_ &m)
Definition
DialectIRDL.cpp:20
IRCore.h
NanobindAdaptors.h
Nanobind.h
mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyModule
Definition
IRCore.h:539
mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyModule::get
MlirModule get()
Gets the backing MlirModule.
Definition
IRCore.h:549
IRDL.h
mlirLoadIRDLDialects
MLIR_CAPI_EXPORTED MlirLogicalResult mlirLoadIRDLDialects(MlirModule module)
Loads all IRDL dialects in the provided module, registering the dialects in the module's associated c...
Definition
IRDL.cpp:16
IR.h
Support.h
mlirLogicalResultIsFailure
static bool mlirLogicalResultIsFailure(MlirLogicalResult res)
Checks if the given logical result represents a failure.
Definition
Support.h:129
mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN
Definition
Globals.h:31
mlir::python::nanobind_adaptors
Definition
NanobindAdaptors.h:425
nanobind
Definition
IRCore.h:1844
Generated on
for MLIR by
1.14.0