1baa5beecStyb0807 //===--- DialectNVGPU.cpp - Pybind module for NVGPU dialect API support ---===// 24f88c231SGuray Ozen // 34f88c231SGuray Ozen // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 44f88c231SGuray Ozen // See https://llvm.org/LICENSE.txt for license information. 54f88c231SGuray Ozen // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 64f88c231SGuray Ozen // 74f88c231SGuray Ozen //===----------------------------------------------------------------------===// 84f88c231SGuray Ozen 94f88c231SGuray Ozen #include "mlir-c/Dialect/NVGPU.h" 104f88c231SGuray Ozen #include "mlir-c/IR.h" 11*5cd42747SPeter Hawkins #include "mlir/Bindings/Python/NanobindAdaptors.h" 12*5cd42747SPeter Hawkins #include "mlir/Bindings/Python/Nanobind.h" 134f88c231SGuray Ozen 14*5cd42747SPeter Hawkins namespace nb = nanobind; 154f88c231SGuray Ozen using namespace llvm; 164f88c231SGuray Ozen using namespace mlir; 174f88c231SGuray Ozen using namespace mlir::python; 18*5cd42747SPeter Hawkins using namespace mlir::python::nanobind_adaptors; 194f88c231SGuray Ozen 20*5cd42747SPeter Hawkins static void populateDialectNVGPUSubmodule(const nb::module_ &m) { 214f88c231SGuray Ozen auto nvgpuTensorMapDescriptorType = mlir_type_subclass( 224f88c231SGuray Ozen m, "TensorMapDescriptorType", mlirTypeIsANVGPUTensorMapDescriptorType); 234f88c231SGuray Ozen 244f88c231SGuray Ozen nvgpuTensorMapDescriptorType.def_classmethod( 254f88c231SGuray Ozen "get", 26*5cd42747SPeter Hawkins [](nb::object cls, MlirType tensorMemrefType, int swizzle, int l2promo, 274f88c231SGuray Ozen int oobFill, int interleave, MlirContext ctx) { 284f88c231SGuray Ozen return cls(mlirNVGPUTensorMapDescriptorTypeGet( 294f88c231SGuray Ozen ctx, tensorMemrefType, swizzle, l2promo, oobFill, interleave)); 304f88c231SGuray Ozen }, 314f88c231SGuray Ozen "Gets an instance of TensorMapDescriptorType in the same context", 32*5cd42747SPeter Hawkins nb::arg("cls"), nb::arg("tensor_type"), nb::arg("swizzle"), 33*5cd42747SPeter Hawkins nb::arg("l2promo"), nb::arg("oob_fill"), nb::arg("interleave"), 34*5cd42747SPeter Hawkins nb::arg("ctx").none() = nb::none()); 354f88c231SGuray Ozen } 364f88c231SGuray Ozen 37*5cd42747SPeter Hawkins NB_MODULE(_mlirDialectsNVGPU, m) { 384f88c231SGuray Ozen m.doc() = "MLIR NVGPU dialect."; 394f88c231SGuray Ozen 40baa5beecStyb0807 populateDialectNVGPUSubmodule(m); 414f88c231SGuray Ozen } 42