[StableHLO] Use stablehlo submodule (#14094)
Use the stablehlo submodule to provide stablehlo, since we do not need
the 'mhlo' part or mlir-hlo anymore.
Fixes: https://github.com/openxla/iree/issues/12678
---------
Co-authored-by: Scott Todd <scotttodd@google.com>
diff --git a/.gitmodules b/.gitmodules
index 384ac8f..22e0981 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -32,9 +32,6 @@
[submodule "third_party/cpuinfo"]
path = third_party/cpuinfo
url = https://github.com/pytorch/cpuinfo.git
-[submodule "third_party/mlir-hlo"]
- path = third_party/mlir-hlo
- url = https://github.com/iree-org/iree-mhlo-fork.git
[submodule "third_party/libyaml"]
path = third_party/libyaml
url = https://github.com/yaml/libyaml.git
@@ -44,3 +41,6 @@
[submodule "third_party/musl"]
path = third_party/musl
url = https://github.com/powderluv/musl.git
+[submodule "third_party/stablehlo"]
+ path = third_party/stablehlo
+ url = https://github.com/iree-org/stablehlo.git
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6041b86..3be93f0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -812,7 +812,7 @@
# Add default external projects.
iree_llvm_add_external_project(mlir-iree-dialects ${CMAKE_CURRENT_SOURCE_DIR}/llvm-external-projects/iree-dialects)
- iree_llvm_add_external_project(mlir-hlo ${CMAKE_CURRENT_SOURCE_DIR}/third_party/mlir-hlo)
+ iree_llvm_add_external_project(stablehlo ${CMAKE_CURRENT_SOURCE_DIR}/third_party/stablehlo)
if(IREE_INPUT_TORCH)
iree_llvm_add_external_project(torch-mlir-dialects ${CMAKE_CURRENT_SOURCE_DIR}/third_party/torch-mlir-dialects)
endif()
@@ -865,7 +865,7 @@
endif()
if(IREE_BUILD_COMPILER)
- add_subdirectory(build_tools/third_party/mlir-hlo EXCLUDE_FROM_ALL)
+ add_subdirectory(build_tools/third_party/stablehlo EXCLUDE_FROM_ALL)
endif()
if(IREE_BUILD_TESTS)
diff --git a/build_tools/bazel/workspace.bzl b/build_tools/bazel/workspace.bzl
index f54c920..10ff146 100644
--- a/build_tools/bazel/workspace.bzl
+++ b/build_tools/bazel/workspace.bzl
@@ -129,8 +129,8 @@
maybe(
native.local_repository,
- name = "mlir-hlo",
- path = paths.join(iree_path, "third_party/mlir-hlo"),
+ name = "stablehlo",
+ path = paths.join(iree_path, "third_party/stablehlo"),
)
maybe(
diff --git a/build_tools/bazel_to_cmake/bazel_to_cmake_targets.py b/build_tools/bazel_to_cmake/bazel_to_cmake_targets.py
index 7c70e30..9d95d23 100644
--- a/build_tools/bazel_to_cmake/bazel_to_cmake_targets.py
+++ b/build_tools/bazel_to_cmake/bazel_to_cmake_targets.py
@@ -78,9 +78,9 @@
"@llvm-project//mlir:VectorOps": ["MLIRVector"],
# StableHLO.
- "@mlir-hlo//stablehlo:chlo_ops": ["ChloOps",],
- "@mlir-hlo//stablehlo:stablehlo_ops": ["StablehloOps",],
- "@mlir-hlo//stablehlo:broadcast_utils": ["StablehloBroadcastUtils",],
+ "@stablehlo//:chlo_ops": ["ChloOps",],
+ "@stablehlo//:stablehlo_ops": ["StablehloOps",],
+ "@stablehlo//:broadcast_utils": ["StablehloBroadcastUtils",],
# NCCL
"@nccl//:headers": ["nccl::headers",],
diff --git a/build_tools/scripts/integrate/README.md b/build_tools/scripts/integrate/README.md
index 059fa63..bc9e882 100644
--- a/build_tools/scripts/integrate/README.md
+++ b/build_tools/scripts/integrate/README.md
@@ -4,7 +4,7 @@
party dependencies (which are submodules in the project):
* llvm-project
-* mlir-hlo
+* stablehlo
Depending on your activity, please refer to the appropriate script,
which has comments at the top on how to use it:
@@ -87,11 +87,11 @@
### Advancing the mainline branch in forks
-The IREE team maintains fork repositories for both llvm-project and mlir-hlo,
+The IREE team maintains fork repositories for both llvm-project and stablehlo,
allowing them to be patched out of band. These repositories are:
* https://github.com/iree-org/iree-llvm-fork (`main` branch)
-* https://github.com/iree-org/iree-mhlo-fork (`master` branch)
+* https://github.com/iree-org/stablehlo (`main` branch)
* https://github.com/iree-org/iree-tf-fork (`master` branch)
Iree repository has an
@@ -106,9 +106,9 @@
#### Strategy 1: Bump third_party/llvm-project in isolation
It is very common to only bump llvm-project and not sync to new versions of
-mlir-hlo and tensorflow. However, as we need to periodically integrate those
+stablehlo and tensorflow. However, as we need to periodically integrate those
as well, if the Google repositories are up to date and you have the option
-to integrate to a common LLVM commit, bringing mlir-hlo and tensorflow up
+to integrate to a common LLVM commit, bringing stablehlo and tensorflow up
to date as well, it can save some cycles overall.
In order to bump to the current ToT commit, simply run:
@@ -152,20 +152,20 @@
be prepared to settle in for a bit and play a triage role, working to get things
minimally to a point that you can shard failures to others.
-Note that if not bumping mlir-hlo, then it is likely that you will hit a
-compiler error in mlir-hlo at some point and will need to fix it. Advancing
+Note that if not bumping stablehlo, then it is likely that you will hit a
+compiler error in stablehlo at some point and will need to fix it. Advancing
it to HEAD is always an option, if that contains the fix, but this dependency
is unstable and should be maintained version locked with the integrations
directory. It is possible to advance it, but only if integrations tests pass,
and even then there is the chance for untested compatibility issues.
-Typically, for the parts of mlir-hlo that we use, changes can be trivial (a
+Typically, for the parts of stablehlo that we use, changes can be trivial (a
few lines, likely that you have already patched something similar in IREE).
Just make the changes in your submodule, commit them and push to a patch
branch with:
```
-$SCRIPTS/patch_module.py --module_name=mlir-hlo
+$SCRIPTS/patch_module.py --module_name=stablehlo
```
You can just do this in your integrate branch and incorporate the changes.
@@ -196,7 +196,7 @@
won't miss the commits when bumping submodules. If you don't know who is the
integrator, you can reach out to @hanchung on discord or add hanhanW as a reviewer.
-We support cherry-picking specific commits in to both llvm-project and mlir-hlo.
+We support cherry-picking specific commits in to both llvm-project and stablehlo.
This should only ever be done to incorporate patches that enable further
development and which will resolve automatically as part of a future
integrate of the respective module: make sure that you are only cherry-picking
@@ -205,12 +205,12 @@
with such changes, which will let you use the CI -- but please do not commit
experimental, non-upstream committed commits to the main project.
-The process for cherry-picking into llvm-project or mlir-hlo uses the same
+The process for cherry-picking into llvm-project or stablehlo uses the same
script. The first step is to prepare a patch branch and reset your local
submodule to track it:
```
-$SCRIPTS/patch_module.py --module={llvm-project|mlir-hlo}
+$SCRIPTS/patch_module.py --module={llvm-project|stablehlo}
```
If successful, this will allocate a new branch in the fork repo with a name
diff --git a/build_tools/scripts/integrate/iree_modules.py b/build_tools/scripts/integrate/iree_modules.py
index 3d9cf04..39ac4fd 100644
--- a/build_tools/scripts/integrate/iree_modules.py
+++ b/build_tools/scripts/integrate/iree_modules.py
@@ -30,14 +30,14 @@
fork_repository_pull="https://github.com/iree-org/iree-llvm-fork.git",
branch_prefix="patched-llvm-project-",
),
- "mlir-hlo":
+ "stablehlo":
ModuleInfo(
- name="mlir-hlo",
- path="third_party/mlir-hlo",
- branch_pin_file="third_party/mlir-hlo.branch-pin",
- default_repository_url="https://github.com/iree-org/iree-mhlo-fork.git",
- fork_repository_push="git@github.com:iree-org/iree-mhlo-fork.git",
- fork_repository_pull="https://github.com/iree-org/iree-mhlo-fork.git",
- branch_prefix="patched-mlir-hlo-",
+ name="stablehlo",
+ path="third_party/stablehlo",
+ branch_pin_file="third_party/stablehlo.branch-pin",
+ default_repository_url="https://github.com/iree-org/stablehlo.git",
+ fork_repository_push="git@github.com:iree-org/stablehlo.git",
+ fork_repository_pull="https://github.com/iree-org/stablehlo.git",
+ branch_prefix="patched-stablehlo-",
)
}
diff --git a/build_tools/scripts/integrate/patch_module.py b/build_tools/scripts/integrate/patch_module.py
index 7b77a75..6068cee 100755
--- a/build_tools/scripts/integrate/patch_module.py
+++ b/build_tools/scripts/integrate/patch_module.py
@@ -16,7 +16,7 @@
# git cherry-pick <some commit>
# 3. Run this script from the main IREE repository (one of the following):
# patch_module.py --module=llvm-project
-# patch_module.py --module=mlir-hlo
+# patch_module.py --module=stablehlo
# 4. Send a PR on the main IREE repo to bump the submodule. Be sure to include
# the name of the patch branch for posterity.
diff --git a/build_tools/third_party/mlir-hlo/CMakeLists.txt b/build_tools/third_party/mlir-hlo/CMakeLists.txt
deleted file mode 100644
index a68af7e..0000000
--- a/build_tools/third_party/mlir-hlo/CMakeLists.txt
+++ /dev/null
@@ -1,29 +0,0 @@
-# Copyright 2020 The IREE Authors
-#
-# Licensed under the Apache License v2.0 with LLVM Exceptions.
-# See https://llvm.org/LICENSE.txt for license information.
-# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-set(TF_MLIR_HLO_SOURCE_DIR
- "${IREE_SOURCE_DIR}/third_party/mlir-hlo/"
-)
-set(TF_MLIR_HLO_BINARY_DIR
- "${IREE_BINARY_DIR}/llvm-external-projects/mlir-hlo"
-)
-
-external_cc_library(
- PACKAGE
- tensorflow
- NAME
- external_mhlo_includes
- ROOT
- ${TF_MLIR_HLO_SOURCE_DIR}
- INCLUDES
- "${TF_MLIR_HLO_SOURCE_DIR}"
- "${TF_MLIR_HLO_SOURCE_DIR}/include/"
- "${TF_MLIR_HLO_SOURCE_DIR}/stablehlo/"
- "${TF_MLIR_HLO_BINARY_DIR}"
- "${TF_MLIR_HLO_BINARY_DIR}/include/"
- "${TF_MLIR_HLO_BINARY_DIR}/stablehlo/"
- PUBLIC
-)
diff --git a/build_tools/third_party/stablehlo/CMakeLists.txt b/build_tools/third_party/stablehlo/CMakeLists.txt
new file mode 100644
index 0000000..568e47a
--- /dev/null
+++ b/build_tools/third_party/stablehlo/CMakeLists.txt
@@ -0,0 +1,12 @@
+# Copyright 2023 The IREE Authors
+#
+# Licensed under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+set(STABLEHLO_SOURCE_DIR
+ "${IREE_SOURCE_DIR}/third_party/stablehlo/"
+)
+set(STABLEHLO_BINARY_DIR
+ "${IREE_BINARY_DIR}/llvm-external-projects/stablehlo"
+)
diff --git a/compiler/bindings/python/CMakeLists.txt b/compiler/bindings/python/CMakeLists.txt
index 0c03446..38c420c 100644
--- a/compiler/bindings/python/CMakeLists.txt
+++ b/compiler/bindings/python/CMakeLists.txt
@@ -34,8 +34,8 @@
"${IREE_SOURCE_DIR}/compiler/bindings/c"
"${IREE_SOURCE_DIR}/llvm-external-projects/iree-dialects/include"
"${IREE_SOURCE_DIR}/third_party/llvm-project/mlir/include"
- "${IREE_SOURCE_DIR}/third_party/mlir-hlo/include"
- "${IREE_SOURCE_DIR}/third_party/mlir-hlo"
+ "${IREE_SOURCE_DIR}/third_party/stablehlo/include"
+ "${IREE_SOURCE_DIR}/third_party/stablehlo"
)
# On Unixes, disable the creation of versioned/symlinked `.so` files. With
diff --git a/compiler/setup.py b/compiler/setup.py
index df9e1e9..562d194 100644
--- a/compiler/setup.py
+++ b/compiler/setup.py
@@ -355,7 +355,7 @@
print(f"ERROR: Could not get IREE revision: {e}", file=sys.stderr)
revisions["LLVM_PROJECT"] = find_git_submodule_revision(
"third_party/llvm-project")
- revisions["MLIR_HLO"] = find_git_submodule_revision("third_party/mlir-hlo")
+ revisions["STABLEHLO"] = find_git_submodule_revision("third_party/stablehlo")
return revisions
diff --git a/compiler/src/iree/compiler/InputConversion/Common/BUILD.bazel b/compiler/src/iree/compiler/InputConversion/Common/BUILD.bazel
index 3f944a5..a3d7e7b 100644
--- a/compiler/src/iree/compiler/InputConversion/Common/BUILD.bazel
+++ b/compiler/src/iree/compiler/InputConversion/Common/BUILD.bazel
@@ -105,7 +105,7 @@
"@llvm-project//mlir:Pass",
"@llvm-project//mlir:TosaDialect",
"@llvm-project//mlir:Transforms",
- "@mlir-hlo//stablehlo:stablehlo_ops",
+ "@stablehlo//:stablehlo_ops",
"@torch-mlir-dialects//:TorchMLIRTMTensorDialect",
],
)
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/BUILD.bazel b/compiler/src/iree/compiler/InputConversion/StableHLO/BUILD.bazel
index ff0e92c..4a457e9 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/BUILD.bazel
+++ b/compiler/src/iree/compiler/InputConversion/StableHLO/BUILD.bazel
@@ -53,8 +53,8 @@
tblgen = "@llvm-project//mlir:mlir-tblgen",
td_file = "CHLODecompositionPatterns.td",
deps = [
- "@mlir-hlo//stablehlo:chlo_ops_td_files",
- "@mlir-hlo//stablehlo:stablehlo_ops_td_files",
+ "@stablehlo//:chlo_ops_td_files",
+ "@stablehlo//:stablehlo_ops_td_files",
],
)
@@ -115,9 +115,9 @@
"@llvm-project//mlir:TensorUtils",
"@llvm-project//mlir:Transforms",
"@llvm-project//mlir:VectorDialect",
- "@mlir-hlo//stablehlo:broadcast_utils",
- "@mlir-hlo//stablehlo:chlo_ops",
- "@mlir-hlo//stablehlo:stablehlo_ops",
+ "@stablehlo//:broadcast_utils",
+ "@stablehlo//:chlo_ops",
+ "@stablehlo//:stablehlo_ops",
],
)
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/CMakeLists.txt b/compiler/src/iree/compiler/InputConversion/StableHLO/CMakeLists.txt
index f23c246..4674e8a 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/CMakeLists.txt
+++ b/compiler/src/iree/compiler/InputConversion/StableHLO/CMakeLists.txt
@@ -1,5 +1,5 @@
# Add this tablegen include to support CHLO rewrites with DRR.
-list(APPEND IREE_COMPILER_TABLEGEN_INCLUDE_DIRS "${IREE_SOURCE_DIR}/third_party/mlir-hlo/stablehlo")
+list(APPEND IREE_COMPILER_TABLEGEN_INCLUDE_DIRS "${IREE_SOURCE_DIR}/third_party/stablehlo")
### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_ABOVE_THIS_LINE ###
################################################################################
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/BUILD.bazel b/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/BUILD.bazel
index 5979832..165ce95 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/BUILD.bazel
+++ b/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/BUILD.bazel
@@ -53,7 +53,7 @@
td_file = "ComplexLoweringPatterns.td",
deps = [
"@llvm-project//mlir:FuncTdFiles",
- "@mlir-hlo//stablehlo:stablehlo_ops_td_files",
+ "@stablehlo//:stablehlo_ops_td_files",
],
)
@@ -90,7 +90,7 @@
"@llvm-project//mlir:Support",
"@llvm-project//mlir:TensorDialect",
"@llvm-project//mlir:Transforms",
- "@mlir-hlo//stablehlo:chlo_ops",
- "@mlir-hlo//stablehlo:stablehlo_ops",
+ "@stablehlo//:chlo_ops",
+ "@stablehlo//:stablehlo_ops",
],
)
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/CMakeLists.txt b/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/CMakeLists.txt
index 5aefb3a..8fccaef 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/CMakeLists.txt
+++ b/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/CMakeLists.txt
@@ -1,5 +1,5 @@
# Add this tablegen include to support stablehlo rewrites with DRR.
-list(APPEND IREE_COMPILER_TABLEGEN_INCLUDE_DIRS "${IREE_SOURCE_DIR}/third_party/mlir-hlo/stablehlo")
+list(APPEND IREE_COMPILER_TABLEGEN_INCLUDE_DIRS "${IREE_SOURCE_DIR}/third_party/stablehlo")
### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_ABOVE_THIS_LINE ###
################################################################################
diff --git a/compiler/src/iree/compiler/Tools/BUILD.bazel b/compiler/src/iree/compiler/Tools/BUILD.bazel
index 799372e..1bd4185 100644
--- a/compiler/src/iree/compiler/Tools/BUILD.bazel
+++ b/compiler/src/iree/compiler/Tools/BUILD.bazel
@@ -43,8 +43,8 @@
"@llvm-project//mlir:ConversionPasses",
"@llvm-project//mlir:IR",
"@llvm-project//mlir:TosaDialect",
- "@mlir-hlo//stablehlo:chlo_ops",
- "@mlir-hlo//stablehlo:stablehlo_ops",
+ "@stablehlo//:chlo_ops",
+ "@stablehlo//:stablehlo_ops",
"@torch-mlir-dialects//:TorchMLIRTMTensorDialect",
],
)
diff --git a/third_party/mlir-hlo b/third_party/mlir-hlo
deleted file mode 160000
index 63a907f..0000000
--- a/third_party/mlir-hlo
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 63a907f9839f06863a64d7f47d059624f7e035bf
diff --git a/third_party/stablehlo b/third_party/stablehlo
new file mode 160000
index 0000000..52de2c0
--- /dev/null
+++ b/third_party/stablehlo
@@ -0,0 +1 @@
+Subproject commit 52de2c0b4b7446a56e8985a4de6d50c1d8b47c3b