View all files | ||||
MLIR-based GEMM, convolution, attention, GEMM+GEMM, and CONV+GEMM kernel generator for AMD GPUs.
rocMLIR is an MLIR-based GPU kernel generator targeting AMD GPUs. The high-level lowering is migraphx -> tosa / linalg -> rock, which then continues through MLIR's amdgpu and rocdl dialects to HSACO via the LLVM AMDGPU backend (vendored under external/llvm-project/).
It targets AMD CDNA and RDNA GPUs (gfx9xx / gfx10xx / gfx11xx / gfx12xx), and is primarily consumed as the static librockCompiler library by MIGraphX, though it can also be driven standalone for kernel generation, validation, and performance tuning.
To not actually run the tests, use check-rocmlir-build-only.
To build the static librockCompiler library used by MIGraphX:
To install librockCompiler so MIGraphX can find it:
Additional developer documentation lives under mlir/docs/.
A typical standalone pipeline generates a kernel with rocmlir-gen, lowers it with rocmlir-driver -c, and runs it via rocm-run -- a wrapper around mlir-runner that auto-locates the rocMLIR build and the LLVM build directory under external/llvm-project/, and links the right runtime libraries (libmlir_rocm_runtime, libconv-validation-wrappers, runner utils, etc.):
Useful rocmlir-gen flags:
Run build/bin/rocmlir-gen --help for the full, current option list.
rocmlir-driver is a wrapper around the kernel generation pipeline. Use -c (or --kernel-pipeline=full --host-pipeline=runner) to run the default pipeline. Adding --debug-only=serialize-to-isa will dump the GCN assembly for the executed kernels to standard error.
More examples live under mlir/test/rocmlir-driver/ (notably sanity.mlir), with end-to-end PR tests under mlir/test/fusion/pr-e2e/ (including the MIGraphX-dialect mixr-* tests) and mlir/test/fusion/e2e/. To build and run the full in-tree test suite (from the build directory):
By default, we infer the use of GPU-specific acceleration instructions (MFMA or WMMA) based on the features of the currently available GPU. To disable this, add -DROCMLIR_GEN_FLAGS="-mfma=off -wmma=off" to the cmake invocation above. Note that this will not affect behavior in production/static library builds, which do not use rocmlir-gen.
We welcome contributions! Please read CONTRIBUTING.md for the issue-reporting and pull-request workflow.
For bugs and feature requests, open a GitHub Issue.
To report a security vulnerability, do not open a public GitHub issue. See SECURITY.md for our responsible disclosure policy.
For questions, issues, or contributions, please reach out to the maintainers:
See CODEOWNERS for the full ownership list.
This project is licensed under the Apache License 2.0 with LLVM Exceptions.