-
Notifications
You must be signed in to change notification settings - Fork 13.4k
/
Copy pathDialectNVGPU.cpp
41 lines (35 loc) · 1.54 KB
/
DialectNVGPU.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//===--- DialectNVGPU.cpp - Pybind module for NVGPU dialect API support ---===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "mlir-c/Dialect/NVGPU.h"
#include "mlir-c/IR.h"
#include "mlir/Bindings/Python/NanobindAdaptors.h"
#include "mlir/Bindings/Python/Nanobind.h"
namespace nb = nanobind;
using namespace llvm;
using namespace mlir;
using namespace mlir::python;
using namespace mlir::python::nanobind_adaptors;
static void populateDialectNVGPUSubmodule(const nb::module_ &m) {
auto nvgpuTensorMapDescriptorType = mlir_type_subclass(
m, "TensorMapDescriptorType", mlirTypeIsANVGPUTensorMapDescriptorType);
nvgpuTensorMapDescriptorType.def_classmethod(
"get",
[](nb::object cls, MlirType tensorMemrefType, int swizzle, int l2promo,
int oobFill, int interleave, MlirContext ctx) {
return cls(mlirNVGPUTensorMapDescriptorTypeGet(
ctx, tensorMemrefType, swizzle, l2promo, oobFill, interleave));
},
"Gets an instance of TensorMapDescriptorType in the same context",
nb::arg("cls"), nb::arg("tensor_type"), nb::arg("swizzle"),
nb::arg("l2promo"), nb::arg("oob_fill"), nb::arg("interleave"),
nb::arg("ctx").none() = nb::none());
}
NB_MODULE(_mlirDialectsNVGPU, m) {
m.doc() = "MLIR NVGPU dialect.";
populateDialectNVGPUSubmodule(m);
}