Adding plumbing and samples of custom CUDA/SPIR-V/CPU dispatch code. (#11287)

This adds a skeleton workflow for declaring external objects that are
able to be referenced by the compiler all the way from the high-level
dialects (flow, at least) and a sample demonstrating how device
functions in .cu, .glsl, and .o files can be connected end-to-end with
execution. The end goal is to allow codegen backends - including
extensions - to either select from precompiled object files or
generate/JIT their own as part of translation.

The core feature added is the `#hal.executable.object` attribute that
allows executable variants to have extra object files specified:
```mlir
hal.executable private @executable {
  // Variant linking in an x86-64 object file containing external functions.
  hal.executable.variant public @x86_64, target = #x86_64_target, objects = [
    // Object files linked into the executable.
    #hal.executable.object<{
      // Referencing a file path on disk but could also have the data embedded.
      path = "samples/custom_dispatch/cpu/embedded/functions.o"
    }>
```
The attribute also allows for data to be directly embedded and (in the
future) specified via MLIR external resources. When using file paths
either the absolute path, a path relative to the current working
directory, or a relative path joined with search paths will be tried.
`--iree-hal-executable-object-search-path=` can be specified multiple
times to add to the search paths.

This can be extended as required for new backends (.metallibs and
archives) as well as various formats for the existing ones (linking .spv
files together, .bc instead of .o for LLVM IR, etc). There's some work
to be done around interactions with linking phases that may limit the
usefulness of these stages for cross-compilation but at least for now we
can rely on a bleeding-edge user wanting to hand-author these dispatch
functions not caring about it yet. Since objects are specified
per-variant it's possible for a user to still cross-compile and
multi-target just with a bit more IR (today). It's also possible to
specify the objects at the stream level and (if we have a good story for
tensor -> pointers) we could allow it at the flow/input-level too.

Some future ergonomics improvements are tracked in #11289.
In particular there will be a way to avoid the boilerplate the CPU side
requires by having us generate that automatically for some very basic
interfaces (limited access to workgroup params and the environment).
tree: 44d5bb4199bf2e9606a56933d38d5f6ca3a66695
  1. .github/
  2. benchmarks/
  3. build_tools/
  4. compiler/
  5. docs/
  6. experimental/
  7. integrations/
  8. llvm-external-projects/
  9. runtime/
  10. samples/
  11. tests/
  12. third_party/
  13. tools/
  14. .bazelignore
  15. .bazelrc
  16. .bazelversion
  17. .clang-format
  18. .dockerignore
  19. .gitignore
  20. .gitmodules
  21. .pylintrc
  22. .style.yapf
  23. .yamllint.yml
  24. AUTHORS
  25. BUILD.bazel
  26. CITATION.cff
  27. CMakeLists.txt
  28. configure_bazel.py
  29. CONTRIBUTING.md
  30. gpudag.txt
  31. LICENSE
  32. README.md
  33. WORKSPACE
README.md

IREE: Intermediate Representation Execution Environment

IREE (Intermediate Representation Execution Environment, pronounced as “eerie”) is an MLIR-based end-to-end compiler and runtime that lowers Machine Learning (ML) models to a unified IR that scales up to meet the needs of the datacenter and down to satisfy the constraints and special considerations of mobile and edge deployments.

See our website for project details, user guides, and instructions on building from source.

CI Status

Project Status

IREE is still in its early phase. We have settled down on the overarching infrastructure and are actively improving various software components as well as project logistics. It is still quite far from ready for everyday use and is made available without any support at the moment. With that said, we welcome any kind of feedback on any communication channels!

Communication Channels

Related Project Channels

  • MLIR topic within LLVM Discourse: IREE is enabled by and heavily relies on MLIR. IREE sometimes is referred to in certain MLIR discussions. Useful if you are also interested in MLIR evolution.

Architecture Overview

IREE Architecture IREE Architecture

See our website for more information.

Presentations and Talks

  • 2021-06-09: IREE Runtime Design Tech Talk (recording and slides)
  • 2020-08-20: IREE CodeGen: MLIR Open Design Meeting Presentation (recording and slides)
  • 2020-03-18: Interactive HAL IR Walkthrough (recording)
  • 2020-01-31: End-to-end MLIR Workflow in IREE: MLIR Open Design Meeting Presentation (recording and slides)

License

IREE is licensed under the terms of the Apache 2.0 License with LLVM Exceptions. See LICENSE for more information.