MLIR 23.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;
18
19namespace mlir {
20namespace python {
22namespace amdgpu {
23struct TDMBaseType : PyConcreteType<TDMBaseType> {
27 static constexpr const char *pyClassName = "TDMBaseType";
29 using Base::Base;
30
31 static void bindDerived(ClassTy &c) {
32 c.def_static(
33 "get",
34 [](const PyType &elementType, DefaultingPyMlirContext context) {
35 return TDMBaseType(
36 context->getRef(),
37 mlirAMDGPUTDMBaseTypeGet(context.get()->get(), elementType));
38 },
39 "Gets an instance of TDMBaseType in the same context",
40 nb::arg("element_type"), nb::arg("context").none() = nb::none());
41 }
42};
43
44struct TDMDescriptorType : PyConcreteType<TDMDescriptorType> {
45 static constexpr IsAFunctionTy isaFunction =
49 static constexpr const char *pyClassName = "TDMDescriptorType";
51 using Base::Base;
52
53 static void bindDerived(ClassTy &c) {
54 c.def_static(
55 "get",
56 [](DefaultingPyMlirContext context) {
57 return TDMDescriptorType(
58 context->getRef(),
59 mlirAMDGPUTDMDescriptorTypeGet(context.get()->get()));
60 },
61 "Gets an instance of TDMDescriptorType in the same context",
62 nb::arg("context").none() = nb::none());
63 }
64};
65
66struct TDMGatherBaseType : PyConcreteType<TDMGatherBaseType> {
67 static constexpr IsAFunctionTy isaFunction =
71 static constexpr const char *pyClassName = "TDMGatherBaseType";
73 using Base::Base;
74
75 static void bindDerived(ClassTy &c) {
76 c.def_static(
77 "get",
78 [](const PyType &elementType, const PyType &indexType,
80 return TDMGatherBaseType(
81 context->getRef(),
82 mlirAMDGPUTDMGatherBaseTypeGet(context.get()->get(), elementType,
83 indexType));
84 },
85 "Gets an instance of TDMGatherBaseType in the same context",
86 nb::arg("element_type"), nb::arg("index_type"),
87 nb::arg("context").none() = nb::none());
88 }
89};
90
96} // namespace amdgpu
97} // namespace MLIR_BINDINGS_PYTHON_DOMAIN
98} // namespace python
99} // namespace mlir
100
101NB_MODULE(_mlirDialectsAMDGPU, m) {
102 m.doc() = "MLIR AMDGPU dialect.";
103
106}
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:278
PyType(PyMlirContextRef contextRef, MlirType type)
Definition IRCore.h:876
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:78