MLIR
22.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/Nanobind.h
"
13
#include "
mlir/Bindings/Python/NanobindAdaptors.h
"
14
15
namespace
nb
=
nanobind
;
16
using namespace
mlir
;
17
using namespace
mlir::python
;
18
using namespace
mlir::python::nanobind_adaptors
;
19
20
static
void
populateDialectIRDLSubmodule
(nb::module_ &m) {
21
m.def(
22
"load_dialects"
,
23
[](MlirModule module) {
24
if
(
mlirLogicalResultIsFailure
(
mlirLoadIRDLDialects
(module)))
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
NanobindAdaptors.h
Nanobind.h
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:127
mlir::python::nanobind_adaptors
Definition:
NanobindAdaptors.h:360
mlir::python
Definition:
Diagnostics.h:21
mlir
Include the generated interface declarations.
Definition:
LocalAliasAnalysis.h:20
nanobind
Definition:
NanobindAdaptors.h:35
Generated on Mon Sep 22 2025 12:34:37 for MLIR by
1.9.1