MLIR 22.0.0git
DialectAMDGPU.cpp
Go to the documentation of this file.
1//===--- DialectAMDGPU.cpp - Pybind module for AMDGPU 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
10#include "mlir-c/IR.h"
14#include "nanobind/nanobind.h"
15
16namespace nb = nanobind;
17using namespace llvm;
19
20namespace mlir {
21namespace python {
23namespace amdgpu {
24struct TDMBaseType : PyConcreteType<TDMBaseType> {
28 static constexpr const char *pyClassName = "TDMBaseType";
30 using Base::Base;
31
32 static void bindDerived(ClassTy &c) {
33 c.def_static(
34 "get",
35 [](const PyType &elementType, DefaultingPyMlirContext context) {
36 return TDMBaseType(
37 context->getRef(),
38 mlirAMDGPUTDMBaseTypeGet(context.get()->get(), elementType));
39 },
40 "Gets an instance of TDMBaseType in the same context",
41 nb::arg("element_type"), nb::arg("context").none() = nb::none());
42 }
43};
44
45struct TDMDescriptorType : PyConcreteType<TDMDescriptorType> {
46 static constexpr IsAFunctionTy isaFunction =
50 static constexpr const char *pyClassName = "TDMDescriptorType";
52 using Base::Base;
53
54 static void bindDerived(ClassTy &c) {
55 c.def_static(
56 "get",
57 [](DefaultingPyMlirContext context) {
58 return TDMDescriptorType(
59 context->getRef(),
60 mlirAMDGPUTDMDescriptorTypeGet(context.get()->get()));
61 },
62 "Gets an instance of TDMDescriptorType in the same context",
63 nb::arg("context").none() = nb::none());
64 }
65};
66
67struct TDMGatherBaseType : PyConcreteType<TDMGatherBaseType> {
68 static constexpr IsAFunctionTy isaFunction =
72 static constexpr const char *pyClassName = "TDMGatherBaseType";
74 using Base::Base;
75
76 static void bindDerived(ClassTy &c) {
77 c.def_static(
78 "get",
79 [](const PyType &elementType, const PyType &indexType,
81 return TDMGatherBaseType(
82 context->getRef(),
83 mlirAMDGPUTDMGatherBaseTypeGet(context.get()->get(), elementType,
84 indexType));
85 },
86 "Gets an instance of TDMGatherBaseType in the same context",
87 nb::arg("element_type"), nb::arg("index_type"),
88 nb::arg("context").none() = nb::none());
89 }
90};
91
97} // namespace amdgpu
98} // namespace MLIR_BINDINGS_PYTHON_DOMAIN
99} // namespace python
100} // namespace mlir
101
102NB_MODULE(_mlirDialectsAMDGPU, m) {
103 m.doc() = "MLIR AMDGPU dialect.";
104
107}
MLIR_CAPI_EXPORTED bool mlirTypeIsAAMDGPUTDMGatherBaseType(MlirType type)
Definition AMDGPU.cpp:63
MLIR_CAPI_EXPORTED bool mlirTypeIsAAMDGPUTDMDescriptorType(MlirType type)
Definition AMDGPU.cpp:43
MLIR_CAPI_EXPORTED MlirType mlirAMDGPUTDMGatherBaseTypeGet(MlirContext ctx, MlirType elementType, MlirType indexType)
Definition AMDGPU.cpp:71
MLIR_CAPI_EXPORTED MlirType mlirAMDGPUTDMDescriptorTypeGet(MlirContext ctx)
Definition AMDGPU.cpp:51
MLIR_CAPI_EXPORTED MlirTypeID mlirAMDGPUTDMDescriptorTypeGetTypeID()
Definition AMDGPU.cpp:47
MLIR_CAPI_EXPORTED bool mlirTypeIsAAMDGPUTDMBaseType(MlirType type)
Definition AMDGPU.cpp:23
MLIR_CAPI_EXPORTED MlirStringRef mlirAMDGPUTDMBaseTypeGetName(void)
Definition AMDGPU.cpp:35
MLIR_CAPI_EXPORTED MlirType mlirAMDGPUTDMBaseTypeGet(MlirContext ctx, MlirType elementType)
Definition AMDGPU.cpp:31
MLIR_CAPI_EXPORTED MlirTypeID mlirAMDGPUTDMBaseTypeGetTypeID()
Definition AMDGPU.cpp:27
MLIR_CAPI_EXPORTED MlirTypeID mlirAMDGPUTDMGatherBaseTypeGetTypeID()
Definition AMDGPU.cpp:67
MLIR_CAPI_EXPORTED MlirStringRef mlirAMDGPUTDMDescriptorTypeGetName(void)
Definition AMDGPU.cpp:55
MLIR_CAPI_EXPORTED MlirStringRef mlirAMDGPUTDMGatherBaseTypeGetName(void)
Definition AMDGPU.cpp:77
NB_MODULE(_mlirDialectsAMDGPU, m)
ReferrentTy * get() const
Used in function arguments when None should resolve to the current context manager set instance.
Definition IRCore.h:280
PyType(PyMlirContextRef contextRef, MlirType type)
Definition IRCore.h:878
The OpAsmOpInterface, see OpAsmInterface.td for more details.
Definition CallGraph.h:229
static void populateDialectAMDGPUSubmodule(nb::module_ &m)
Include the generated interface declarations.
A pointer to a sized fragment of a string, not necessarily null-terminated.
Definition Support.h:75