{"id":25165540,"url":"https://github.com/libxsmm/tpp-mlir","last_synced_at":"2025-04-05T17:06:44.887Z","repository":{"id":37907959,"uuid":"500473121","full_name":"libxsmm/tpp-mlir","owner":"libxsmm","description":"TPP experimentation on MLIR for linear algebra","archived":false,"fork":false,"pushed_at":"2025-01-18T00:47:43.000Z","size":59128,"stargazers_count":115,"open_issues_count":22,"forks_count":31,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-01-18T01:32:53.888Z","etag":null,"topics":["compiler","library","llvm","machine-learning","micro-kernel"],"latest_commit_sha":null,"homepage":"https://arxiv.org/abs/2404.15204","language":"MLIR","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/libxsmm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-06T14:45:43.000Z","updated_at":"2025-01-18T00:47:44.000Z","dependencies_parsed_at":"2023-09-27T15:47:35.009Z","dependency_job_id":"f6be94ca-0cff-4c99-9f04-ea808e4cb149","html_url":"https://github.com/libxsmm/tpp-mlir","commit_stats":null,"previous_names":["libxsmm/tpp-mlir"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libxsmm%2Ftpp-mlir","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libxsmm%2Ftpp-mlir/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libxsmm%2Ftpp-mlir/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libxsmm%2Ftpp-mlir/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/libxsmm","download_url":"https://codeload.github.com/libxsmm/tpp-mlir/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247369952,"owners_count":20927928,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compiler","library","llvm","machine-learning","micro-kernel"],"created_at":"2025-02-09T05:08:25.178Z","updated_at":"2025-04-05T17:06:44.870Z","avatar_url":"https://github.com/libxsmm.png","language":"MLIR","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TPP MLIR\n\nThis is an experiment in using MLIR to automatically select the best [Tensor Processing Primitives](https://arxiv.org/abs/2104.05755) for linear algebra.\n\nThis repository contains an out-of-tree [MLIR](https://mlir.llvm.org/) dialect as well as an `opt`-like tool to operate on that dialect and a `runner`-like tool to execute and benchmark MLIR kernels.\n\nIt also contains the recipes to use [LIBXSMM](https://github.com/libxsmm/libxsmm) from inside MLIR and can be used by other tools to drive our passes.\n\nThis repository was previously called `tpp-sandbox`.\nIf you have a checkout with the previous name, please follow [these instructions](https://docs.github.com/en/repositories/creating-and-managing-repositories/renaming-a-repository) to rename the remote locally.\n\n## Build Status\n\n[![TPP-MLIR Base Tests](https://github.com/plaidml/tpp-mlir/actions/workflows/tpp-mlir.yml/badge.svg)](https://github.com/plaidml/tpp-mlir/actions/workflows/tpp-mlir.yml)\n\n[![TPP-MLIR Benchmarks](https://github.com/plaidml/tpp-mlir/actions/workflows/tpp-benchmark.yml/badge.svg)](https://github.com/plaidml/tpp-mlir/actions/workflows/tpp-benchmark.yml)\n\n[![TPP-MLIR Arm Graviton 3](https://github.com/libxsmm/tpp-mlir/actions/workflows/tpp-graviton.yml/badge.svg)](https://github.com/libxsmm/tpp-mlir/actions/workflows/tpp-graviton.yml)\n\n## How to setup the environment\n\nIn order to build LLVM and TPP-MLIR, several software development tools such as git, cmake, compilers, etc. are needed.\nIf you're able to build LLVM, you'll be able to build our project, but we do have some additional (optional) dependencies (OneDNN, OpenMP) that can be disabled (see below).\nOur required dependencies (libxsmm, libxsmm-dnn) are fetched and built by our build system, so you should have no problems either.\n\nIf you're having trouble with your build, you can use Conda to create a minimal environment (see below).\n\n## How to build LLVM\n\n```sh\n# Clone\ngit clone https://github.com/llvm/llvm-project.git\n\n# checking out a tpp-mlir compatible version of llvm-project\nwget https://raw.githubusercontent.com/libxsmm/tpp-mlir/main/build_tools/llvm_version.txt\npushd llvm-project\ngit checkout `cat ../llvm_version.txt`\npopd\nrm llvm_version.txt\n\n# create build dir\nmkdir llvm-project/build\npushd llvm-project/build\n\n# This is important for the next step\nexport CUSTOM_LLVM_ROOT=`pwd`\necho $CUSTOM_LLVM_ROOT\nexport PATH=$CUSTOM_LLVM_ROOT/bin:$PATH\n\n# Configure Build\ncmake -G Ninja ../llvm \\\n   -DLLVM_ENABLE_PROJECTS=\"mlir\" \\\n   -DLLVM_BUILD_EXAMPLES=ON \\\n   -DLLVM_INSTALL_UTILS=ON \\\n   -DLLVM_TARGETS_TO_BUILD=\"host\" \\\n   -DCMAKE_BUILD_TYPE=Release \\\n   -DLLVM_ENABLE_ASSERTIONS=ON \\\n   -DCMAKE_C_COMPILER=clang \\\n   -DCMAKE_CXX_COMPILER=clang++ \\\n   -DLLVM_USE_LINKER=lld\n\n# Build\nninja \n\npopd\n```\n\n## How to build TPP MLIR\n\nThis setup assumes that you have built LLVM and MLIR in `$CUSTOM_LLVM_ROOT` as above.\n\n_Note: OpenMP is a requirement to get multi-threaded performance on our code.\nIf you don't want to build with OpenMP, disable with the CMake flag `-DUSE_OpenMP=False`._\n\n_Note: OneDNN is a requirement to get performance comparisons against our code.\nIf you don't want to build with OneDNN, disable with the CMake flag `-DUSE_OneDNN=False`._\n\n```sh\n# Clone\ngit clone https://github.com/libxsmm/tpp-mlir.git\nmkdir tpp-mlir/build\npushd tpp-mlir/build\n\n# Build \u0026 test\n# Please, make sure to use clang to build TPP-MLIR\ncmake -G Ninja .. \\\n   -DCMAKE_BUILD_TYPE=Release \\\n   -DMLIR_DIR=$CUSTOM_LLVM_ROOT/lib/cmake/mlir \\\n   -DLLVM_EXTERNAL_LIT=$CUSTOM_LLVM_ROOT/bin/llvm-lit \\\n   -DCMAKE_C_COMPILER=clang \\\n   -DCMAKE_CXX_COMPILER=clang++ \\\n   -DLLVM_USE_LINKER=lld\ncmake --build . --target check-tpp\n\npopd\n```\n\nTo enable experimental GPU support see: [GPU/README.md](lib/TPP/GPU/README.md)\n\nIn the example above, we are building both LLVM/MLIR and tpp-mlir in relese mode. You can easily change the build type by adopting the `-DCMAKE_BUILD_TYPE` option, e.g. `=DCMAKE_BUILD_TYPE=RelWithDebInfo`. \n\n### Conda Environment\n\nEvery modern Linux and MacOS system should be able to build our project without glitches, however, you may have an older OS or some special condisiont (cluster environment).\nAs each operating system has its own package manager and package names, we opted for providing instructions for the user-level package manager ```conda```.\nThis environment has been successfully tested on top of a Fedora Server minimal installation with less than 400 system-wide packages being installed.\n\nInitial Setup (using Conda via Miniforge):\n```sh\nexport TPPMLIR_WORKSPACE_DIR=/foo\ncd ${TPPMLIR_WORKSPACE_DIR}\nexport ARCH_NAME=$(uname -m)\nwget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-${ARCH_NAME}.sh\nbash Miniforge3-Linux-${ARCH_NAME}.sh -b -p ${TPPMLIR_WORKSPACE_DIR}/miniforge3\neval \"$(${TPPMLIR_WORKSPACE_DIR}/miniforge3/bin/conda shell.bash hook)\"\nconda activate\n\nconda install -y cmake ninja git clang clangxx llvm lld llvm-openmp llvm-tools binutils\nif [ \"${ARCH_NAME}\" == \"aarch64\" ]; then\n   conda install -y gcc_linux-aarch64 gxx_linux-aarch64\nelif [ \"${ARCH_NAME}\" == \"x86_64\" ]; then\n   conda install -y gcc_linux-64 gxx_linux-64\nfi\npython -m pip install coloredlogs\n```\n\nReloading the environment  after conda deactivate/logout/reboot:\n```sh\nexport TPPMLIR_WORKSPACE_DIR=/foo\ncd ${TPPMLIR_WORKSPACE_DIR}\neval \"$(${TPPMLIR_WORKSPACE_DIR}/miniforge3/bin/conda shell.bash hook)\"\nconda activate\n```\n\n### Formatting Tools\n\nOur project uses Python and C++ source formating tools.\nThere are two Ninja targets to verify the formatting:\n * `check-clang`, which uses clang-format version 16\n * `check-python`, which uses Python's `black` or `autopep8` lint checkers\n\nDue to `clang-format`'s instability and non-backwards compatibility, we require that the version used be 16.\nIf you have another version of `clang` installed, make sure you install `clang-format-16` on your system.\n\nPlease, do not submit PRs with formatting issues on other files than you're making your code changes.\nAlso avoid PRs with too many formatting changes in the same file on unrelated code.\n\n## License\n\nThis project is made available under the Apache License 2.0 with LLVM Exceptions. See the `LICENSE.txt` file for more details.\n\n## References\n\nBRGEMM: [High-Performance Deep Learning via a Single Building Block (2019)](https://arxiv.org/abs/1906.06440)\n\nTPP: [Tensor Processing Primitives: A Programming Abstraction for Efficiency and Portability in Deep Learning \u0026 HPC Workloads (2021)](https://arxiv.org/abs/2104.05755)\n\nPARLOOPER: [Harnessing Deep Learning and HPC Kernels via High-Level Loop and Tensor Abstractions on CPU Architectures (2023)](https://arxiv.org/abs/2304.12576)\n\nTPP-MLIR: [Towards a high-performance AI compiler with upstream MLIR (2024)](https://arxiv.org/abs/2404.15204)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibxsmm%2Ftpp-mlir","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flibxsmm%2Ftpp-mlir","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibxsmm%2Ftpp-mlir/lists"}