制作者的介绍仅有上面的一句话。 更多详情请阅读仓库 README。 仓库 README ↗
正在加载完整 README。
查看完整 README ↗Numba-CUDA-MLIR provides a programming model similar to CUDA C++ in Python. It is evolved from Numba-CUDA, and is intended to be compatible with Numba-CUDA kernels.
Numba-CUDA-MLIR aims to interoperate well with existing programming models whilst also allowing experts sufficient control over code generation.
Install with pip:
pip install numba-cuda-mlir[cu13] # or [cu12] if using CUDA 12
Writing and executing a simple vector add kernel:
import numpy as np
from numba_cuda_mlir import cuda
@cuda.jit
def vector_add(a, b, out):
i = cuda.grid(1)
if i < out.shape[0]:
out[i] = a[i] + b[i]
n = 1_000_000
a = np.ones(n, dtype=np.float32)
b = np.ones(n, dtype=np.float32)
out = np.zeros(n, dtype=np.float32)
threads_per_block = 256
blocks = (n + threads_per_block - 1) // threads_per_block
vector_add[blocks, threads_per_block](a, b, out)
Change imports to use the numba_cuda_mlir.cuda package instead of
numba.cuda. For example:
from numba import cuda
becomes:
from numba_cuda_mlir import cuda
For the majority of code using Numba-CUDA, this should be a sufficient change to enable the use of Numba-CUDA-MLIR. For code using the extension APIs, modifications will be required as Numba-CUDA-MLIR uses MLIR in its code generation process instead of LLVM IR. See the Migration Guidance in the documentation for further details.
cuda.core and cuda-bindings packagesPython 3.10 is no longer supported; use Python 3.11 or newer.
For full details of installation methods including from packages and building from source and testing, please see INSTALL.md.
See the Contribution Guidelines for information on how to set up a development environment and follow the contribution process.
A small suite of benchmarks can be executed from the source repository by running:
pytest tests/benchmarks/ --benchmark -s
Numba-CUDA-MLIR is distributed under the Apache License 2.0.
It incorporates the following third-party projects, each retained under its original license:
See NOTICE for
the full attribution map and per-component locations in this repository, and
THIRD-PARTY-LICENSES
for the verbatim upstream license texts.
Contributions are accepted under the terms described in
CONTRIBUTING.md.