(pronounced "you-dsl")
This repository contains the source code for EUDSL, a toolkit for the construction of
embedded DSLs, in arbitrary languages, for targeting MLIR.
FYI: this project is currently "alpha" quality.
Currently, there are six components:
nanobind bindings;pip install mlir-python-bindings -f https://llvm.github.io/eudsl.pip install eudsl-python-extras -f https://llvm.github.io/eudsl if used with the upstream bindings.$ EUDSL_PYTHON_EXTRAS_HOST_PACKAGE_PREFIX=<YOUR_HOST_MLIR_PYTHON_PACKAGE_PREFIX> \
pip install eudsl-python-extras -f https://llvm.github.io/eudsl
where EUDSL_PYTHON_EXTRAS_HOST_PACKAGE_PREFIX is (as it says) the package prefix for your chosen host bindings.
When in doubt about this prefix, it is everything up until ir when you import your bindings, e.g., in import torch_mlir.ir,
torch_mlir is the EUDSL_PYTHON_EXTRAS_HOST_PACKAGE_PREFIX for the torch-mlir bindings.pip install mlir-python-mcp -f https://llvm.github.io/eudsl..mcp.json snippet and the list of tools.nanobind wrapper over the LLVM C++ API, so the Python class hierarchy mirrors llvm::; the DSL lowers a decorated Python function (with ordinary arithmetic and if/while/for) to a compiled llvm::Function.llvm.mir, reaches one level lower — LLVM's post-instruction-selection Machine IR — with the same split: hand-written bindings over the MachineFunction/MachineInstr object model plus a @machine_function DSL for building generic (GlobalISel) MIR.pip install eudsl-llvmpy -f https://llvm.github.io/eudsl.We currently provide two online playgrounds where you can try out the WebAssembly version of mlir-python-bindings and eudsl-python-extras directly in your browser:
https://llvm.github.io/eudsl/jupyter – A JupyterLite instance with a Pyodide kernel. You can install the MLIR Python bindings with: await piplite.install("mlir-python-bindings").
https://llvm.github.io/eudsl/console – A Pyodide-based REPL with mlir-python-bindings and eudsl-python-extras preloaded. Just run: from mlir.ir import * to start coding.
Python wheels of all the tools are available at the eudsl release page.
They are also pip install-able with .e.g
$ pip install mlir-python-bindings -f https://llvm.github.io/eudsl
// or
$ pip install eudsl-python-extras -f https://llvm.github.io/eudsl
If you don't want to install locally, here is a colab notebook minimal working example.
Strong recommendation: check the CI scripts @ .github/workflows - they do a fresh checkout and build on every commit and are written to be read by a non-CI expert.
Firstly, you need a distribution of LLVM. You can build LLVM from source using our submodule by doing (on Mac/Linux or mingw):
$ cd <EUDSL_CHECKOUT_DIR>
$ ./scripts/build_llvm.sh
Alternatively you can download a distribution for your platform from the llvm release page.
Then each of the above tools can both be built as a conventional, standalone, CMake project and as a Python wheel. The wheel build looks something like:
$ cd <EUDSL_CHECKOUT_DIR>
$ export CMAKE_PREFIX_PATH=$PWD/llvm-install
$ pip wheel projects/eudsl-nbgen -w wheelhouse -v
If you want to build an individual tool via CMake you can do something like:
$ cd <EUDSL_CHECKOUT_DIR>
$ pip install -r requirements.txt
$ export CMAKE_PREFIX_PATH=$PWD/llvm-install
$ cmake -B $PWD/eudsl-nbgen-build -S $PWD/projects/eudsl-nbgen -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/eudsl-nbgen-install
$ cmake --build "$PWD/eudsl-build" --target install
If you want to build all the tools at once using CMake you can use the root CMakeLists.txt.
If you want to build all the tools at once using CMake directly against third_party/llvm-project then (roughly) the CMake invocation is:
cmake -GNinja -B build -S <EUDSL_CHECKOUT_DIR>/third_party/llvm-project/llvm \
-DLLVM_EXTERNAL_PROJECTS=EUDSL \
-DLLVM_EXTERNAL_EUDSL_SOURCE_DIR=<EUDSL_CHECKOUT_DIR> \
-DLLVM_BUILD_LLVM_DYLIB=ON \
-DLLVM_ENABLE_PROJECTS=clang;mlir
Yes C++ headers... ↩
336 commits
251 commits
15 commits
4 commits
Python
73.5%
C++
21.6%
Jupyter Notebook
2.8%
CMake
1.5%
(pronounced "you-dsl")
This repository contains the source code for EUDSL, a toolkit for the construction of
embedded DSLs, in arbitrary languages, for targeting MLIR.
FYI: this project is currently "alpha" quality.
Currently, there are six components:
nanobind bindings;pip install mlir-python-bindings -f https://llvm.github.io/eudsl.pip install eudsl-python-extras -f https://llvm.github.io/eudsl if used with the upstream bindings.$ EUDSL_PYTHON_EXTRAS_HOST_PACKAGE_PREFIX=<YOUR_HOST_MLIR_PYTHON_PACKAGE_PREFIX> \
pip install eudsl-python-extras -f https://llvm.github.io/eudsl
where EUDSL_PYTHON_EXTRAS_HOST_PACKAGE_PREFIX is (as it says) the package prefix for your chosen host bindings.
When in doubt about this prefix, it is everything up until ir when you import your bindings, e.g., in import torch_mlir.ir,
torch_mlir is the EUDSL_PYTHON_EXTRAS_HOST_PACKAGE_PREFIX for the torch-mlir bindings.pip install mlir-python-mcp -f https://llvm.github.io/eudsl..mcp.json snippet and the list of tools.nanobind wrapper over the LLVM C++ API, so the Python class hierarchy mirrors llvm::; the DSL lowers a decorated Python function (with ordinary arithmetic and if/while/for) to a compiled llvm::Function.llvm.mir, reaches one level lower — LLVM's post-instruction-selection Machine IR — with the same split: hand-written bindings over the MachineFunction/MachineInstr object model plus a @machine_function DSL for building generic (GlobalISel) MIR.pip install eudsl-llvmpy -f https://llvm.github.io/eudsl.We currently provide two online playgrounds where you can try out the WebAssembly version of mlir-python-bindings and eudsl-python-extras directly in your browser:
https://llvm.github.io/eudsl/jupyter – A JupyterLite instance with a Pyodide kernel. You can install the MLIR Python bindings with: await piplite.install("mlir-python-bindings").
https://llvm.github.io/eudsl/console – A Pyodide-based REPL with mlir-python-bindings and eudsl-python-extras preloaded. Just run: from mlir.ir import * to start coding.
Python wheels of all the tools are available at the eudsl release page.
They are also pip install-able with .e.g
$ pip install mlir-python-bindings -f https://llvm.github.io/eudsl
// or
$ pip install eudsl-python-extras -f https://llvm.github.io/eudsl
If you don't want to install locally, here is a colab notebook minimal working example.
Strong recommendation: check the CI scripts @ .github/workflows - they do a fresh checkout and build on every commit and are written to be read by a non-CI expert.
Firstly, you need a distribution of LLVM. You can build LLVM from source using our submodule by doing (on Mac/Linux or mingw):
$ cd <EUDSL_CHECKOUT_DIR>
$ ./scripts/build_llvm.sh
Alternatively you can download a distribution for your platform from the llvm release page.
Then each of the above tools can both be built as a conventional, standalone, CMake project and as a Python wheel. The wheel build looks something like:
$ cd <EUDSL_CHECKOUT_DIR>
$ export CMAKE_PREFIX_PATH=$PWD/llvm-install
$ pip wheel projects/eudsl-nbgen -w wheelhouse -v
If you want to build an individual tool via CMake you can do something like:
$ cd <EUDSL_CHECKOUT_DIR>
$ pip install -r requirements.txt
$ export CMAKE_PREFIX_PATH=$PWD/llvm-install
$ cmake -B $PWD/eudsl-nbgen-build -S $PWD/projects/eudsl-nbgen -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/eudsl-nbgen-install
$ cmake --build "$PWD/eudsl-build" --target install
If you want to build all the tools at once using CMake you can use the root CMakeLists.txt.
If you want to build all the tools at once using CMake directly against third_party/llvm-project then (roughly) the CMake invocation is:
cmake -GNinja -B build -S <EUDSL_CHECKOUT_DIR>/third_party/llvm-project/llvm \
-DLLVM_EXTERNAL_PROJECTS=EUDSL \
-DLLVM_EXTERNAL_EUDSL_SOURCE_DIR=<EUDSL_CHECKOUT_DIR> \
-DLLVM_BUILD_LLVM_DYLIB=ON \
-DLLVM_ENABLE_PROJECTS=clang;mlir
Yes C++ headers... ↩
336 commits
251 commits
15 commits
4 commits
Python
73.5%
C++
21.6%
Jupyter Notebook
2.8%
CMake
1.5%