{"id":24824319,"url":"https://github.com/llvm/mlir-tcp","last_synced_at":"2025-10-13T22:31:51.019Z","repository":{"id":274890989,"uuid":"924334734","full_name":"llvm/mlir-tcp","owner":"llvm","description":"Tensor Compute Primitives: Mid-level Intermediate Representation for Machine Learning Programs","archived":false,"fork":false,"pushed_at":"2025-06-10T16:14:21.000Z","size":583,"stargazers_count":11,"open_issues_count":2,"forks_count":7,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-09-28T12:41:18.976Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/llvm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-01-29T20:19:44.000Z","updated_at":"2025-09-27T17:46:23.000Z","dependencies_parsed_at":"2025-04-17T04:57:39.380Z","dependency_job_id":"ecc35b53-129c-44a3-aad0-2c11b280aad9","html_url":"https://github.com/llvm/mlir-tcp","commit_stats":null,"previous_names":["llvm/mlir-tcp"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/llvm/mlir-tcp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/llvm%2Fmlir-tcp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/llvm%2Fmlir-tcp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/llvm%2Fmlir-tcp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/llvm%2Fmlir-tcp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/llvm","download_url":"https://codeload.github.com/llvm/mlir-tcp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/llvm%2Fmlir-tcp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279017161,"owners_count":26085983,"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","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-01-30T20:29:10.724Z","updated_at":"2025-10-13T22:31:51.014Z","avatar_url":"https://github.com/llvm.png","language":"MLIR","funding_links":[],"categories":[],"sub_categories":[],"readme":"Tensor Compute Primitives\n=========================\n\nMid-level intermediate representation for machine learning programs.\n\n[![Bazel Build and Test (mlir-tcp)](https://github.com/llvm/mlir-tcp/actions/workflows/bazelBuildAndTestTcp.yml/badge.svg)](https://github.com/llvm/mlir-tcp/actions/workflows/bazelBuildAndTestTcp.yml)\n\n:construction: **This project is under active development (WIP).**\n\n## Project Communication\n\n- For general discussion use `#mlir-tcp` channel on the [LLVM Discord](https://discord.gg/xS7Z362)\n- For feature request or bug report file a detailed [issue on GitHub](https://github.com/llvm/mlir-tcp/issues)\n\n## Developer Guide\n\nTo build TCP using Bazel, follow these steps:\n\n1. (Optional) For a quick start, launch an interactive docker container with clang (and lld) pre-installed:\n```shell\n./docker/run_docker.sh\n```\n\n2. You can now build `tcp-opt` by running:\n```shell\nbazel build //:tcp-opt\n```\n\n3. To run TCP lit and aot compile tests:\n```shell\nbazel test //...\n```\n\nWe welcome contributions to `mlir-tcp`. When authoring new TCP ops with dialect conversions from/to Torch and Linalg, please include lit tests for dialect and conversions, as well as [aot_compile](https://github.com/llvm/mlir-tcp/blob/main/tools/aot/README.md) generated e2e integration tests. Lastly, please finalize your PR with clang-format, black and bazel buildifier to ensure the C++/python sources and BUILD files are formatted consistently:\n```shell\n# clang-format\nfind . -type f -name \"*.cpp\" -o -name \"*.h\" | xargs clang-format -i\n\n# black\nblack .\n\n# buildifer\nbazel run //tools/buildifier:buildifier\n```\n\nTo enable [clangd](https://clangd.llvm.org/) (for code completion, navigation and insights), generate the compilation database using [bazel-compile-commands-extractor](https://github.com/hedronvision/bazel-compile-commands-extractor):\n```shell\nbazel build //...\n\nbazel run //tools/clangd:refresh_compile_commands\n```\nWhen run successfully, a `compile_commands.json` is generated at the workspace root (and refreshed upon re-runs). If you're using VSCode, just hit CMD+SHIFT+P and select `clangd: Restart language server` to start clangd. Note that this only works for non-docker builds at the moment.\n\nWhen bumping upstream dependencies (LLVM, Torch-MLIR), you may validate the set of \"green commits\" by running the corresponding third-party tests:\n```shell\nbazel test @llvm-project//mlir/...\nbazel test @torch-mlir//...\n```\n\nThe following CI workflows are automatically triggered anytime upstream dependencies (`deps.bzl`) are updated:\n- [![Bazel Build and Test (llvm-project)](https://github.com/llvm/mlir-tcp/actions/workflows/bazelBuildAndTestLlvm.yml/badge.svg)](https://github.com/llvm/mlir-tcp/actions/workflows/bazelBuildAndTestLlvm.yml)\n- [![Bazel Build and Test (torch-mlir)](https://github.com/llvm/mlir-tcp/actions/workflows/bazelBuildAndTestTorchmlir.yml/badge.svg)](https://github.com/llvm/mlir-tcp/actions/workflows/bazelBuildAndTestTorchmlir.yml)\n\nTo use newer `torch-mlir` and/or `torch` python packages in our hermetic python sandbox, just regenerate `requirements_lock.txt` as follows:\n```shell\ntruncate -s 0 requirements_lock.txt\nbazel run //tools/pip:requirements.update\n```\n\n## Debugging Guide\n\nBelow are some standard techniques for debugging your compilation process, assuming you've reduced it to a form that can be reproduced with `tcp-opt`. For MLIR-specific debugging tips, refer [here](https://mlir.llvm.org/getting_started/Debugging/).\n\n### `printf` debugging\n\nPrinting to stdout/stderr works as usual:\n```C++\nop.emitWarning() \u003c\u003c \"HERE: \" \u003c\u003c myVariable;      // preferred for op/loc diagnostics\n\nllvm::errs() \u003c\u003c \"HERE: \" \u003c\u003c myVariable \u003c\u003c \"\\n\";  // alternative\n```\n\nYou can also hook into the [LLVM_DEBUG](https://llvm.org/docs/ProgrammersManual.html#the-llvm-debug-macro-and-debug-option) macro:\n```C++\n#include \"llvm/Support/Debug.h\"\n\n#define DEBUG_TYPE \"foo\"\nLLVM_DEBUG(llvm::dbgs() \u003c\u003c \"This only shows up when -debug or -debug-only=foo is provided.\\n\");\n#undef DEBUG_TYPE\n\n#define DEBUG_TYPE \"bar\"\nLLVM_DEBUG(llvm::dbgs() \u003c\u003c \"This only shows up when -debug or -debug-only=bar is provided.\\n\");\n#undef DEBUG_TYPE\n```\n\nThen run with the `-debug-only=foo,bar` flag to cuts out messages that aren't associated with the passed `DEBUG_TYPE`s.\n```shell\nbazel run //:tcp-opt -- --some-pass `pwd`/test.mlir -debug-only=foo,bar\n```\n\n### `gdb` debugging\n\nTo debug `tcp-opt` with [gdb](https://www.sourceware.org/gdb/):\n```shell\nbazel build --config=gdb //:tcp-opt\n\ngdb --args bazel-bin/tcp-opt -h\n```\n\nFor help with gdb commands please refer to [gdb cheat sheet](https://gist.github.com/rkubik/b96c23bd8ed58333de37f2b8cd052c30).\n\n### `aot_compile` debugging\n\nRefer this [README](https://github.com/llvm/mlir-tcp/blob/main/tools/aot/README.md) for a step-by-step guide to debugging an end-to-end compilation pipeline using the AOT Compile framework.\n\n### Enable `llvm-symbolizer`\n\nIf you get a stack dump without any symbol names:\n```shell\nStack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):\n0  tcp-opt   0x000055ac1c9c0c1d\n1  tcp-opt   0x000055ac1c9c110b\n2  tcp-opt   0x000055ac1c9be846\n3  tcp-opt   0x000055ac1c9c1855\n4  libc.so.6 0x00007f7011c6a520\n...\n```\n\nDo this and re-run:\n```shell\nbazel build @llvm-project//llvm:llvm-symbolizer\nexport LLVM_SYMBOLIZER_PATH=`pwd`/bazel-bin/external/llvm-project/llvm/llvm-symbolizer\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fllvm%2Fmlir-tcp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fllvm%2Fmlir-tcp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fllvm%2Fmlir-tcp/lists"}