1//===--- DialectNvgpu.cpp - Pybind module for Nvgpu 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/NVGPU.h"
10#include "mlir-c/IR.h"
11#include "mlir/Bindings/Python/PybindAdaptors.h"
12#include <pybind11/pybind11.h>
13
14namespace py = pybind11;
15using namespace llvm;
16using namespace mlir;
17using namespace mlir::python;
18using namespace mlir::python::adaptors;
19
20static void populateDialectNvgpuSubmodule(const pybind11::module &m) {
21 auto nvgpuTensorMapDescriptorType = mlir_type_subclass(
22 m, "TensorMapDescriptorType", mlirTypeIsANVGPUTensorMapDescriptorType);
23
24 nvgpuTensorMapDescriptorType.def_classmethod(
25 "get",
26 [](py::object cls, MlirType tensorMemrefType, int swizzle, int l2promo,
27 int oobFill, int interleave, MlirContext ctx) {
28 return cls(mlirNVGPUTensorMapDescriptorTypeGet(
29 ctx, tensorMemrefType, swizzle, l2promo, oobFill, interleave));
30 },
31 "Gets an instance of TensorMapDescriptorType in the same context",
32 py::arg("cls"), py::arg("tensor_type"), py::arg("swizzle"),
33 py::arg("l2promo"), py::arg("oob_fill"), py::arg("interleave"),
34 py::arg("ctx") = py::none());
35}
36
37PYBIND11_MODULE(_mlirDialectsNvgpu, m) {
38 m.doc() = "MLIR NVGPU dialect.";
39
40 populateDialectNvgpuSubmodule(m);
41}
42

source code of mlir/lib/Bindings/Python/DialectNVGPU.cpp