[spirv] Migrate ConvertToGPUPass' invocation tiling logic (#5814)

`ConvertToGPUPass` is a sink for lowering away all Linalg ops
in the SPIR-V pipeline: it can distribute a Linalg op to both
global invocation IDs (if just having one-level distribution) or
local invocation IDs (if having two-level distribution). 

This is mostly historical; now we have more proper layering
in the pipeline where we perform the first-level tiling and
distribution at flow level and the second/third level at
`TileAndVectorizeInOneWorkgroupPass`, the functionality
in `ConvertToGPUPass` is overlapping with that, although
in a complementary way: the tiling in the former pass does
not handle the cases where we cannot do imperfect tiling;
it requires perfectly tiled cases, as we are assuming number
of processors equal to number of iterations to avoid generating
`scf.for` loop from the start. `ConvertToGPUPass` is more
generic and can handle all cases.  This is all opaque and
complicated. 

This commit relaxes the `TileAndVectorizeInOneWorkgroupPass`
to not assume the number of processors equal to the number
of iterations. Now we just tile and cyclically distribute using
`scf.for` loops. This causes issues for perfectly tiled cases
as we need to canonicalize the `affine.min` and one-trip
`scf.for` away to expose static sizes for further vectorization.
That can be done by pulling in additional canonicalization
patterns.

Also in order to utilize `TileAndVectorizeInOneWorkgroupPass`
for the second/third level tiling we need to have the corresponding
scheme in launch configuration for them. This commit also
adds the default second/third level tiling for all now supported
Linalg ops: no tiling on subgroup and tiling to 1 for invocations.
This at the same time helps to clean up a bunch of unwieldy
templated configurations for different ops..

Together, the above migrates the invocation tiling logic
in `ConvertToGPUPass` to their proper places. This is the
first step as reining in `ConvertToGPUPass` and launch
configurations.
13 files changed
tree: b6963fb743482d332a7d4a3555fe863dc84cdd9d
  1. .github/
  2. bindings/
  3. build_tools/
  4. colab/
  5. docs/
  6. experimental/
  7. integrations/
  8. iree/
  9. scripts/
  10. third_party/
  11. .bazelignore
  12. .bazelrc
  13. .bazelversion
  14. .clang-format
  15. .gitignore
  16. .gitmodules
  17. .style.yapf
  18. .yamllint.yml
  19. BUILD.bazel
  20. CMakeLists.txt
  21. configure_bazel.py
  22. CONTRIBUTING.md
  23. LICENSE
  24. README.md
  25. SUBMODULE_VERSIONS.txt
  26. WORKSPACE
README.md

IREE: Intermediate Representation Execution Environment

IREE (Intermediate Representation Execution Environment, pronounced as “eerie”) is an MLIR-based end-to-end compiler that lowers Machine Learning (ML) models to a unified IR optimized for real-time inference on mobile/edge devices against heterogeneous hardware accelerators. IREE also provides flexible deployment solutions for its compiled ML models.

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

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.

Build Status

CI SystemBuild SystemPlatformArchitectureComponentStatus
KokoroBazelLinuxx86Corekokoro_status_bazel_linux_x86_core
KokoroCMake & BazelLinuxx86-swiftshaderIntegrationskokoro_status_cmake-bazel_linux_x86-swiftshader_integrations
KokoroCMake & BazelLinuxx86-turingIntegrationskokoro_status_cmake-bazel_linux_x86-turing_integrations
KokoroCMakeLinuxx86-swiftshaderCore + Bindingskokoro_status_cmake_linux_x86-swiftshader
KokoroCMakeLinuxx86-swiftshader-asanCore + Bindingskokoro_status_cmake_linux_x86-swiftshader-asan
KokoroCMakeLinuxx86-turingCore + Bindingskokoro_status_cmake_linux_x86-turing
KokoroCMakeAndroidarm64-v8aRuntime (build only)kokoro_status_cmake_android_arm64-v8a
BuildKiteCMakeAndroidarm64-v8aRuntimebuildkite-status-cmake-android-arm

Presentations and Talks

  • 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 license. See LICENSE for more information.