Migrate StableHLO input conversion to a compiler plugin. (#15568)
Progress on https://github.com/openxla/iree/issues/15468
StableHLO-specific changes:
* Added `input_stablehlo` plugin at
`compiler/plugins/input/StableHLO/stablehlo-iree/`
* Moved StableHLO input conversion code into the plugin
* Note file paths: `stablehlo-iree/Conversion` is used instead of
`stablehlo-iree/InputConversion` to save on lengths
* Torch and TOSA both have fewer characters and do not have a
`InputConversion/Preprocessing/` subfolder so they don't hit the same
limit
Cleanup now that all input dialect conversion is handled via plugins
consistently:
* Deleted `init_input_dialects.[h, cc]` and `init_input_passes.[h, cc]`
* Removed dialect-specific code paths from
`compiler/Pipelines/[Pipelines, Options].cpp`
* Generated more `CMakeList.txt` files from `BUILD.bazel` files (input
dialect dependencies and source files are organized into plugins with
their own top-level filtering)
* Added `auto_input_conversion.mlir` tests for each input plugin that
use `--compile-to=input` to show how the "auto" input type handles their
dialects
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index 39dc8a1..4b13c66 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -73,7 +73,7 @@
/compiler/src/iree/compiler/Dialect/Vulkan/ @antiagainst
/compiler/src/iree/compiler/GlobalOptimization/ @hanhanW
/compiler/src/iree/compiler/InputConversion/ @MaheshRavishankar @stellaraccident
-/compiler/src/iree/compiler/InputConversion/StableHLO/ @hanhanW @MaheshRavishankar @rsuderman
+/compiler/plugins/input/StableHLO/ @hanhanW @MaheshRavishankar @rsuderman
/compiler/plugins/input/TOSA/ @MaheshRavishankar @rsuderman
# Runtime
diff --git a/compiler/plugins/input/StableHLO/BUILD.bazel b/compiler/plugins/input/StableHLO/BUILD.bazel
new file mode 100644
index 0000000..522ca5d
--- /dev/null
+++ b/compiler/plugins/input/StableHLO/BUILD.bazel
@@ -0,0 +1,11 @@
+# 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
+
+package(
+ default_visibility = ["//visibility:public"],
+ features = ["layering_check"],
+ licenses = ["notice"], # Apache 2.0
+)
diff --git a/compiler/plugins/input/StableHLO/CMakeLists.txt b/compiler/plugins/input/StableHLO/CMakeLists.txt
new file mode 100644
index 0000000..e6efac5
--- /dev/null
+++ b/compiler/plugins/input/StableHLO/CMakeLists.txt
@@ -0,0 +1,22 @@
+# 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(IREE_PACKAGE_ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}")
+set(IREE_PACKAGE_ROOT_PREFIX "")
+set(IREE_COMPILER_TABLEGEN_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}")
+
+add_library(stablehlo-iree_compiler_defs INTERFACE)
+target_include_directories(stablehlo-iree_compiler_defs
+ INTERFACE
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}
+)
+
+# Configures all iree_cc_* targets to take this implicit dep,
+# which provides common includes and copts for the tree.
+set(IREE_IMPLICIT_DEFS_CC_DEPS stablehlo-iree_compiler_defs)
+
+add_subdirectory(stablehlo-iree)
diff --git a/compiler/plugins/input/StableHLO/stablehlo-iree/BUILD.bazel b/compiler/plugins/input/StableHLO/stablehlo-iree/BUILD.bazel
new file mode 100644
index 0000000..3d4e563
--- /dev/null
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/BUILD.bazel
@@ -0,0 +1,39 @@
+# 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
+
+load("//build_tools/bazel:build_defs.oss.bzl", "iree_compiler_cc_library", "iree_compiler_register_plugin")
+
+package(
+ default_visibility = ["//visibility:public"],
+ features = ["layering_check"],
+ licenses = ["notice"], # Apache 2.0
+)
+
+iree_compiler_register_plugin(
+ plugin_id = "input_stablehlo",
+ target = ":registration",
+)
+
+iree_compiler_cc_library(
+ name = "registration",
+ srcs = [
+ "PluginRegistration.cpp",
+ ],
+ copts = [
+ "-Icompiler/plugins/input/StableHLO",
+ "-I$(GENDIR)/compiler/plugins/input/StableHLO",
+ ],
+ deps = [
+ "//compiler/plugins/input/StableHLO/stablehlo-iree/Conversion",
+ "//compiler/src/iree/compiler/PluginAPI",
+ "@llvm-project//mlir:ConversionPasses",
+ "@llvm-project//mlir:IR",
+ "@llvm-project//mlir:Pass",
+ "@llvm-project//mlir:Transforms",
+ "@stablehlo//:chlo_ops",
+ "@stablehlo//:stablehlo_ops",
+ ],
+)
diff --git a/compiler/plugins/input/StableHLO/stablehlo-iree/CMakeLists.txt b/compiler/plugins/input/StableHLO/stablehlo-iree/CMakeLists.txt
new file mode 100644
index 0000000..a38dd6c
--- /dev/null
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/CMakeLists.txt
@@ -0,0 +1,22 @@
+iree_add_all_subdirs()
+
+iree_compiler_register_plugin(
+ PLUGIN_ID
+ input_stablehlo
+ TARGET
+ ::registration
+)
+
+iree_cc_library(
+ NAME
+ registration
+ SRCS
+ "PluginRegistration.cpp"
+ DEPS
+ MLIRIR
+ MLIRPass
+ MLIRTransforms
+ iree::compiler::PluginAPI
+ stablehlo-iree::Conversion::Conversion
+ PUBLIC
+)
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/BUILD.bazel b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/BUILD.bazel
similarity index 89%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/BUILD.bazel
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/BUILD.bazel
index 4a457e9..5da79e9 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/BUILD.bazel
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/BUILD.bazel
@@ -35,6 +35,10 @@
"Passes.h.inc",
"Rewriters.h",
],
+ copts = [
+ "-Icompiler/plugins/input/StableHLO",
+ "-I$(GENDIR)/compiler/plugins/input/StableHLO",
+ ],
deps = [
":PassesIncGen",
"@llvm-project//mlir:Pass",
@@ -81,13 +85,17 @@
"TypeConversion.h",
"VerifyCompilerInputLegality.cpp",
],
+ copts = [
+ "-Icompiler/plugins/input/StableHLO",
+ "-I$(GENDIR)/compiler/plugins/input/StableHLO",
+ ],
deps = [
":CHLODecompositionPatterns",
":PassHeaders",
+ "//compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing",
"//compiler/src/iree/compiler/Dialect/Flow/IR",
"//compiler/src/iree/compiler/Dialect/Util/IR",
"//compiler/src/iree/compiler/Dialect/Util/Transforms",
- "//compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing",
"//compiler/src/iree/compiler/Utils",
"//llvm-external-projects/iree-dialects:IREELinalgExtDialect",
"@llvm-project//llvm:Support",
@@ -122,24 +130,25 @@
)
iree_compiler_cc_library(
- name = "StableHLO",
+ name = "Conversion",
srcs = [
"Passes.cpp",
],
hdrs = [
"Passes.h",
],
- defines = [
- "IREE_HAVE_STABLEHLO_INPUT",
+ copts = [
+ "-Icompiler/plugins/input/StableHLO",
+ "-I$(GENDIR)/compiler/plugins/input/StableHLO",
],
deps = [
":PassHeaders",
":StableHLOLegalization",
+ "//compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing",
"//compiler/src/iree/compiler/Dialect/Flow/IR",
"//compiler/src/iree/compiler/Dialect/Util/IR",
"//compiler/src/iree/compiler/Dialect/Util/Transforms",
"//compiler/src/iree/compiler/InputConversion/Common",
- "//compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing",
"@llvm-project//llvm:Support",
"@llvm-project//mlir:LinalgTransforms",
"@llvm-project//mlir:MLProgramDialect",
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/CHLODecompositionPatterns.td b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/CHLODecompositionPatterns.td
similarity index 100%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/CHLODecompositionPatterns.td
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/CHLODecompositionPatterns.td
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/CMakeLists.txt b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/CMakeLists.txt
similarity index 71%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/CMakeLists.txt
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/CMakeLists.txt
index 4674e8a..f615ae2 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/CMakeLists.txt
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/CMakeLists.txt
@@ -1,17 +1,9 @@
+# TODO(scotttodd): generate this file
+# Need a mapping for stablehlo-iree::Conversion::Preprocessing
+
# Add this tablegen include to support CHLO rewrites with DRR.
list(APPEND IREE_COMPILER_TABLEGEN_INCLUDE_DIRS "${IREE_SOURCE_DIR}/third_party/stablehlo")
-### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_ABOVE_THIS_LINE ###
-################################################################################
-# Autogenerated by build_tools/bazel_to_cmake/bazel_to_cmake.py from #
-# compiler/src/iree/compiler/InputConversion/StableHLO/BUILD.bazel #
-# #
-# Use iree_cmake_extra_content from iree/build_defs.oss.bzl to add arbitrary #
-# CMake-only content. #
-# #
-# To disable autogeneration for this file entirely, delete this header. #
-################################################################################
-
iree_add_all_subdirs()
iree_tablegen_library(
@@ -26,6 +18,9 @@
iree_cc_library(
NAME
PassHeaders
+ COPTS
+ "-Icompiler/plugins/input/StableHLO"
+ "-I$(GENDIR)/compiler/plugins/input/StableHLO"
HDRS
"PassDetail.h"
"Passes.h"
@@ -50,6 +45,9 @@
iree_cc_library(
NAME
StableHLOLegalization
+ COPTS
+ "-Icompiler/plugins/input/StableHLO"
+ "-I$(GENDIR)/compiler/plugins/input/StableHLO"
SRCS
"ConvertCollectives.cpp"
"LegalizeCHLO.cpp"
@@ -104,14 +102,17 @@
iree::compiler::Dialect::Flow::IR
iree::compiler::Dialect::Util::IR
iree::compiler::Dialect::Util::Transforms
- iree::compiler::InputConversion::StableHLO::Preprocessing
iree::compiler::Utils
+ stablehlo-iree::Conversion::Preprocessing
PUBLIC
)
iree_cc_library(
NAME
- StableHLO
+ Conversion
+ COPTS
+ "-Icompiler/plugins/input/StableHLO"
+ "-I$(GENDIR)/compiler/plugins/input/StableHLO"
HDRS
"Passes.h"
SRCS
@@ -133,10 +134,6 @@
iree::compiler::Dialect::Util::IR
iree::compiler::Dialect::Util::Transforms
iree::compiler::InputConversion::Common
- iree::compiler::InputConversion::StableHLO::Preprocessing
- DEFINES
- "IREE_HAVE_STABLEHLO_INPUT"
+ stablehlo-iree::Conversion::Preprocessing
PUBLIC
)
-
-### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_BELOW_THIS_LINE ###
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/ConvertCollectives.cpp b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/ConvertCollectives.cpp
similarity index 99%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/ConvertCollectives.cpp
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/ConvertCollectives.cpp
index 7f15ead..a4ec6a8 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/ConvertCollectives.cpp
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/ConvertCollectives.cpp
@@ -10,12 +10,12 @@
#include "iree/compiler/Dialect/Flow/IR/FlowDialect.h"
#include "iree/compiler/Dialect/Flow/IR/FlowOps.h"
#include "iree/compiler/Dialect/Flow/IR/FlowTypes.h"
-#include "iree/compiler/InputConversion/StableHLO/Rewriters.h"
#include "iree/compiler/Utils/IndexSet.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/Tensor/IR/Tensor.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/Transforms/DialectConversion.h"
+#include "stablehlo-iree/Conversion/Rewriters.h"
#include "stablehlo/dialect/StablehloOps.h"
namespace mlir::iree_compiler::stablehlo {
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/LegalizeCHLO.cpp b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/LegalizeCHLO.cpp
similarity index 99%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/LegalizeCHLO.cpp
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/LegalizeCHLO.cpp
index f2985ce..b22f318 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/LegalizeCHLO.cpp
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/LegalizeCHLO.cpp
@@ -7,9 +7,6 @@
// Implements logic for lowering CHLO ops to StableHLO and Shape dialect ops,
// taking care of CHLO's broadcasting semantics
-#include "iree/compiler/InputConversion/StableHLO/Passes.h"
-#include "iree/compiler/InputConversion/StableHLO/Preprocessing/Rewriters.h"
-#include "iree/compiler/InputConversion/StableHLO/Rewriters.h"
#include "llvm/ADT/STLExtras.h"
#include "mlir/Dialect/Complex/IR/Complex.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
@@ -21,6 +18,9 @@
#include "mlir/IR/TypeUtilities.h"
#include "mlir/Support/LogicalResult.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
+#include "stablehlo-iree/Conversion/Passes.h"
+#include "stablehlo-iree/Conversion/Preprocessing/Rewriters.h"
+#include "stablehlo-iree/Conversion/Rewriters.h"
#include "stablehlo/dialect/BroadcastUtils.h"
#include "stablehlo/dialect/ChloOps.h"
#include "stablehlo/dialect/StablehloOps.h"
@@ -28,7 +28,7 @@
namespace mlir::iree_compiler::stablehlo {
#define GEN_PASS_DEF_LEGALIZECHLO
-#include "iree/compiler/InputConversion/StableHLO/Passes.h.inc"
+#include "stablehlo-iree/Conversion/Passes.h.inc"
namespace {
@@ -2225,7 +2225,7 @@
} // namespace
namespace {
-#include "iree/compiler/InputConversion/StableHLO/CHLODecompositionPatterns.h.inc"
+#include "stablehlo-iree/Conversion/CHLODecompositionPatterns.h.inc"
} // end anonymous namespace
namespace {
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/LegalizeControlFlow.cpp b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/LegalizeControlFlow.cpp
similarity index 97%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/LegalizeControlFlow.cpp
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/LegalizeControlFlow.cpp
index 6328f7c..5c5da14 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/LegalizeControlFlow.cpp
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/LegalizeControlFlow.cpp
@@ -6,20 +6,20 @@
// Implements logic for lowering StableHLO dialect ops to the SCF dialect.
-#include "iree/compiler/InputConversion/StableHLO/Passes.h"
-#include "iree/compiler/InputConversion/StableHLO/Rewriters.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/SCF/IR/SCF.h"
#include "mlir/Dialect/Tensor/IR/Tensor.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Value.h"
#include "mlir/Transforms/DialectConversion.h"
+#include "stablehlo-iree/Conversion/Passes.h"
+#include "stablehlo-iree/Conversion/Rewriters.h"
#include "stablehlo/dialect/StablehloOps.h"
namespace mlir::iree_compiler::stablehlo {
#define GEN_PASS_DEF_LEGALIZECONTROLFLOW
-#include "iree/compiler/InputConversion/StableHLO/Passes.h.inc"
+#include "stablehlo-iree/Conversion/Passes.h.inc"
namespace {
// All transformations in this file take stablehlo blocks which end with
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/LegalizeShapeComputations.cpp b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/LegalizeShapeComputations.cpp
similarity index 96%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/LegalizeShapeComputations.cpp
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/LegalizeShapeComputations.cpp
index 6902b22..bc82dfe 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/LegalizeShapeComputations.cpp
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/LegalizeShapeComputations.cpp
@@ -6,21 +6,21 @@
// Implements logic for lowering StableHLO dialect to scalar shape operations.
-#include "iree/compiler/InputConversion/StableHLO/MapStableHLOToScalarOp.h"
-#include "iree/compiler/InputConversion/StableHLO/Passes.h"
-#include "iree/compiler/InputConversion/StableHLO/Rewriters.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/Math/IR/Math.h"
#include "mlir/Dialect/Tensor/IR/Tensor.h"
#include "mlir/IR/TypeUtilities.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
+#include "stablehlo-iree/Conversion/MapStableHLOToScalarOp.h"
+#include "stablehlo-iree/Conversion/Passes.h"
+#include "stablehlo-iree/Conversion/Rewriters.h"
#include "stablehlo/dialect/StablehloOps.h"
namespace mlir::iree_compiler::stablehlo {
#define GEN_PASS_DEF_LEGALIZESHAPECOMPUTATIONS
-#include "iree/compiler/InputConversion/StableHLO/Passes.h.inc"
+#include "stablehlo-iree/Conversion/Passes.h.inc"
namespace {
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/LegalizeToLinalgUtils.cpp b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/LegalizeToLinalgUtils.cpp
similarity index 98%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/LegalizeToLinalgUtils.cpp
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/LegalizeToLinalgUtils.cpp
index df900a4..a19d702 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/LegalizeToLinalgUtils.cpp
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/LegalizeToLinalgUtils.cpp
@@ -6,7 +6,7 @@
// Implements utilities for lowering StableHLO dialect to Linalg dialect.
-#include "iree/compiler/InputConversion/StableHLO/LegalizeToLinalgUtils.h"
+#include "stablehlo-iree/Conversion/LegalizeToLinalgUtils.h"
#include <algorithm>
#include <numeric>
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/LegalizeToLinalgUtils.h b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/LegalizeToLinalgUtils.h
similarity index 92%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/LegalizeToLinalgUtils.h
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/LegalizeToLinalgUtils.h
index bf5ea2d..f311a0e 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/LegalizeToLinalgUtils.h
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/LegalizeToLinalgUtils.h
@@ -6,8 +6,8 @@
// Utils for lowering of the StableHLO dialect to the Linalg dialect.
-#ifndef IREE_COMPILER_INPUTCONVERSION_STABLEHLO_LEGALIZE_TO_LINALG_UTILS_H_
-#define IREE_COMPILER_INPUTCONVERSION_STABLEHLO_LEGALIZE_TO_LINALG_UTILS_H_
+#ifndef STABLEHLO_IREE_CONVERSION_LEGALIZE_TO_LINALG_UTILS_H_
+#define STABLEHLO_IREE_CONVERSION_LEGALIZE_TO_LINALG_UTILS_H_
#include <algorithm>
#include <numeric>
@@ -15,7 +15,6 @@
#include <string>
#include <utility>
-#include "iree/compiler/InputConversion/StableHLO/MapStableHLOToScalarOp.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringSet.h"
@@ -35,6 +34,7 @@
#include "mlir/Support/LLVM.h"
#include "mlir/Support/LogicalResult.h"
#include "mlir/Transforms/DialectConversion.h"
+#include "stablehlo-iree/Conversion/MapStableHLOToScalarOp.h"
#include "stablehlo/dialect/StablehloOps.h"
namespace mlir::iree_compiler::stablehlo {
@@ -110,4 +110,4 @@
} // namespace mlir::iree_compiler::stablehlo
-#endif // IREE_COMPILER_INPUTCONVERSION_STABLEHLO_LEGALIZE_TO_LINALG_UTILS_H_
+#endif // STABLEHLO_IREE_CONVERSION_LEGALIZE_TO_LINALG_UTILS_H_
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/MapStableHLOToScalarOp.h b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/MapStableHLOToScalarOp.h
similarity index 99%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/MapStableHLOToScalarOp.h
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/MapStableHLOToScalarOp.h
index 6bf1489..848f0ff 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/MapStableHLOToScalarOp.h
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/MapStableHLOToScalarOp.h
@@ -4,8 +4,8 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#ifndef IREE_COMPILER_INPUTCONVERSION_STABLEHLO_MAP_STABLEHLO_TO_SCALAR_OP_H
-#define IREE_COMPILER_INPUTCONVERSION_STABLEHLO_MAP_STABLEHLO_TO_SCALAR_OP_H
+#ifndef STABLEHLO_IREE_CONVERSION_MAP_STABLEHLO_TO_SCALAR_OP_H
+#define STABLEHLO_IREE_CONVERSION_MAP_STABLEHLO_TO_SCALAR_OP_H
#include <optional>
@@ -1306,4 +1306,4 @@
} // namespace stablehlo
} // namespace mlir
-#endif // IREE_COMPILER_INPUTCONVERSION_STABLEHLO_MAP_STABLEHLO_TO_SCALAR_OP_H
+#endif // STABLEHLO_IREE_CONVERSION_MAP_STABLEHLO_TO_SCALAR_OP_H
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/PassDetail.h b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/PassDetail.h
similarity index 63%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/PassDetail.h
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/PassDetail.h
index 6027d09..3a37d0d 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/PassDetail.h
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/PassDetail.h
@@ -4,8 +4,8 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#ifndef IREE_COMPILER_INPUTCONVERSION_STABLEHLO_PASSDETAIL_H_
-#define IREE_COMPILER_INPUTCONVERSION_STABLEHLO_PASSDETAIL_H_
+#ifndef STABLEHLO_IREE_CONVERSION_PASSDETAIL_H_
+#define STABLEHLO_IREE_CONVERSION_PASSDETAIL_H_
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/IR/BuiltinOps.h"
@@ -14,8 +14,8 @@
namespace mlir::iree_compiler::stablehlo {
#define GEN_PASS_DECL
-#include "iree/compiler/InputConversion/StableHLO/Passes.h.inc"
+#include "stablehlo-iree/Conversion/Passes.h.inc"
} // namespace mlir::iree_compiler::stablehlo
-#endif // IREE_COMPILER_INPUTCONVERSION_STABLEHLO_PASSDETAIL_H_
+#endif // STABLEHLO_IREE_CONVERSION_PASSDETAIL_H_
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/Passes.cpp b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Passes.cpp
similarity index 95%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/Passes.cpp
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Passes.cpp
index 048f845..d735622 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/Passes.cpp
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Passes.cpp
@@ -4,11 +4,10 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#include "iree/compiler/InputConversion/StableHLO/Passes.h"
+#include "stablehlo-iree/Conversion/Passes.h"
#include "iree/compiler/Dialect/Util/Transforms/Passes.h"
#include "iree/compiler/InputConversion/Common/Passes.h"
-#include "iree/compiler/InputConversion/StableHLO/Preprocessing/Passes.h"
#include "mlir/Conversion/ReconcileUnrealizedCasts/ReconcileUnrealizedCasts.h"
#include "mlir/Conversion/SCFToControlFlow/SCFToControlFlow.h"
#include "mlir/Conversion/ShapeToStandard/ShapeToStandard.h"
@@ -18,11 +17,12 @@
#include "mlir/Pass/PassOptions.h"
#include "mlir/Pass/PassRegistry.h"
#include "mlir/Transforms/Passes.h"
+#include "stablehlo-iree/Conversion/Preprocessing/Passes.h"
namespace mlir::iree_compiler::stablehlo {
namespace {
#define GEN_PASS_REGISTRATION
-#include "iree/compiler/InputConversion/StableHLO/Passes.h.inc" // IWYU pragma: export
+#include "stablehlo-iree/Conversion/Passes.h.inc" // IWYU pragma: export
} // namespace
namespace {
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/Passes.h b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Passes.h
similarity index 85%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/Passes.h
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Passes.h
index c8fe79f..5a37bcd 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/Passes.h
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Passes.h
@@ -4,11 +4,11 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#ifndef IREE_COMPILER_INPUTCONVERSION_STABLEHLO_PASSES_H_
-#define IREE_COMPILER_INPUTCONVERSION_STABLEHLO_PASSES_H_
+#ifndef STABLEHLO_IREE_CONVERSION_PASSES_H_
+#define STABLEHLO_IREE_CONVERSION_PASSES_H_
-#include "iree/compiler/InputConversion/StableHLO/PassDetail.h"
#include "mlir/Pass/Pass.h"
+#include "stablehlo-iree/Conversion/PassDetail.h"
namespace mlir {
class TypeConverter;
@@ -42,4 +42,5 @@
} // namespace iree_compiler::stablehlo
} // namespace mlir
-#endif // IREE_COMPILER_INPUTCONVERSION_STABLEHLO_PASSES_H_
+
+#endif // STABLEHLO_IREE_CONVERSION_PASSES_H_
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/Passes.td b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Passes.td
similarity index 92%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/Passes.td
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Passes.td
index 94c95c0..4f19875 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/Passes.td
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Passes.td
@@ -4,8 +4,8 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#ifndef IREE_COMPILER_INPUTCONVERSION_STABLEHLO_PASSES
-#define IREE_COMPILER_INPUTCONVERSION_STABLEHLO_PASSES
+#ifndef STABLEHLO_IREE_CONVERSION_PASSES
+#define STABLEHLO_IREE_CONVERSION_PASSES
include "mlir/Pass/PassBase.td"
@@ -62,4 +62,4 @@
"Verifies that only supported IR constructs are passed to the compiler";
}
-#endif // IREE_COMPILER_INPUTCONVERSION_STABLEHLO_PASSES
+#endif // STABLEHLO_IREE_CONVERSION_PASSES
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/BUILD.bazel b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/BUILD.bazel
similarity index 95%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/BUILD.bazel
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/BUILD.bazel
index 9e2f5ae..ce7c715 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/BUILD.bazel
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/BUILD.bazel
@@ -75,6 +75,10 @@
"Passes.h",
"Rewriters.h",
],
+ copts = [
+ "-Icompiler/plugins/input/StableHLO",
+ "-I$(GENDIR)/compiler/plugins/input/StableHLO",
+ ],
deps = [
":ComplexLoweringPatterns",
":PassHeaders",
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/CMakeLists.txt b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/CMakeLists.txt
similarity index 91%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/CMakeLists.txt
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/CMakeLists.txt
index 5ef3819..7b49c08 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/CMakeLists.txt
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/CMakeLists.txt
@@ -4,7 +4,7 @@
### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_ABOVE_THIS_LINE ###
################################################################################
# Autogenerated by build_tools/bazel_to_cmake/bazel_to_cmake.py from #
-# compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/BUILD.bazel#
+# compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/BUILD.bazel#
# #
# Use iree_cmake_extra_content from iree/build_defs.oss.bzl to add arbitrary #
# CMake-only content. #
@@ -49,6 +49,9 @@
iree_cc_library(
NAME
Preprocessing
+ COPTS
+ "-Icompiler/plugins/input/StableHLO"
+ "-I$(GENDIR)/compiler/plugins/input/StableHLO"
HDRS
"Passes.h"
"Rewriters.h"
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/Canonicalization.cpp b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/Canonicalization.cpp
similarity index 99%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/Canonicalization.cpp
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/Canonicalization.cpp
index 9adbf95..53e329b 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/Canonicalization.cpp
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/Canonicalization.cpp
@@ -10,8 +10,6 @@
#include <functional>
#include <numeric>
-#include "iree/compiler/InputConversion/StableHLO/Preprocessing/Passes.h"
-#include "iree/compiler/InputConversion/StableHLO/Preprocessing/Rewriters.h"
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/STLExtras.h"
@@ -27,12 +25,14 @@
#include "mlir/IR/PatternMatch.h"
#include "mlir/IR/TypeUtilities.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
+#include "stablehlo-iree/Conversion/Preprocessing/Passes.h"
+#include "stablehlo-iree/Conversion/Preprocessing/Rewriters.h"
#include "stablehlo/dialect/StablehloOps.h"
namespace mlir::iree_compiler::stablehlo {
#define GEN_PASS_DEF_STABLEHLOCANONICALIZE
-#include "iree/compiler/InputConversion/StableHLO/Preprocessing/Passes.h.inc"
+#include "stablehlo-iree/Conversion/Preprocessing/Passes.h.inc"
namespace {
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/ComplexLoweringPatterns.td b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/ComplexLoweringPatterns.td
similarity index 100%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/ComplexLoweringPatterns.td
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/ComplexLoweringPatterns.td
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/DotGeneralToDot.cpp b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/DotGeneralToDot.cpp
similarity index 98%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/DotGeneralToDot.cpp
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/DotGeneralToDot.cpp
index fca7077..ed28321 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/DotGeneralToDot.cpp
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/DotGeneralToDot.cpp
@@ -6,20 +6,20 @@
// Implements logic for lowering the StableHLO general dot op to the dot op.
-#include "iree/compiler/InputConversion/StableHLO/Preprocessing/Passes.h"
-#include "iree/compiler/InputConversion/StableHLO/Preprocessing/Rewriters.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/SparseTensor/IR/SparseTensor.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/ImplicitLocOpBuilder.h"
#include "mlir/IR/Value.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
+#include "stablehlo-iree/Conversion/Preprocessing/Passes.h"
+#include "stablehlo-iree/Conversion/Preprocessing/Rewriters.h"
#include "stablehlo/dialect/StablehloOps.h"
namespace mlir::iree_compiler::stablehlo {
#define GEN_PASS_DEF_DOTGENERALTODOT
-#include "iree/compiler/InputConversion/StableHLO/Preprocessing/Passes.h.inc"
+#include "stablehlo-iree/Conversion/Preprocessing/Passes.h.inc"
namespace {
Value transposeReshape(Value arg, Location loc,
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/EinsumToDotGeneral.cpp b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/EinsumToDotGeneral.cpp
similarity index 96%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/EinsumToDotGeneral.cpp
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/EinsumToDotGeneral.cpp
index e71e73f..e671fed 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/EinsumToDotGeneral.cpp
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/EinsumToDotGeneral.cpp
@@ -6,16 +6,16 @@
// Implements logic for lowering StableHLO einsum op to dot_general ops.
-#include "iree/compiler/InputConversion/StableHLO/Preprocessing/Passes.h"
-#include "iree/compiler/InputConversion/StableHLO/Preprocessing/Rewriters.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
+#include "stablehlo-iree/Conversion/Preprocessing/Passes.h"
+#include "stablehlo-iree/Conversion/Preprocessing/Rewriters.h"
#include "stablehlo/dialect/StablehloOps.h"
namespace mlir::iree_compiler::stablehlo {
#define GEN_PASS_DEF_EINSUMTODOTGENERAL
-#include "iree/compiler/InputConversion/StableHLO/Preprocessing/Passes.h.inc"
+#include "stablehlo-iree/Conversion/Preprocessing/Passes.h.inc"
namespace {
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/FlattenTuplesInCFG.cpp b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/FlattenTuplesInCFG.cpp
similarity index 97%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/FlattenTuplesInCFG.cpp
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/FlattenTuplesInCFG.cpp
index 419d967..86b3caf 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/FlattenTuplesInCFG.cpp
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/FlattenTuplesInCFG.cpp
@@ -6,8 +6,6 @@
// Implements IREE-specific preprocessing for XLA inputs.
-#include "iree/compiler/InputConversion/StableHLO/Preprocessing/Passes.h"
-#include "iree/compiler/InputConversion/StableHLO/Preprocessing/Rewriters.h"
#include "llvm/ADT/TypeSwitch.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/ControlFlow/IR/ControlFlowOps.h"
@@ -20,12 +18,14 @@
#include "mlir/IR/PatternMatch.h"
#include "mlir/Support/LogicalResult.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
+#include "stablehlo-iree/Conversion/Preprocessing/Passes.h"
+#include "stablehlo-iree/Conversion/Preprocessing/Rewriters.h"
#include "stablehlo/dialect/StablehloOps.h"
namespace mlir::iree_compiler::stablehlo {
#define GEN_PASS_DEF_FLATTENTUPLESINCFG
-#include "iree/compiler/InputConversion/StableHLO/Preprocessing/Passes.h.inc"
+#include "stablehlo-iree/Conversion/Preprocessing/Passes.h.inc"
namespace {
// Given a set of types, unpack to a list of a types, removing all tuples.
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/FlattenTuplesInSCF.cpp b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/FlattenTuplesInSCF.cpp
similarity index 97%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/FlattenTuplesInSCF.cpp
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/FlattenTuplesInSCF.cpp
index a0432e0..a48761e 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/FlattenTuplesInSCF.cpp
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/FlattenTuplesInSCF.cpp
@@ -6,8 +6,6 @@
// Implements IREE-specific preprocessing for XLA inputs.
-#include "iree/compiler/InputConversion/StableHLO/Preprocessing/Passes.h"
-#include "iree/compiler/InputConversion/StableHLO/Preprocessing/Rewriters.h"
#include "llvm/ADT/TypeSwitch.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/ControlFlow/IR/ControlFlowOps.h"
@@ -21,12 +19,14 @@
#include "mlir/IR/Operation.h"
#include "mlir/Support/LogicalResult.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
+#include "stablehlo-iree/Conversion/Preprocessing/Passes.h"
+#include "stablehlo-iree/Conversion/Preprocessing/Rewriters.h"
#include "stablehlo/dialect/StablehloOps.h"
namespace mlir::iree_compiler::stablehlo {
#define GEN_PASS_DEF_FLATTENTUPLESINSCF
-#include "iree/compiler/InputConversion/StableHLO/Preprocessing/Passes.h.inc"
+#include "stablehlo-iree/Conversion/Preprocessing/Passes.h.inc"
namespace {
// Given a set of types, unpack to a list of a types, removing all tuples.
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/GatherToTorchIndexSelect.cpp b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/GatherToTorchIndexSelect.cpp
similarity index 95%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/GatherToTorchIndexSelect.cpp
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/GatherToTorchIndexSelect.cpp
index 528f6dc..155efc9 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/GatherToTorchIndexSelect.cpp
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/GatherToTorchIndexSelect.cpp
@@ -6,17 +6,17 @@
// Implements logic for lowering StableHLO gather to torch_index_select.
-#include "iree/compiler/InputConversion/StableHLO/Preprocessing/Passes.h"
-#include "iree/compiler/InputConversion/StableHLO/Preprocessing/Rewriters.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/IR/MLIRContext.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
+#include "stablehlo-iree/Conversion/Preprocessing/Passes.h"
+#include "stablehlo-iree/Conversion/Preprocessing/Rewriters.h"
#include "stablehlo/dialect/StablehloOps.h"
namespace mlir::iree_compiler::stablehlo {
#define GEN_PASS_DEF_GATHERTOTORCHINDEXSELECT
-#include "iree/compiler/InputConversion/StableHLO/Preprocessing/Passes.h.inc"
+#include "stablehlo-iree/Conversion/Preprocessing/Passes.h.inc"
namespace {
struct GatherIsTorchIndexSelectPattern final
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/LowerComplex.cpp b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/LowerComplex.cpp
similarity index 93%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/LowerComplex.cpp
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/LowerComplex.cpp
index c4d6ddf..0476621 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/LowerComplex.cpp
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/LowerComplex.cpp
@@ -8,16 +8,16 @@
// operations. This does not include removing complex values from function
// argument or return types.
-#include "iree/compiler/InputConversion/StableHLO/Preprocessing/Passes.h"
-#include "iree/compiler/InputConversion/StableHLO/Preprocessing/Rewriters.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
+#include "stablehlo-iree/Conversion/Preprocessing/Passes.h"
+#include "stablehlo-iree/Conversion/Preprocessing/Rewriters.h"
#include "stablehlo/dialect/StablehloOps.h"
namespace mlir::iree_compiler::stablehlo {
#define GEN_PASS_DEF_LOWERCOMPLEX
-#include "iree/compiler/InputConversion/StableHLO/Preprocessing/Passes.h.inc"
+#include "stablehlo-iree/Conversion/Preprocessing/Passes.h.inc"
namespace {
@@ -114,7 +114,7 @@
} // end anonymous namespace
namespace {
-#include "iree/compiler/InputConversion/StableHLO/Preprocessing/ComplexLoweringPatterns.h.inc"
+#include "stablehlo-iree/Conversion/Preprocessing/ComplexLoweringPatterns.h.inc"
} // end anonymous namespace
void populatePreprocessingComplexPatterns(MLIRContext *context,
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/Passes.cpp b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/Passes.cpp
similarity index 72%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/Passes.cpp
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/Passes.cpp
index 2633e60..b438691 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/Passes.cpp
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/Passes.cpp
@@ -4,12 +4,12 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#include "iree/compiler/InputConversion/StableHLO/Preprocessing/Passes.h"
+#include "stablehlo-iree/Conversion/Preprocessing/Passes.h"
namespace mlir::iree_compiler::stablehlo {
namespace {
#define GEN_PASS_REGISTRATION
-#include "iree/compiler/InputConversion/StableHLO/Preprocessing/Passes.h.inc" // IWYU pragma: export
+#include "stablehlo-iree/Conversion/Preprocessing/Passes.h.inc" // IWYU pragma: export
} // namespace
void registerStableHLOPreprocessingPasses() {
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/Passes.h b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/Passes.h
similarity index 69%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/Passes.h
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/Passes.h
index b5e6a2c..b4b836b 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/Passes.h
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/Passes.h
@@ -4,8 +4,8 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#ifndef IREE_COMPILER_INPUTCONVERSION_STABLEHLO_PREPROCESSING_PASSES_H_
-#define IREE_COMPILER_INPUTCONVERSION_STABLEHLO_PREPROCESSING_PASSES_H_
+#ifndef STABLEHLO_IREE_CONVERSION_PREPROCESSING_PASSES_H_
+#define STABLEHLO_IREE_CONVERSION_PREPROCESSING_PASSES_H_
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/IR/BuiltinOps.h"
@@ -14,7 +14,7 @@
namespace mlir::iree_compiler::stablehlo {
#define GEN_PASS_DECL
-#include "iree/compiler/InputConversion/StableHLO/Preprocessing/Passes.h.inc"
+#include "stablehlo-iree/Conversion/Preprocessing/Passes.h.inc"
//===----------------------------------------------------------------------===//
// Register all Passes
@@ -24,4 +24,4 @@
} // namespace mlir::iree_compiler::stablehlo
-#endif // IREE_COMPILER_INPUTCONVERSION_STABLEHLO_PREPROCESSING_PASSES_H_
+#endif // STABLEHLO_IREE_CONVERSION_PREPROCESSING_PASSES_H_
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/Passes.td b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/Passes.td
similarity index 90%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/Passes.td
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/Passes.td
index 1b4a020..e93fa2a 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/Passes.td
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/Passes.td
@@ -4,8 +4,8 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#ifndef IREE_COMPILER_INPUTCONVERSION_STABLEHLO_PREPROCESSING_PASSES
-#define IREE_COMPILER_INPUTCONVERSION_STABLEHLO_PREPROCESSING_PASSES
+#ifndef STABLEHLO_IREE_CONVERSION_PREPROCESSING_PASSES
+#define STABLEHLO_IREE_CONVERSION_PREPROCESSING_PASSES
include "mlir/Pass/PassBase.td"
@@ -58,4 +58,4 @@
let summary = "Materializes 'broadcast_dimensions' attributes";
}
-#endif // IREE_COMPILER_INPUTCONVERSION_STABLEHLO_PREPROCESSING_PASSES
+#endif // STABLEHLO_IREE_CONVERSION_PREPROCESSING_PASSES
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/Rewriters.h b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/Rewriters.h
similarity index 89%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/Rewriters.h
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/Rewriters.h
index c2bf829..bd5347d 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/Rewriters.h
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/Rewriters.h
@@ -4,8 +4,8 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#ifndef IREE_COMPILER_INPUTCONVERSION_STABLEHLO_PREPROCESSING_REWRITERS_H_
-#define IREE_COMPILER_INPUTCONVERSION_STABLEHLO_PREPROCESSING_REWRITERS_H_
+#ifndef STABLEHLO_IREE_CONVERSION_PREPROCESSING_REWRITERS_H_
+#define STABLEHLO_IREE_CONVERSION_PREPROCESSING_REWRITERS_H_
#include "mlir/IR/PatternMatch.h"
#include "mlir/Transforms/DialectConversion.h"
@@ -46,4 +46,4 @@
} // namespace mlir::iree_compiler::stablehlo
-#endif // IREE_COMPILER_INPUTCONVERSION_STABLEHLO_PREPROCESSING_REWRITERS_H_
+#endif // STABLEHLO_IREE_CONVERSION_PREPROCESSING_REWRITERS_H_
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/StableHLOToStableHLO.cpp b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/StableHLOToStableHLO.cpp
similarity index 99%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/StableHLOToStableHLO.cpp
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/StableHLOToStableHLO.cpp
index 7fcfb04..601ee88 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/StableHLOToStableHLO.cpp
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/StableHLOToStableHLO.cpp
@@ -9,8 +9,6 @@
#include <numeric>
#include <random>
-#include "iree/compiler/InputConversion/StableHLO/Preprocessing/Passes.h"
-#include "iree/compiler/InputConversion/StableHLO/Preprocessing/Rewriters.h"
#include "llvm/ADT/STLExtras.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
@@ -21,13 +19,15 @@
#include "mlir/IR/PatternMatch.h"
#include "mlir/IR/TypeUtilities.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
+#include "stablehlo-iree/Conversion/Preprocessing/Passes.h"
+#include "stablehlo-iree/Conversion/Preprocessing/Rewriters.h"
#include "stablehlo/dialect/ChloOps.h"
#include "stablehlo/dialect/StablehloOps.h"
namespace mlir::iree_compiler::stablehlo {
#define GEN_PASS_DEF_STABLEHLOTOSTABLEHLOPREPROCESSING
-#include "iree/compiler/InputConversion/StableHLO/Preprocessing/Passes.h.inc"
+#include "stablehlo-iree/Conversion/Preprocessing/Passes.h.inc"
namespace {
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/UnfuseBatchNorm.cpp b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/UnfuseBatchNorm.cpp
similarity index 98%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/UnfuseBatchNorm.cpp
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/UnfuseBatchNorm.cpp
index dc9ceee..df53dfa 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/UnfuseBatchNorm.cpp
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/UnfuseBatchNorm.cpp
@@ -4,8 +4,6 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#include "iree/compiler/InputConversion/StableHLO/Preprocessing/Passes.h"
-#include "iree/compiler/InputConversion/StableHLO/Preprocessing/Rewriters.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/Shape/IR/Shape.h"
@@ -13,12 +11,14 @@
#include "mlir/IR/ImplicitLocOpBuilder.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
+#include "stablehlo-iree/Conversion/Preprocessing/Passes.h"
+#include "stablehlo-iree/Conversion/Preprocessing/Rewriters.h"
#include "stablehlo/dialect/StablehloOps.h"
namespace mlir::iree_compiler::stablehlo {
#define GEN_PASS_DEF_UNFUSEBATCHNORM
-#include "iree/compiler/InputConversion/StableHLO/Preprocessing/Passes.h.inc"
+#include "stablehlo-iree/Conversion/Preprocessing/Passes.h.inc"
namespace {
// Broadcasts the 1D value tensor 'value_1d' to the shape of 'result_type'. If
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/test/BUILD.bazel b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/test/BUILD.bazel
similarity index 96%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/test/BUILD.bazel
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/test/BUILD.bazel
index b8fe70c..2d8fbda 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/test/BUILD.bazel
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/test/BUILD.bazel
@@ -4,8 +4,6 @@
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-# Tests for common transforms.
-
load("//build_tools/bazel:iree_lit_test.bzl", "iree_lit_test_suite")
load("//build_tools/bazel:enforce_glob.bzl", "enforce_glob")
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/test/CMakeLists.txt b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/test/CMakeLists.txt
similarity index 92%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/test/CMakeLists.txt
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/test/CMakeLists.txt
index da9a641..92e4c89 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/test/CMakeLists.txt
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/test/CMakeLists.txt
@@ -1,6 +1,6 @@
################################################################################
# Autogenerated by build_tools/bazel_to_cmake/bazel_to_cmake.py from #
-# compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/test/BUILD.bazel#
+# compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/test/BUILD.bazel#
# #
# Use iree_cmake_extra_content from iree/build_defs.oss.bzl to add arbitrary #
# CMake-only content. #
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/test/canonicalization.mlir b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/test/canonicalization.mlir
similarity index 100%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/test/canonicalization.mlir
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/test/canonicalization.mlir
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/test/canonicalize_dot_general.mlir b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/test/canonicalize_dot_general.mlir
similarity index 100%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/test/canonicalize_dot_general.mlir
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/test/canonicalize_dot_general.mlir
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/test/complex_lowering.mlir b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/test/complex_lowering.mlir
similarity index 100%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/test/complex_lowering.mlir
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/test/complex_lowering.mlir
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/test/dot_general_to_dot.mlir b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/test/dot_general_to_dot.mlir
similarity index 100%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/test/dot_general_to_dot.mlir
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/test/dot_general_to_dot.mlir
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/test/einsum_to_dot_general.mlir b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/test/einsum_to_dot_general.mlir
similarity index 100%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/test/einsum_to_dot_general.mlir
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/test/einsum_to_dot_general.mlir
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/test/flatten_tuples_in_cfg.mlir b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/test/flatten_tuples_in_cfg.mlir
similarity index 100%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/test/flatten_tuples_in_cfg.mlir
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/test/flatten_tuples_in_cfg.mlir
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/test/flatten_tuples_in_scf.mlir b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/test/flatten_tuples_in_scf.mlir
similarity index 100%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/test/flatten_tuples_in_scf.mlir
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/test/flatten_tuples_in_scf.mlir
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/test/gather_to_torch_index_select.mlir b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/test/gather_to_torch_index_select.mlir
similarity index 100%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/test/gather_to_torch_index_select.mlir
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/test/gather_to_torch_index_select.mlir
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/test/stablehlo_to_stablehlo.mlir b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/test/stablehlo_to_stablehlo.mlir
similarity index 100%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/test/stablehlo_to_stablehlo.mlir
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/test/stablehlo_to_stablehlo.mlir
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/test/unfuse_batch_norm.mlir b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/test/unfuse_batch_norm.mlir
similarity index 100%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/Preprocessing/test/unfuse_batch_norm.mlir
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Preprocessing/test/unfuse_batch_norm.mlir
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/Rewriters.h b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Rewriters.h
similarity index 95%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/Rewriters.h
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Rewriters.h
index 13b01fb..69d025d 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/Rewriters.h
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/Rewriters.h
@@ -4,8 +4,8 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#ifndef IREE_COMPILER_INPUTCONVERSION_STABLEHLO_REWRITERS_H_
-#define IREE_COMPILER_INPUTCONVERSION_STABLEHLO_REWRITERS_H_
+#ifndef STABLEHLO_IREE_CONVERSION_REWRITERS_H_
+#define STABLEHLO_IREE_CONVERSION_REWRITERS_H_
#include "mlir/Transforms/DialectConversion.h"
@@ -99,4 +99,4 @@
} // namespace mlir::iree_compiler::stablehlo
-#endif // IREE_COMPILER_INPUTCONVERSION_STABLEHLO_REWRITERS_H_
+#endif // STABLEHLO_IREE_CONVERSION_REWRITERS_H_
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/StableHLOToArith.cpp b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/StableHLOToArith.cpp
similarity index 96%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/StableHLOToArith.cpp
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/StableHLOToArith.cpp
index d57e9f7..6fac082 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/StableHLOToArith.cpp
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/StableHLOToArith.cpp
@@ -6,13 +6,13 @@
// Implements logic for lowering scalar StableHLO ops to arith dialect.
-#include "iree/compiler/InputConversion/StableHLO/LegalizeToLinalgUtils.h"
-#include "iree/compiler/InputConversion/StableHLO/Rewriters.h"
-#include "iree/compiler/InputConversion/StableHLO/TypeConversion.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/Tensor/IR/Tensor.h"
#include "mlir/Transforms/DialectConversion.h"
+#include "stablehlo-iree/Conversion/LegalizeToLinalgUtils.h"
+#include "stablehlo-iree/Conversion/Rewriters.h"
+#include "stablehlo-iree/Conversion/TypeConversion.h"
#include "stablehlo/dialect/StablehloOps.h"
namespace mlir::iree_compiler::stablehlo {
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/StableHLOToIREEInputDialects.cpp b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/StableHLOToIREEInputDialects.cpp
similarity index 97%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/StableHLOToIREEInputDialects.cpp
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/StableHLOToIREEInputDialects.cpp
index de24f09..a6d8cfa 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/StableHLOToIREEInputDialects.cpp
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/StableHLOToIREEInputDialects.cpp
@@ -11,12 +11,6 @@
#include "iree/compiler/Dialect/Flow/IR/FlowOps.h"
#include "iree/compiler/Dialect/Util/IR/UtilDialect.h"
#include "iree/compiler/Dialect/Util/IR/UtilOps.h"
-#include "iree/compiler/InputConversion/StableHLO/LegalizeToLinalgUtils.h"
-#include "iree/compiler/InputConversion/StableHLO/PassDetail.h"
-#include "iree/compiler/InputConversion/StableHLO/Passes.h"
-#include "iree/compiler/InputConversion/StableHLO/Preprocessing/Rewriters.h"
-#include "iree/compiler/InputConversion/StableHLO/Rewriters.h"
-#include "iree/compiler/InputConversion/StableHLO/TypeConversion.h"
#include "iree/compiler/Utils/ConversionUtils.h"
#include "llvm/ADT/SmallVector.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
@@ -34,13 +28,19 @@
#include "mlir/IR/TypeUtilities.h"
#include "mlir/Transforms/DialectConversion.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
+#include "stablehlo-iree/Conversion/LegalizeToLinalgUtils.h"
+#include "stablehlo-iree/Conversion/PassDetail.h"
+#include "stablehlo-iree/Conversion/Passes.h"
+#include "stablehlo-iree/Conversion/Preprocessing/Rewriters.h"
+#include "stablehlo-iree/Conversion/Rewriters.h"
+#include "stablehlo-iree/Conversion/TypeConversion.h"
#include "stablehlo/dialect/ChloOps.h"
#include "stablehlo/dialect/StablehloOps.h"
namespace mlir::iree_compiler::stablehlo {
#define GEN_PASS_DEF_CONVERTSTABLEHLOTOIREEINPUTDIALECTS
-#include "iree/compiler/InputConversion/StableHLO/Passes.h.inc"
+#include "stablehlo-iree/Conversion/Passes.h.inc"
namespace {
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/StableHLOToLinalg.cpp b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/StableHLOToLinalg.cpp
similarity index 99%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/StableHLOToLinalg.cpp
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/StableHLOToLinalg.cpp
index c36ee73..a6b128b 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/StableHLOToLinalg.cpp
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/StableHLOToLinalg.cpp
@@ -10,10 +10,6 @@
#include <cstdint>
#include <string>
-#include "iree/compiler/InputConversion/StableHLO/LegalizeToLinalgUtils.h"
-#include "iree/compiler/InputConversion/StableHLO/Passes.h"
-#include "iree/compiler/InputConversion/StableHLO/Rewriters.h"
-#include "iree/compiler/InputConversion/StableHLO/TypeConversion.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
@@ -45,12 +41,16 @@
#include "mlir/Support/LLVM.h"
#include "mlir/Support/LogicalResult.h"
#include "mlir/Transforms/DialectConversion.h"
+#include "stablehlo-iree/Conversion/LegalizeToLinalgUtils.h"
+#include "stablehlo-iree/Conversion/Passes.h"
+#include "stablehlo-iree/Conversion/Rewriters.h"
+#include "stablehlo-iree/Conversion/TypeConversion.h"
#include "stablehlo/dialect/StablehloOps.h"
namespace mlir::iree_compiler::stablehlo {
#define GEN_PASS_DEF_CONVERTSTABLEHLOTOLINALG
-#include "iree/compiler/InputConversion/StableHLO/Passes.h.inc"
+#include "stablehlo-iree/Conversion/Passes.h.inc"
namespace {
Value getResultValue(Operation *op) { return op->getResult(0); }
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/StableHLOToLinalgConvolution.cpp b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/StableHLOToLinalgConvolution.cpp
similarity index 99%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/StableHLOToLinalgConvolution.cpp
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/StableHLOToLinalgConvolution.cpp
index e7473cb..971115b 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/StableHLOToLinalgConvolution.cpp
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/StableHLOToLinalgConvolution.cpp
@@ -6,12 +6,12 @@
// Implements logic for lowering StableHLO convolution ops to Linalg dialect.
-#include "iree/compiler/InputConversion/StableHLO/LegalizeToLinalgUtils.h"
-#include "iree/compiler/InputConversion/StableHLO/Rewriters.h"
#include "mlir/Dialect/Linalg/IR/Linalg.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/Support/LogicalResult.h"
#include "mlir/Transforms/DialectConversion.h"
+#include "stablehlo-iree/Conversion/LegalizeToLinalgUtils.h"
+#include "stablehlo-iree/Conversion/Rewriters.h"
#include "stablehlo/dialect/StablehloOps.h"
namespace mlir::iree_compiler::stablehlo {
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/StableHLOToLinalgDotProd.cpp b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/StableHLOToLinalgDotProd.cpp
similarity index 98%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/StableHLOToLinalgDotProd.cpp
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/StableHLOToLinalgDotProd.cpp
index 3c6f060..9d22b7b 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/StableHLOToLinalgDotProd.cpp
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/StableHLOToLinalgDotProd.cpp
@@ -8,12 +8,12 @@
// These patterns are separated out to their own file to save on the compilation
// times, given that we instantiate a large number of class templates here.
-#include "iree/compiler/InputConversion/StableHLO/LegalizeToLinalgUtils.h"
-#include "iree/compiler/InputConversion/StableHLO/Rewriters.h"
#include "mlir/Dialect/Linalg/IR/Linalg.h"
#include "mlir/Dialect/SparseTensor/IR/SparseTensor.h"
#include "mlir/Support/LogicalResult.h"
#include "mlir/Transforms/DialectConversion.h"
+#include "stablehlo-iree/Conversion/LegalizeToLinalgUtils.h"
+#include "stablehlo-iree/Conversion/Rewriters.h"
#include "stablehlo/dialect/StablehloOps.h"
namespace mlir::iree_compiler::stablehlo {
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/StableHLOToLinalgExt.cpp b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/StableHLOToLinalgExt.cpp
similarity index 98%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/StableHLOToLinalgExt.cpp
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/StableHLOToLinalgExt.cpp
index 9b18631..2ab7ce5 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/StableHLOToLinalgExt.cpp
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/StableHLOToLinalgExt.cpp
@@ -16,11 +16,6 @@
#include "iree/compiler/Dialect/Flow/IR/FlowDialect.h"
#include "iree/compiler/Dialect/Flow/IR/FlowOps.h"
#include "iree/compiler/Dialect/Util/IR/UtilOps.h"
-#include "iree/compiler/InputConversion/StableHLO/LegalizeToLinalgUtils.h"
-#include "iree/compiler/InputConversion/StableHLO/MapStableHLOToScalarOp.h"
-#include "iree/compiler/InputConversion/StableHLO/PassDetail.h"
-#include "iree/compiler/InputConversion/StableHLO/Passes.h"
-#include "iree/compiler/InputConversion/StableHLO/Rewriters.h"
#include "mlir/Dialect/ControlFlow/IR/ControlFlow.h"
#include "mlir/Dialect/Linalg/IR/Linalg.h"
#include "mlir/Dialect/Tensor/IR/Tensor.h"
@@ -32,13 +27,18 @@
#include "mlir/IR/Matchers.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/Transforms/DialectConversion.h"
+#include "stablehlo-iree/Conversion/LegalizeToLinalgUtils.h"
+#include "stablehlo-iree/Conversion/MapStableHLOToScalarOp.h"
+#include "stablehlo-iree/Conversion/PassDetail.h"
+#include "stablehlo-iree/Conversion/Passes.h"
+#include "stablehlo-iree/Conversion/Rewriters.h"
#include "stablehlo/dialect/ChloOps.h"
#include "stablehlo/dialect/StablehloOps.h"
namespace mlir::iree_compiler::stablehlo {
#define GEN_PASS_DEF_CONVERTSTABLEHLOTOLINALGEXT
-#include "iree/compiler/InputConversion/StableHLO/Passes.h.inc"
+#include "stablehlo-iree/Conversion/Passes.h.inc"
namespace {
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/StableHLOToLinalgPointwise.cpp b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/StableHLOToLinalgPointwise.cpp
similarity index 97%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/StableHLOToLinalgPointwise.cpp
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/StableHLOToLinalgPointwise.cpp
index ef6e897..53ea368 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/StableHLOToLinalgPointwise.cpp
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/StableHLOToLinalgPointwise.cpp
@@ -8,13 +8,13 @@
// These patterns are separated out to their own file to save on the compilation
// times, given that we instantiate a large number of class templates here.
-#include "iree/compiler/InputConversion/StableHLO/LegalizeToLinalgUtils.h"
-#include "iree/compiler/InputConversion/StableHLO/MapStableHLOToScalarOp.h"
-#include "iree/compiler/InputConversion/StableHLO/Rewriters.h"
-#include "iree/compiler/InputConversion/StableHLO/TypeConversion.h"
#include "mlir/IR/ValueRange.h"
#include "mlir/Support/LogicalResult.h"
#include "mlir/Transforms/DialectConversion.h"
+#include "stablehlo-iree/Conversion/LegalizeToLinalgUtils.h"
+#include "stablehlo-iree/Conversion/MapStableHLOToScalarOp.h"
+#include "stablehlo-iree/Conversion/Rewriters.h"
+#include "stablehlo-iree/Conversion/TypeConversion.h"
#include "stablehlo/dialect/StablehloOps.h"
namespace mlir::iree_compiler::stablehlo {
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/StableHLOToLinalgRandom.cpp b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/StableHLOToLinalgRandom.cpp
similarity index 99%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/StableHLOToLinalgRandom.cpp
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/StableHLOToLinalgRandom.cpp
index 4860db8..592d6d5 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/StableHLOToLinalgRandom.cpp
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/StableHLOToLinalgRandom.cpp
@@ -7,12 +7,12 @@
// Implements logic for lowering StableHLO random number generation to Linalg
// dialect.
-#include "iree/compiler/InputConversion/StableHLO/LegalizeToLinalgUtils.h"
-#include "iree/compiler/InputConversion/StableHLO/Rewriters.h"
#include "mlir/Dialect/Linalg/IR/Linalg.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/Support/LogicalResult.h"
#include "mlir/Transforms/DialectConversion.h"
+#include "stablehlo-iree/Conversion/LegalizeToLinalgUtils.h"
+#include "stablehlo-iree/Conversion/Rewriters.h"
#include "stablehlo/dialect/StablehloOps.h"
namespace mlir::iree_compiler::stablehlo {
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/StableHLOToLinalgReduce.cpp b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/StableHLOToLinalgReduce.cpp
similarity index 99%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/StableHLOToLinalgReduce.cpp
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/StableHLOToLinalgReduce.cpp
index d4a2d71..c06cb46 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/StableHLOToLinalgReduce.cpp
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/StableHLOToLinalgReduce.cpp
@@ -8,12 +8,12 @@
// These patterns are separated out to their own file to save on the compilation
// times.
-#include "iree/compiler/InputConversion/StableHLO/LegalizeToLinalgUtils.h"
-#include "iree/compiler/InputConversion/StableHLO/Rewriters.h"
#include "llvm/ADT/STLExtras.h"
#include "mlir/Dialect/Linalg/IR/Linalg.h"
#include "mlir/Support/LogicalResult.h"
#include "mlir/Transforms/DialectConversion.h"
+#include "stablehlo-iree/Conversion/LegalizeToLinalgUtils.h"
+#include "stablehlo-iree/Conversion/Rewriters.h"
#include "stablehlo/dialect/StablehloOps.h"
namespace mlir::iree_compiler::stablehlo {
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/TypeConversion.cpp b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/TypeConversion.cpp
similarity index 97%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/TypeConversion.cpp
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/TypeConversion.cpp
index 6501fcd..b823ead 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/TypeConversion.cpp
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/TypeConversion.cpp
@@ -4,7 +4,7 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#include "iree/compiler/InputConversion/StableHLO/TypeConversion.h"
+#include "stablehlo-iree/Conversion/TypeConversion.h"
#include <optional>
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/TypeConversion.h b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/TypeConversion.h
similarity index 82%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/TypeConversion.h
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/TypeConversion.h
index 73e0f7c..bb94343 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/TypeConversion.h
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/TypeConversion.h
@@ -4,8 +4,8 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#ifndef IREE_COMPILER_INPUTCONVERSION_STABLEHLO_TYPE_CONVERSION_H
-#define IREE_COMPILER_INPUTCONVERSION_STABLEHLO_TYPE_CONVERSION_H
+#ifndef STABLEHLO_IREE_CONVERSION_TYPE_CONVERSION_H
+#define STABLEHLO_IREE_CONVERSION_TYPE_CONVERSION_H
#include "mlir/IR/Attributes.h"
#include "mlir/IR/Dialect.h"
@@ -31,4 +31,4 @@
} // namespace mlir::iree_compiler::stablehlo
-#endif // IREE_COMPILER_INPUTCONVERSION_STABLEHLO_TYPE_CONVERSION_H
+#endif // STABLEHLO_IREE_CONVERSION_TYPE_CONVERSION_H
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/VerifyCompilerInputLegality.cpp b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/VerifyCompilerInputLegality.cpp
similarity index 93%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/VerifyCompilerInputLegality.cpp
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/VerifyCompilerInputLegality.cpp
index 05f5902..7345e80 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/VerifyCompilerInputLegality.cpp
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/VerifyCompilerInputLegality.cpp
@@ -4,18 +4,18 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#include "iree/compiler/InputConversion/StableHLO/PassDetail.h"
-#include "iree/compiler/InputConversion/StableHLO/Passes.h"
#include "mlir/Dialect/Shape/IR/Shape.h"
#include "mlir/IR/MLIRContext.h"
#include "mlir/Transforms/DialectConversion.h"
+#include "stablehlo-iree/Conversion/PassDetail.h"
+#include "stablehlo-iree/Conversion/Passes.h"
#include "stablehlo/dialect/ChloOps.h"
#include "stablehlo/dialect/StablehloOps.h"
namespace mlir::iree_compiler::stablehlo {
#define GEN_PASS_DEF_VERIFYCOMPILERSTABLEHLOINPUTLEGALITY
-#include "iree/compiler/InputConversion/StableHLO/Passes.h.inc"
+#include "stablehlo-iree/Conversion/Passes.h.inc"
namespace {
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/test/BUILD.bazel b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/test/BUILD.bazel
similarity index 94%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/test/BUILD.bazel
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/test/BUILD.bazel
index 345673e..c0c0b41 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/test/BUILD.bazel
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/test/BUILD.bazel
@@ -4,8 +4,6 @@
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-# Tests for common transforms.
-
load("//build_tools/bazel:iree_lit_test.bzl", "iree_lit_test_suite")
load("//build_tools/bazel:enforce_glob.bzl", "enforce_glob")
@@ -18,6 +16,7 @@
name = "lit",
srcs = enforce_glob(
[
+ "auto_input_conversion.mlir",
"convert_collectives.mlir",
"legalize_chlo_decomposition.mlir",
"legalize_chlo_no_broadcast.mlir",
@@ -39,6 +38,7 @@
),
cfg = "//compiler:lit.cfg.py",
tools = [
+ "//tools:iree-compile",
"//tools:iree-opt",
"@llvm-project//llvm:FileCheck",
],
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/test/CMakeLists.txt b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/test/CMakeLists.txt
similarity index 91%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/test/CMakeLists.txt
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/test/CMakeLists.txt
index 4e4311a..7400707 100644
--- a/compiler/src/iree/compiler/InputConversion/StableHLO/test/CMakeLists.txt
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/test/CMakeLists.txt
@@ -1,6 +1,6 @@
################################################################################
# Autogenerated by build_tools/bazel_to_cmake/bazel_to_cmake.py from #
-# compiler/src/iree/compiler/InputConversion/StableHLO/test/BUILD.bazel #
+# compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/test/BUILD.bazel #
# #
# Use iree_cmake_extra_content from iree/build_defs.oss.bzl to add arbitrary #
# CMake-only content. #
@@ -14,6 +14,7 @@
NAME
lit
SRCS
+ "auto_input_conversion.mlir"
"convert_collectives.mlir"
"legalize_chlo_decomposition.mlir"
"legalize_chlo_no_broadcast.mlir"
@@ -32,6 +33,7 @@
"verify_compiler_input_legality.mlir"
TOOLS
FileCheck
+ iree-compile
iree-opt
)
diff --git a/compiler/src/iree/compiler/InputConversion/Common/test/auto_input_conversion_pipeline.mlir b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/test/auto_input_conversion.mlir
similarity index 62%
rename from compiler/src/iree/compiler/InputConversion/Common/test/auto_input_conversion_pipeline.mlir
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/test/auto_input_conversion.mlir
index b2ff749..6776bcb 100644
--- a/compiler/src/iree/compiler/InputConversion/Common/test/auto_input_conversion_pipeline.mlir
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/test/auto_input_conversion.mlir
@@ -1,6 +1,6 @@
-// RUN: iree-opt --iree-auto-input-conversion --split-input-file %s | FileCheck %s
+// RUN: iree-compile --compile-to=input --split-input-file %s | FileCheck %s
-// Check that the input conversion pipeline handles a simple input and does not crash.
+// Check that the auto input conversion pipeline uses this plugin.
// CHECK-LABEL: func.func @simple_add_stablehlo
// CHECK: arith.addi
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/test/convert_collectives.mlir b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/test/convert_collectives.mlir
similarity index 100%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/test/convert_collectives.mlir
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/test/convert_collectives.mlir
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/test/legalize_chlo_decomposition.mlir b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/test/legalize_chlo_decomposition.mlir
similarity index 100%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/test/legalize_chlo_decomposition.mlir
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/test/legalize_chlo_decomposition.mlir
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/test/legalize_chlo_no_broadcast.mlir b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/test/legalize_chlo_no_broadcast.mlir
similarity index 100%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/test/legalize_chlo_no_broadcast.mlir
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/test/legalize_chlo_no_broadcast.mlir
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/test/legalize_chlo_with_broadcast.mlir b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/test/legalize_chlo_with_broadcast.mlir
similarity index 100%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/test/legalize_chlo_with_broadcast.mlir
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/test/legalize_chlo_with_broadcast.mlir
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/test/legalize_control_flow.mlir b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/test/legalize_control_flow.mlir
similarity index 100%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/test/legalize_control_flow.mlir
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/test/legalize_control_flow.mlir
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/test/legalize_shape_computations.mlir b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/test/legalize_shape_computations.mlir
similarity index 100%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/test/legalize_shape_computations.mlir
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/test/legalize_shape_computations.mlir
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/test/stablehlo_to_iree_input_dialects.mlir b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/test/stablehlo_to_iree_input_dialects.mlir
similarity index 100%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/test/stablehlo_to_iree_input_dialects.mlir
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/test/stablehlo_to_iree_input_dialects.mlir
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/test/stablehlo_to_linalg.mlir b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/test/stablehlo_to_linalg.mlir
similarity index 100%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/test/stablehlo_to_linalg.mlir
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/test/stablehlo_to_linalg.mlir
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/test/stablehlo_to_linalg_convolution.mlir b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/test/stablehlo_to_linalg_convolution.mlir
similarity index 100%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/test/stablehlo_to_linalg_convolution.mlir
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/test/stablehlo_to_linalg_convolution.mlir
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/test/stablehlo_to_linalg_dot_prod.mlir b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/test/stablehlo_to_linalg_dot_prod.mlir
similarity index 100%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/test/stablehlo_to_linalg_dot_prod.mlir
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/test/stablehlo_to_linalg_dot_prod.mlir
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/test/stablehlo_to_linalg_ext.mlir b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/test/stablehlo_to_linalg_ext.mlir
similarity index 100%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/test/stablehlo_to_linalg_ext.mlir
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/test/stablehlo_to_linalg_ext.mlir
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/test/stablehlo_to_linalg_gather.mlir b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/test/stablehlo_to_linalg_gather.mlir
similarity index 100%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/test/stablehlo_to_linalg_gather.mlir
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/test/stablehlo_to_linalg_gather.mlir
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/test/stablehlo_to_linalg_pointwise.mlir b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/test/stablehlo_to_linalg_pointwise.mlir
similarity index 100%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/test/stablehlo_to_linalg_pointwise.mlir
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/test/stablehlo_to_linalg_pointwise.mlir
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/test/stablehlo_to_linalg_random.mlir b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/test/stablehlo_to_linalg_random.mlir
similarity index 100%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/test/stablehlo_to_linalg_random.mlir
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/test/stablehlo_to_linalg_random.mlir
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/test/stablehlo_to_linalg_reduce.mlir b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/test/stablehlo_to_linalg_reduce.mlir
similarity index 100%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/test/stablehlo_to_linalg_reduce.mlir
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/test/stablehlo_to_linalg_reduce.mlir
diff --git a/compiler/src/iree/compiler/InputConversion/StableHLO/test/verify_compiler_input_legality.mlir b/compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/test/verify_compiler_input_legality.mlir
similarity index 100%
rename from compiler/src/iree/compiler/InputConversion/StableHLO/test/verify_compiler_input_legality.mlir
rename to compiler/plugins/input/StableHLO/stablehlo-iree/Conversion/test/verify_compiler_input_legality.mlir
diff --git a/compiler/plugins/input/StableHLO/stablehlo-iree/PluginRegistration.cpp b/compiler/plugins/input/StableHLO/stablehlo-iree/PluginRegistration.cpp
new file mode 100644
index 0000000..2d8b002
--- /dev/null
+++ b/compiler/plugins/input/StableHLO/stablehlo-iree/PluginRegistration.cpp
@@ -0,0 +1,173 @@
+// 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
+
+#include "iree/compiler/PluginAPI/Client.h"
+#include "mlir/Conversion/Passes.h"
+#include "mlir/IR/BuiltinOps.h"
+#include "mlir/Pass/PassManager.h"
+#include "stablehlo/dialect/ChloOps.h"
+#include "stablehlo/dialect/StablehloOps.h"
+
+#include "stablehlo-iree/Conversion/Passes.h"
+
+namespace mlir {
+namespace iree_compiler {
+namespace stablehlo {
+
+namespace {
+
+struct StableHLOOptions {
+ bool demoteI64ToI32 = true;
+ bool demoteF64ToF32 = false;
+ bool promoteBF16ToF32 = false;
+
+ void bindOptions(OptionsBinder &binder) {
+ static llvm::cl::OptionCategory category("StableHLO Input");
+
+ // TODO(#8745): Find a better place for these options / rename them
+ // * Could rename to 'iree-stablehlo-*', but would want to update users
+ // * Could make generic, if they can be used with other dialects
+ binder.opt<bool>(
+ "iree-input-demote-i64-to-i32", demoteI64ToI32,
+ llvm::cl::desc(
+ "Converts all i64 ops and values into i32 counterparts."),
+ llvm::cl::cat(category));
+
+ binder.opt<bool>(
+ "iree-input-demote-f64-to-f32", demoteF64ToF32,
+ llvm::cl::desc(
+ "Converts all f64 ops and values into f32 counterparts."),
+ llvm::cl::cat(category));
+
+ binder.opt<bool>(
+ "iree-input-promote-bf16-to-f32", promoteBF16ToF32,
+ llvm::cl::desc(
+ "Converts all bf16 ops and values into f32 counterparts."),
+ llvm::cl::cat(category));
+ }
+};
+
+static bool checkOpForTuples(Operation *op) {
+ if (auto funcOp = dyn_cast<func::FuncOp>(op)) {
+ FunctionType type = dyn_cast<FunctionType>(funcOp.getFunctionType());
+ for (auto t : type.getResults()) {
+ if (isa<TupleType>(t)) {
+ return true;
+ }
+ }
+ for (auto t : type.getInputs()) {
+ if (isa<TupleType>(t)) {
+ return true;
+ }
+ }
+ }
+
+ // Check for tuple operands or results.
+ for (auto t : op->getOperandTypes()) {
+ if (isa<TupleType>(t)) {
+ return true;
+ }
+ }
+ for (auto t : op->getResultTypes()) {
+ if (isa<TupleType>(t)) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+// StableHLO (https://github.com/openxla/stablehlo) support plugin.
+//
+// The StableHLO plugin provides dialects, passes and opt-in options.
+// Therefore, it is appropriate for default activation.
+struct StableHLOSession
+ : public PluginSession<StableHLOSession, StableHLOOptions,
+ PluginActivationPolicy::DefaultActivated> {
+ static void registerPasses() {
+ // TODO(scotttodd): register other StableHLO passes?
+ registerStableHLOConversionPasses();
+ }
+
+ void onRegisterDialects(DialectRegistry ®istry) override {
+ registry.insert<mlir::chlo::ChloDialect>();
+ registry.insert<mlir::stablehlo::StablehloDialect>();
+ }
+
+ bool extendCustomInputConversionPassPipeline(
+ OpPassManager &passManager, std::string_view typeMnemonic) override {
+ StableHloOptions stableHloOptions;
+ stableHloOptions.demoteI64ToI32 = options.demoteI64ToI32;
+ stableHloOptions.demoteF64ToF32 = options.demoteF64ToF32;
+ stableHloOptions.promoteBF16ToF32 = options.promoteBF16ToF32;
+
+ if (typeMnemonic == "stablehlo") {
+ buildStableHLOInputConversionPassPipeline(passManager, stableHloOptions);
+ return true;
+ } else if (typeMnemonic == "stablehlo_xla") {
+ buildStableHLOXLAInputConversionPassPipeline(passManager,
+ stableHloOptions);
+ return true;
+ }
+
+ return false;
+ }
+
+ void populateCustomInputConversionTypes(StringSet<> &typeMnemonics) override {
+ typeMnemonics.insert("stablehlo");
+ typeMnemonics.insert("stablehlo_xla");
+ }
+
+ void populateDetectedCustomInputConversionTypes(
+ ModuleOp &module, StringSet<> &typeMnemonics) override {
+
+ auto *ctx = module.getContext();
+ const Dialect *chloDialect = ctx->getLoadedDialect("chlo");
+ const Dialect *stablehloDialect = ctx->getLoadedDialect("stablehlo");
+
+ // stablehlo ops _with tuples_ --> only "stablehlo_xla" type
+ // stablehlo ops _without tuples_ --> only "stablehlo" type
+ // no stablehlo ops --> no types
+
+ bool hasStableHLO = false;
+ bool hasTuples = false;
+ module.walk([&](Operation *op) {
+ Dialect *d = op->getDialect();
+ if (d == chloDialect || d == stablehloDialect) {
+ hasStableHLO = true;
+ if (checkOpForTuples(op)) {
+ hasTuples = true;
+ // Early exit, no need to continue scanning.
+ return WalkResult::interrupt();
+ }
+ // Keep scanning in case a future op contains tuples.
+ }
+ return WalkResult::advance();
+ });
+
+ if (hasTuples) {
+ typeMnemonics.insert("stablehlo_xla");
+ } else if (hasStableHLO) {
+ typeMnemonics.insert("stablehlo");
+ }
+ }
+};
+
+} // namespace
+
+} // namespace stablehlo
+} // namespace iree_compiler
+} // namespace mlir
+
+IREE_DEFINE_COMPILER_OPTION_FLAGS(
+ ::mlir::iree_compiler::stablehlo::StableHLOOptions);
+
+extern "C" bool iree_register_compiler_plugin_input_stablehlo(
+ mlir::iree_compiler::PluginRegistrar *registrar) {
+ registrar->registerPlugin<::mlir::iree_compiler::stablehlo::StableHLOSession>(
+ "input_stablehlo");
+ return true;
+}
diff --git a/compiler/plugins/input/TOSA/tosa-iree/InputConversion/test/BUILD.bazel b/compiler/plugins/input/TOSA/tosa-iree/InputConversion/test/BUILD.bazel
index b1a0a24..8a57538 100644
--- a/compiler/plugins/input/TOSA/tosa-iree/InputConversion/test/BUILD.bazel
+++ b/compiler/plugins/input/TOSA/tosa-iree/InputConversion/test/BUILD.bazel
@@ -16,6 +16,7 @@
name = "lit",
srcs = enforce_glob(
[
+ "auto_input_conversion.mlir",
"convert_i48_to_i64.mlir",
"strip_signedness.mlir",
"tosa_to_linalg_ext.mlir",
@@ -25,6 +26,7 @@
),
cfg = "//compiler:lit.cfg.py",
tools = [
+ "//tools:iree-compile",
"//tools:iree-opt",
"@llvm-project//llvm:FileCheck",
],
diff --git a/compiler/plugins/input/TOSA/tosa-iree/InputConversion/test/CMakeLists.txt b/compiler/plugins/input/TOSA/tosa-iree/InputConversion/test/CMakeLists.txt
index 06ddb1c..d45111e 100644
--- a/compiler/plugins/input/TOSA/tosa-iree/InputConversion/test/CMakeLists.txt
+++ b/compiler/plugins/input/TOSA/tosa-iree/InputConversion/test/CMakeLists.txt
@@ -14,12 +14,14 @@
NAME
lit
SRCS
+ "auto_input_conversion.mlir"
"convert_i48_to_i64.mlir"
"strip_signedness.mlir"
"tosa_to_linalg_ext.mlir"
"verify_compiler_tosa_input_legality.mlir"
TOOLS
FileCheck
+ iree-compile
iree-opt
)
diff --git a/compiler/plugins/input/TOSA/tosa-iree/InputConversion/test/auto_input_conversion.mlir b/compiler/plugins/input/TOSA/tosa-iree/InputConversion/test/auto_input_conversion.mlir
new file mode 100644
index 0000000..957f0d3
--- /dev/null
+++ b/compiler/plugins/input/TOSA/tosa-iree/InputConversion/test/auto_input_conversion.mlir
@@ -0,0 +1,10 @@
+// RUN: iree-compile --compile-to=input --split-input-file %s | FileCheck %s
+
+// Check that the auto input conversion pipeline uses this plugin.
+
+// CHECK-LABEL: func.func @simple_add_tosa
+// CHECK: arith.addi
+func.func @simple_add_tosa(%arg0: tensor<2x2xi32>, %arg1: tensor<2x2xi32>) -> tensor<2x2xi32> {
+ %0 = tosa.add %arg0, %arg1 : (tensor<2x2xi32>, tensor<2x2xi32>) -> tensor<2x2xi32>
+ return %0 : tensor<2x2xi32>
+}
diff --git a/compiler/plugins/input/Torch/torch-iree/InputConversion/test/CMakeLists.txt b/compiler/plugins/input/Torch/torch-iree/InputConversion/test/CMakeLists.txt
index f2d2c0c..35f4295 100644
--- a/compiler/plugins/input/Torch/torch-iree/InputConversion/test/CMakeLists.txt
+++ b/compiler/plugins/input/Torch/torch-iree/InputConversion/test/CMakeLists.txt
@@ -3,6 +3,7 @@
lit
SRCS
"assume_strict_symbols.mlir"
+ "auto_input_conversion.mlir"
"attention.mlir"
"bitcast_quant_tensor.mlir"
"scan.mlir"
@@ -11,5 +12,6 @@
"torch_to_iree.mlir"
TOOLS
FileCheck
+ iree-compile
iree-opt
)
diff --git a/compiler/plugins/input/Torch/torch-iree/InputConversion/test/auto_input_conversion.mlir b/compiler/plugins/input/Torch/torch-iree/InputConversion/test/auto_input_conversion.mlir
new file mode 100644
index 0000000..b8feb51
--- /dev/null
+++ b/compiler/plugins/input/Torch/torch-iree/InputConversion/test/auto_input_conversion.mlir
@@ -0,0 +1,11 @@
+// RUN: iree-compile --compile-to=input --split-input-file %s | FileCheck %s
+
+// Check that the auto input conversion pipeline uses this plugin.
+
+// CHECK-LABEL: func.func @simple_add_torch
+// CHECK: arith.addf
+func.func @simple_add_torch(%arg0: !torch.vtensor<[2],f32>, %arg1: !torch.vtensor<[2],f32>) -> !torch.vtensor<[2],f32> {
+ %int1 = torch.constant.int 1
+ %0 = torch.aten.add.Tensor %arg0, %arg1, %int1 : !torch.vtensor<[2],f32>, !torch.vtensor<[2],f32>, !torch.int -> !torch.vtensor<[2],f32>
+ return %0 : !torch.vtensor<[2],f32>
+}
diff --git a/compiler/plugins/iree_compiler_plugin.cmake b/compiler/plugins/iree_compiler_plugin.cmake
index df17ecd..31f6715 100644
--- a/compiler/plugins/iree_compiler_plugin.cmake
+++ b/compiler/plugins/iree_compiler_plugin.cmake
@@ -4,6 +4,10 @@
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+if(IREE_INPUT_STABLEHLO)
+ add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/input/StableHLO input/StableHLO)
+endif()
+
if(IREE_INPUT_TORCH)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/input/Torch input/Torch)
endif()
diff --git a/compiler/src/iree/compiler/InputConversion/CMakeLists.txt b/compiler/src/iree/compiler/InputConversion/CMakeLists.txt
index 9467020..422c1b6 100644
--- a/compiler/src/iree/compiler/InputConversion/CMakeLists.txt
+++ b/compiler/src/iree/compiler/InputConversion/CMakeLists.txt
@@ -1,11 +1,13 @@
-# Copyright 2022 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
+################################################################################
+# Autogenerated by build_tools/bazel_to_cmake/bazel_to_cmake.py from #
+# compiler/src/iree/compiler/InputConversion/BUILD.bazel #
+# #
+# Use iree_cmake_extra_content from iree/build_defs.oss.bzl to add arbitrary #
+# CMake-only content. #
+# #
+# To disable autogeneration for this file entirely, delete this header. #
+################################################################################
-add_subdirectory(Common)
+iree_add_all_subdirs()
-if(IREE_INPUT_STABLEHLO)
- add_subdirectory(StableHLO)
-endif()
+### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_BELOW_THIS_LINE ###
diff --git a/compiler/src/iree/compiler/InputConversion/Common/AutoInputConversionPipeline.cpp b/compiler/src/iree/compiler/InputConversion/Common/AutoInputConversionPipeline.cpp
index c6b8948..dccaf5d 100644
--- a/compiler/src/iree/compiler/InputConversion/Common/AutoInputConversionPipeline.cpp
+++ b/compiler/src/iree/compiler/InputConversion/Common/AutoInputConversionPipeline.cpp
@@ -7,228 +7,81 @@
#include "iree/compiler/InputConversion/Common/PassDetail.h"
#include "iree/compiler/InputConversion/Common/Passes.h"
#include "iree/compiler/PluginAPI/Client.h"
-#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/IR/BuiltinDialect.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Pass/PassManager.h"
-// Dialect specific
-#ifdef IREE_HAVE_STABLEHLO_INPUT
-#include "iree/compiler/InputConversion/StableHLO/Passes.h"
-#include "stablehlo/dialect/StablehloOps.h"
-#endif // IREE_HAVE_STABLEHLO_INPUT
-
namespace mlir::iree_compiler {
namespace {
struct AutoInputConversionPipelinePass final
: AutoInputConversionPipelineBase<AutoInputConversionPipelinePass> {
- AutoInputConversionPipelinePass(
- const AutoInputConversionPipelineOptions &inputOptions,
- PipelineExtensions *pipelineExtensions)
- : pipelineExtensions(pipelineExtensions) {
- demoteI64ToI32 = inputOptions.demoteI64ToI32;
- demoteF64ToF32 = inputOptions.demoteF64ToF32;
- promoteBF16ToF32 = inputOptions.promoteBF16ToF32;
- }
+ AutoInputConversionPipelinePass(PipelineExtensions *pipelineExtensions)
+ : pipelineExtensions(pipelineExtensions) {}
void runOnOperation() override;
void getDependentDialects(DialectRegistry ®istry) const override;
PipelineExtensions *pipelineExtensions = nullptr;
};
-// All the features seen that should be handled during input conversion.
-struct InputFeatures {
- // HLO features.
- bool hasStableHLO = false;
- // - XLA import features.
- bool hasTuples = false;
-};
-
-static void populateHloFeatures(Operation *op, InputFeatures &features) {
- if (features.hasTuples) {
- return;
- }
-
- if (auto funcOp = dyn_cast<func::FuncOp>(op)) {
- FunctionType type = dyn_cast<FunctionType>(funcOp.getFunctionType());
- for (auto t : type.getResults()) {
- if (isa<TupleType>(t)) {
- features.hasTuples = true;
- return;
- }
- }
- for (auto t : type.getInputs()) {
- if (isa<TupleType>(t)) {
- features.hasTuples = true;
- return;
- }
- }
- }
-
- // Check for tuple operands or results.
- for (auto t : op->getOperandTypes()) {
- if (isa<TupleType>(t)) {
- features.hasTuples = true;
- return;
- }
- }
- for (auto t : op->getResultTypes()) {
- if (isa<TupleType>(t)) {
- features.hasTuples = true;
- return;
- }
- }
-}
-
-static void populateFeatures(Operation *op, const Dialect *chloDialect,
- const Dialect *stablehloDialect,
- InputFeatures &features) {
- Dialect *d = op->getDialect();
- if (d == stablehloDialect || d == chloDialect) {
- features.hasStableHLO = true;
- return populateHloFeatures(op, features);
- }
-}
-
void AutoInputConversionPipelinePass::runOnOperation() {
+ if (!pipelineExtensions)
+ return;
+
ModuleOp module = getOperation();
- MLIRContext *context = &getContext();
-
- // Check if any plugin-provided pipeline extensions can convert dialects in
- // the module first.
- if (pipelineExtensions) {
- llvm::StringSet<> detectedTypeMnemonics;
- pipelineExtensions->populateDetectedCustomInputConversionTypes(
- module, detectedTypeMnemonics);
-
- if (detectedTypeMnemonics.getNumItems() > 1) {
- // TODO(scotttodd): handle multiple typeMnemonics (use all?)
- auto diag = module.emitError(
- "mixture of input types not yet implemented, set "
- "'--iree-input-type=[type]' explicitly instead of using 'auto' or "
- "audit the input program to understand why dialects are mixed");
- diag << " (detected:";
- for (auto &s : detectedTypeMnemonics) {
- diag << " '" << s.first() << "'";
- }
- diag << ")";
- return signalPassFailure();
- } else if (detectedTypeMnemonics.getNumItems() == 1) {
- auto typeMnemonic = detectedTypeMnemonics.begin()->getKey();
- OpPassManager passManager(module.getOperationName());
- bool foundExtension =
- pipelineExtensions->extendCustomInputConversionPassPipeline(
- passManager, typeMnemonic);
- if (!foundExtension) {
- // We expect that callers properly validate supported extensions and
- // that if a plugin advertises support, it actually provides it.
- module.emitError() << "custom input conversion for extension '"
- << typeMnemonic << "' not found";
- return signalPassFailure();
- }
- if (failed(runPipeline(passManager, module))) {
- return signalPassFailure();
- }
- return;
- }
- }
-
- // No plugin-provided pipeline extensions were detected, try the built-in
- // dialect conversions.
- // TODO(scotttodd): Migrate these to compiler plugins?
-
- InputFeatures features;
- const Dialect *chloDialect = context->getLoadedDialect("chlo");
- const Dialect *stablehloDialect = context->getLoadedDialect("stablehlo");
- if (!chloDialect && !stablehloDialect) {
+ llvm::StringSet<> detectedTypeMnemonics;
+ pipelineExtensions->populateDetectedCustomInputConversionTypes(
+ module, detectedTypeMnemonics);
+ if (detectedTypeMnemonics.empty())
return;
- }
- module.walk([&](Operation *op) {
- populateFeatures(op, chloDialect, stablehloDialect, features);
- return WalkResult::advance();
- });
- if (!features.hasStableHLO) {
- return;
- }
-
- OpPassManager pm(ModuleOp::getOperationName(),
- OpPassManager::Nesting::Explicit);
-#ifdef IREE_HAVE_STABLEHLO_INPUT
- if (features.hasStableHLO) {
- stablehlo::StableHloOptions options;
- options.demoteI64ToI32 = demoteI64ToI32;
- options.demoteF64ToF32 = demoteF64ToF32;
- options.promoteBF16ToF32 = promoteBF16ToF32;
- if (features.hasTuples) {
- stablehlo::buildStableHLOXLAInputConversionPassPipeline(pm, options);
- } else {
- stablehlo::buildStableHLOInputConversionPassPipeline(pm, options);
+ if (detectedTypeMnemonics.getNumItems() > 1) {
+ // TODO(scotttodd): handle multiple typeMnemonics (use all?)
+ auto diag = module.emitError(
+ "mixture of input types not yet implemented, set "
+ "'--iree-input-type=[type]' explicitly instead of using 'auto' or "
+ "audit the input program to understand why dialects are mixed");
+ diag << " (detected:";
+ for (auto &s : detectedTypeMnemonics) {
+ diag << " '" << s.first() << "'";
}
+ diag << ")";
+ return signalPassFailure();
}
-#endif // IREE_HAVE_STABLEHLO_INPUT
- if (failed(runPipeline(pm, module))) {
- signalPassFailure();
+ auto typeMnemonic = detectedTypeMnemonics.begin()->getKey();
+ OpPassManager passManager(module.getOperationName());
+ bool foundExtension =
+ pipelineExtensions->extendCustomInputConversionPassPipeline(passManager,
+ typeMnemonic);
+ if (!foundExtension) {
+ // We expect that callers properly validate supported extensions and
+ // that if a plugin advertises support, it actually provides it.
+ module.emitError() << "custom input conversion for extension '"
+ << typeMnemonic << "' not found";
+ return signalPassFailure();
+ }
+ if (failed(runPipeline(passManager, module))) {
+ return signalPassFailure();
}
}
void AutoInputConversionPipelinePass::getDependentDialects(
DialectRegistry ®istry) const {
- // Register dialects from all possible pipelines, as we do not statically know
- // which pipeline will be selected, while dialect registration happens before
- // we run any detection on the input.
- //
- // TODO(kuhar): Find a better registration mechanism so that we do not have to
- // build pipelines just to query dialects and discard them immediately after.
- auto appendPipelineDialects =
- [®istry](function_ref<void(OpPassManager &)> buildFn) {
- OpPassManager pm;
- buildFn(pm);
- pm.getDependentDialects(registry);
- };
-
-#ifdef IREE_HAVE_STABLEHLO_INPUT
- auto appendStablehloPipelineDialects =
- [®istry](function_ref<void(OpPassManager &,
- const stablehlo::StableHloOptions &options)>
- buildFn) {
- const stablehlo::StableHloOptions options;
- OpPassManager pm;
- buildFn(pm, options);
- pm.getDependentDialects(registry);
- };
-
- appendStablehloPipelineDialects(
- stablehlo::buildStableHLOInputConversionPassPipeline);
- appendStablehloPipelineDialects(
- stablehlo::buildStableHLOXLAInputConversionPassPipeline);
-#endif // IREE_HAVE_STABLEHLO_INPUT
-
if (pipelineExtensions) {
pipelineExtensions->registerDialects(registry);
}
-
- if (pipelineExtensions) {
- pipelineExtensions->registerDialects(registry);
- }
-
- (void)appendPipelineDialects;
}
} // namespace
std::unique_ptr<OperationPass<ModuleOp>>
createAutoInputConversionPipelinePass() {
- AutoInputConversionPipelineOptions options;
- return std::make_unique<AutoInputConversionPipelinePass>(options, nullptr);
+ return std::make_unique<AutoInputConversionPipelinePass>(nullptr);
}
-std::unique_ptr<OperationPass<ModuleOp>> createAutoInputConversionPipelinePass(
- const AutoInputConversionPipelineOptions &options,
- PipelineExtensions *pipelineExtensions) {
- return std::make_unique<AutoInputConversionPipelinePass>(options,
- pipelineExtensions);
+std::unique_ptr<OperationPass<ModuleOp>>
+createAutoInputConversionPipelinePass(PipelineExtensions *pipelineExtensions) {
+ return std::make_unique<AutoInputConversionPipelinePass>(pipelineExtensions);
}
} // namespace mlir::iree_compiler
diff --git a/compiler/src/iree/compiler/InputConversion/Common/BUILD.bazel b/compiler/src/iree/compiler/InputConversion/Common/BUILD.bazel
index add7f7f..7d51cdb 100644
--- a/compiler/src/iree/compiler/InputConversion/Common/BUILD.bazel
+++ b/compiler/src/iree/compiler/InputConversion/Common/BUILD.bazel
@@ -94,7 +94,6 @@
deps = [
":PassHeaders",
":PassesIncGen",
- "//compiler/src/iree/compiler/InputConversion/StableHLO",
"//compiler/src/iree/compiler/PluginAPI",
"//compiler/src/iree/compiler/Utils",
"@llvm-project//llvm:Support",
@@ -102,6 +101,5 @@
"@llvm-project//mlir:IR",
"@llvm-project//mlir:Pass",
"@llvm-project//mlir:Transforms",
- "@stablehlo//:stablehlo_ops",
],
)
diff --git a/compiler/src/iree/compiler/InputConversion/Common/CMakeLists.txt b/compiler/src/iree/compiler/InputConversion/Common/CMakeLists.txt
index ae64957..b58eed1 100644
--- a/compiler/src/iree/compiler/InputConversion/Common/CMakeLists.txt
+++ b/compiler/src/iree/compiler/InputConversion/Common/CMakeLists.txt
@@ -1,14 +1,12 @@
-# Copyright 2022 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
-
-# Enable input dialects based on options.
-set(IREE_INPUT_DEPS "")
-if(IREE_INPUT_STABLEHLO)
- list(APPEND IREE_INPUT_DEPS iree::compiler::InputConversion::StableHLO)
-endif()
+################################################################################
+# Autogenerated by build_tools/bazel_to_cmake/bazel_to_cmake.py from #
+# compiler/src/iree/compiler/InputConversion/Common/BUILD.bazel #
+# #
+# Use iree_cmake_extra_content from iree/build_defs.oss.bzl to add arbitrary #
+# CMake-only content. #
+# #
+# To disable autogeneration for this file entirely, delete this header. #
+################################################################################
iree_add_all_subdirs()
@@ -84,15 +82,16 @@
SRCS
"AutoInputConversionPipeline.cpp"
DEPS
- ${IREE_INPUT_DEPS}
::PassHeaders
::PassesIncGen
LLVMSupport
MLIRFuncDialect
MLIRIR
- MLIRLinalgUtils
MLIRPass
MLIRTransforms
iree::compiler::PluginAPI
+ iree::compiler::Utils
PUBLIC
)
+
+### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_BELOW_THIS_LINE ###
diff --git a/compiler/src/iree/compiler/InputConversion/Common/Passes.h b/compiler/src/iree/compiler/InputConversion/Common/Passes.h
index c95401b..865b2c0 100644
--- a/compiler/src/iree/compiler/InputConversion/Common/Passes.h
+++ b/compiler/src/iree/compiler/InputConversion/Common/Passes.h
@@ -35,9 +35,8 @@
std::unique_ptr<OperationPass<ModuleOp>>
createAutoInputConversionPipelinePass();
-std::unique_ptr<OperationPass<ModuleOp>> createAutoInputConversionPipelinePass(
- const AutoInputConversionPipelineOptions &options,
- PipelineExtensions *pipelineExtensions);
+std::unique_ptr<OperationPass<ModuleOp>>
+createAutoInputConversionPipelinePass(PipelineExtensions *pipelineExtensions);
std::unique_ptr<OperationPass<ModuleOp>> createIREEImportPublicPass();
std::unique_ptr<OperationPass<ModuleOp>> createImportMLProgramPass();
std::unique_ptr<OperationPass<func::FuncOp>>
diff --git a/compiler/src/iree/compiler/InputConversion/Common/Passes.td b/compiler/src/iree/compiler/InputConversion/Common/Passes.td
index 6f4d3c6..a93d685 100644
--- a/compiler/src/iree/compiler/InputConversion/Common/Passes.td
+++ b/compiler/src/iree/compiler/InputConversion/Common/Passes.td
@@ -47,14 +47,6 @@
conversion to run, then run that conversion.
}];
let constructor = "mlir::iree_compiler::createAutoInputConversionPipelinePass()";
- let options = [
- Option<"demoteI64ToI32", "iree-autoinput-demote-i64-to-i32", "bool",
- /*default=*/"true", "Convert I64 to I32 equivalents">,
- Option<"demoteF64ToF32", "iree-autoinput-demote-f64-to-f32", "bool",
- /*default=*/"false", "Convert F64 to F32 equivalents">,
- Option<"promoteBF16ToF32", "iree-autoinput-demote-bf16-to-f32", "bool",
- /*default=*/"false", "Convert BF16 to F32 equivalents">,
- ];
}
#endif // IREE_COMPILER_INPUTCONVERSION_COMMON_PASSES
diff --git a/compiler/src/iree/compiler/InputConversion/Common/test/BUILD.bazel b/compiler/src/iree/compiler/InputConversion/Common/test/BUILD.bazel
index 89a24b8..309cb9a 100644
--- a/compiler/src/iree/compiler/InputConversion/Common/test/BUILD.bazel
+++ b/compiler/src/iree/compiler/InputConversion/Common/test/BUILD.bazel
@@ -18,7 +18,6 @@
name = "lit",
srcs = enforce_glob(
[
- "auto_input_conversion_pipeline.mlir",
"import_ml_program.mlir",
"iree_import_public.mlir",
"linalg_quantized_conv_to_conv.mlir",
diff --git a/compiler/src/iree/compiler/InputConversion/Common/test/CMakeLists.txt b/compiler/src/iree/compiler/InputConversion/Common/test/CMakeLists.txt
index 8b967d3..5a31cce 100644
--- a/compiler/src/iree/compiler/InputConversion/Common/test/CMakeLists.txt
+++ b/compiler/src/iree/compiler/InputConversion/Common/test/CMakeLists.txt
@@ -14,7 +14,6 @@
NAME
lit
SRCS
- "auto_input_conversion_pipeline.mlir"
"import_ml_program.mlir"
"iree_import_public.mlir"
"linalg_quantized_conv_to_conv.mlir"
diff --git a/compiler/src/iree/compiler/Pipelines/BUILD.bazel b/compiler/src/iree/compiler/Pipelines/BUILD.bazel
index df24320..b81c25a 100644
--- a/compiler/src/iree/compiler/Pipelines/BUILD.bazel
+++ b/compiler/src/iree/compiler/Pipelines/BUILD.bazel
@@ -17,7 +17,6 @@
srcs = ["Options.cpp"],
hdrs = ["Options.h"],
deps = [
- "//compiler/src/iree/compiler/InputConversion/StableHLO",
"//compiler/src/iree/compiler/Utils",
],
)
@@ -47,7 +46,6 @@
"//compiler/src/iree/compiler/GlobalOptimization",
"//compiler/src/iree/compiler/InputConversion/Common",
"//compiler/src/iree/compiler/InputConversion/Common:AutoInputConversionPipeline",
- "//compiler/src/iree/compiler/InputConversion/StableHLO",
"//compiler/src/iree/compiler/Modules/HAL/Inline/Transforms",
"//compiler/src/iree/compiler/Modules/HAL/Loader/Transforms",
"//compiler/src/iree/compiler/Preprocessing:Passes",
diff --git a/compiler/src/iree/compiler/Pipelines/CMakeLists.txt b/compiler/src/iree/compiler/Pipelines/CMakeLists.txt
index 010308b..4cec12f 100644
--- a/compiler/src/iree/compiler/Pipelines/CMakeLists.txt
+++ b/compiler/src/iree/compiler/Pipelines/CMakeLists.txt
@@ -1,15 +1,14 @@
-# Copyright 2022 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
+################################################################################
+# Autogenerated by build_tools/bazel_to_cmake/bazel_to_cmake.py from #
+# compiler/src/iree/compiler/Pipelines/BUILD.bazel #
+# #
+# Use iree_cmake_extra_content from iree/build_defs.oss.bzl to add arbitrary #
+# CMake-only content. #
+# #
+# To disable autogeneration for this file entirely, delete this header. #
+################################################################################
-# Enable input dialects based on options.
-set(IREE_INPUT_DEPS "")
-set(IREE_INPUT_DEFINES "")
-if(IREE_INPUT_STABLEHLO)
- list(APPEND IREE_INPUT_DEPS iree::compiler::InputConversion::StableHLO)
-endif()
+iree_add_all_subdirs()
iree_cc_library(
NAME
@@ -19,9 +18,7 @@
SRCS
"Options.cpp"
DEPS
- ${IREE_INPUT_DEPS}
iree::compiler::Utils
- iree::compiler::PluginAPI::Config::Defs
PUBLIC
)
@@ -33,7 +30,6 @@
SRCS
"Pipelines.cpp"
DEPS
- ${IREE_INPUT_DEPS}
::Options
LLVMSupport
MLIRIR
@@ -43,6 +39,7 @@
iree::compiler::Bindings::TFLite::Transforms
iree::compiler::Dialect::Flow::Transforms
iree::compiler::Dialect::HAL::Conversion::HALToVM
+ iree::compiler::Dialect::HAL::Target
iree::compiler::Dialect::HAL::Transforms
iree::compiler::Dialect::Stream::Transforms
iree::compiler::Dialect::Util::Transforms
@@ -50,12 +47,14 @@
iree::compiler::Dialect::VM::Conversion::StandardToVM
iree::compiler::Dialect::VM::Target::Bytecode
iree::compiler::Dialect::VM::Transforms
- iree::compiler::Modules::HAL::Inline::Transforms
- iree::compiler::Modules::HAL::Loader::Transforms
+ iree::compiler::GlobalOptimization
iree::compiler::InputConversion::Common
iree::compiler::InputConversion::Common::AutoInputConversionPipeline
+ iree::compiler::Modules::HAL::Inline::Transforms
+ iree::compiler::Modules::HAL::Loader::Transforms
iree::compiler::Preprocessing::Passes
- iree::compiler::GlobalOptimization
iree::compiler::Utils
PUBLIC
)
+
+### BAZEL_TO_CMAKE_PRESERVES_ALL_CONTENT_BELOW_THIS_LINE ###
diff --git a/compiler/src/iree/compiler/Pipelines/Options.cpp b/compiler/src/iree/compiler/Pipelines/Options.cpp
index c5c4c74..879bd1c 100644
--- a/compiler/src/iree/compiler/Pipelines/Options.cpp
+++ b/compiler/src/iree/compiler/Pipelines/Options.cpp
@@ -41,13 +41,13 @@
"Specifies the input program representation:\n"
" =none - No input dialect transformation.\n"
" =auto - Analyze the input program to choose conversion.\n"
-#ifdef IREE_HAVE_STABLEHLO_INPUT
- " =stablehlo - Legalize from StableHLO ops.\n"
- " =stablehlo_xla - Legalize from StableHLO ops (with XLA cleanup preprocessing).\n"
-#endif // IREE_HAVE_STABLEHLO_INPUT
// NOTE: The plugin system does not have a good way to populate CL help
// messages, so we err on the side of being helpful and populating plugin
// options here, even though it is a layering violation.
+#ifdef IREE_COMPILER_PLUGIN_HAVE_STATIC_INPUT_STABLEHLO
+ " =stablehlo - Legalize from StableHLO ops.\n"
+ " =stablehlo_xla - Legalize from StableHLO ops (with XLA cleanup preprocessing).\n"
+#endif // IREE_COMPILER_PLUGIN_HAVE_STATIC_INPUT_STABLEHLO
#ifdef IREE_COMPILER_PLUGIN_HAVE_STATIC_INPUT_TOSA
" =tosa - Legalize from TOSA ops.\n"
#endif // IREE_COMPILER_PLUGIN_HAVE_STATIC_INPUT_TOSA
@@ -59,23 +59,6 @@
// clang-format on
),
llvm::cl::cat(category));
-
-#ifdef IREE_HAVE_STABLEHLO_INPUT
- binder.opt<bool>(
- "iree-input-demote-i64-to-i32", demoteI64ToI32,
- llvm::cl::desc("Converts all i64 ops and values into i32 counterparts."),
- llvm::cl::cat(category));
-
- binder.opt<bool>(
- "iree-input-demote-f64-to-f32", demoteF64ToF32,
- llvm::cl::desc("Converts all f64 ops and values into f32 counterparts."),
- llvm::cl::cat(category));
-
- binder.opt<bool>(
- "iree-input-promote-bf16-to-f32", promoteBF16ToF32,
- llvm::cl::desc("Converts all bf16 ops and values into f32 counterparts."),
- llvm::cl::cat(category));
-#endif // IREE_HAVE_STABLEHLO_INPUT
}
InputDialectOptions::Type InputDialectOptions::parseInputTypeMnemonic() {
@@ -83,12 +66,6 @@
return Type::none;
} else if (inputTypeMnemonic == "auto") {
return Type::auto_detect;
-#ifdef IREE_HAVE_STABLEHLO_INPUT
- } else if (inputTypeMnemonic == "stablehlo") {
- return Type::stablehlo;
- } else if (inputTypeMnemonic == "stablehlo_xla") {
- return Type::stablehlo_xla;
-#endif
} else {
return Type::plugin;
}
diff --git a/compiler/src/iree/compiler/Pipelines/Options.h b/compiler/src/iree/compiler/Pipelines/Options.h
index e58cbff..509557d 100644
--- a/compiler/src/iree/compiler/Pipelines/Options.h
+++ b/compiler/src/iree/compiler/Pipelines/Options.h
@@ -40,13 +40,6 @@
// A named input pipeline from a plugin. If set, then 'pluginInputPipeline'
// must be set.
plugin,
-#ifdef IREE_HAVE_STABLEHLO_INPUT
- // Legalizes input defined over StableHLO ops.
- stablehlo,
- // Special case of 'stablehlo' legalization which also performs some XLA
- // preprocessing, e.g., flattening of tuples.
- stablehlo_xla,
-#endif // IREE_HAVE_STABLEHLO_INPUT
};
// The flag value is captured into spec by the CL system and it must be
// interpreted by parseInputTypeSpec.
diff --git a/compiler/src/iree/compiler/Pipelines/Pipelines.cpp b/compiler/src/iree/compiler/Pipelines/Pipelines.cpp
index 6d2ebcb..b888f8f 100644
--- a/compiler/src/iree/compiler/Pipelines/Pipelines.cpp
+++ b/compiler/src/iree/compiler/Pipelines/Pipelines.cpp
@@ -20,10 +20,6 @@
#include "iree/compiler/Preprocessing/Passes.h"
#include "iree/compiler/Utils/TracingUtils.h"
-#ifdef IREE_HAVE_STABLEHLO_INPUT
-#include "iree/compiler/InputConversion/StableHLO/Passes.h"
-#endif // IREE_HAVE_STABLEHLO_INPUT
-
namespace mlir {
namespace iree_compiler {
@@ -56,26 +52,17 @@
hooks.pipelineExtensions->extendInputConversionPreprocessingPassPipeline(
passManager, inputType);
}
- AutoInputConversionPipelineOptions autoOptions;
- autoOptions.demoteI64ToI32 = inputOptions.demoteI64ToI32;
- autoOptions.demoteF64ToF32 = inputOptions.demoteF64ToF32;
- autoOptions.promoteBF16ToF32 = inputOptions.promoteBF16ToF32;
-
-#ifdef IREE_HAVE_STABLEHLO_INPUT
- stablehlo::StableHloOptions stablehloOptions;
- stablehloOptions.demoteI64ToI32 = inputOptions.demoteI64ToI32;
- stablehloOptions.demoteF64ToF32 = inputOptions.demoteF64ToF32;
- stablehloOptions.promoteBF16ToF32 = inputOptions.promoteBF16ToF32;
-#endif // IREE_HAVE_STABLEHLO_INPUT
switch (inputType) {
case InputDialectOptions::Type::none:
break;
case InputDialectOptions::Type::auto_detect:
- passManager.addPass(createAutoInputConversionPipelinePass(
- autoOptions, hooks.pipelineExtensions));
+ // Run the auto pipeline that chooses from plugins using module contents.
+ passManager.addPass(
+ createAutoInputConversionPipelinePass(hooks.pipelineExtensions));
break;
case InputDialectOptions::Type::plugin: {
+ // Explicitly use a single plugin.
bool foundExtension = false;
if (hooks.pipelineExtensions) {
foundExtension =
@@ -93,17 +80,8 @@
}
break;
}
-#ifdef IREE_HAVE_STABLEHLO_INPUT
- case InputDialectOptions::Type::stablehlo:
- stablehlo::buildStableHLOInputConversionPassPipeline(passManager,
- stablehloOptions);
- break;
- case InputDialectOptions::Type::stablehlo_xla:
- stablehlo::buildStableHLOXLAInputConversionPassPipeline(passManager,
- stablehloOptions);
- break;
-#endif // IREE_HAVE_STABLEHLO_INPUT
}
+
buildCommonInputConversionPassPipeline(passManager);
IREE_TRACE_ADD_END_FRAME_PASS(passManager, "Input");
}
diff --git a/compiler/src/iree/compiler/PluginAPI/Config/BUILD.bazel b/compiler/src/iree/compiler/PluginAPI/Config/BUILD.bazel
index 16f9943..528c671 100644
--- a/compiler/src/iree/compiler/PluginAPI/Config/BUILD.bazel
+++ b/compiler/src/iree/compiler/PluginAPI/Config/BUILD.bazel
@@ -22,6 +22,7 @@
"echo '" +
"HANDLE_PLUGIN_ID(hal_target_cuda)\n" +
"HANDLE_PLUGIN_ID(input_tosa)\n" +
+ "HANDLE_PLUGIN_ID(input_stablehlo)\n" +
# Samples
"HANDLE_PLUGIN_ID(example)\n" +
"HANDLE_PLUGIN_ID(simple_io_sample)\n" +
@@ -41,6 +42,7 @@
# generates its deps from the environment.
# For now, we just hard include all in-tree plugins.
"//compiler/plugins/target/CUDA",
+ "//compiler/plugins/input/StableHLO/stablehlo-iree:registration",
"//compiler/plugins/input/TOSA/tosa-iree:registration",
"//samples/compiler_plugins/example:registration",
"//samples/compiler_plugins/simple_io_sample:registration",
diff --git a/compiler/src/iree/compiler/Tools/BUILD.bazel b/compiler/src/iree/compiler/Tools/BUILD.bazel
index a79bea0..297fd7f 100644
--- a/compiler/src/iree/compiler/Tools/BUILD.bazel
+++ b/compiler/src/iree/compiler/Tools/BUILD.bazel
@@ -26,26 +26,6 @@
)
iree_compiler_cc_library(
- name = "init_input_passes_and_dialects",
- srcs = [
- "init_input_dialects.cc",
- "init_input_passes.cc",
- ],
- hdrs = [
- "init_input_dialects.h",
- "init_input_passes.h",
- ],
- deps = [
- "//compiler/src/iree/compiler/InputConversion/Common",
- "//compiler/src/iree/compiler/InputConversion/StableHLO",
- "@llvm-project//mlir:ConversionPasses",
- "@llvm-project//mlir:IR",
- "@stablehlo//:chlo_ops",
- "@stablehlo//:stablehlo_ops",
- ],
-)
-
-iree_compiler_cc_library(
name = "init_iree_passes_and_dialects",
hdrs = [
"init_iree_dialects.h",
@@ -73,6 +53,7 @@
"//compiler/src/iree/compiler/Dialect/VMVX/IR:VMVXDialect",
"//compiler/src/iree/compiler/Dialect/VMVX/Transforms",
"//compiler/src/iree/compiler/Dialect/Vulkan/IR",
+ "//compiler/src/iree/compiler/InputConversion/Common",
"//compiler/src/iree/compiler/Modules/HAL/Inline/IR:HALInlineDialect",
"//compiler/src/iree/compiler/Modules/HAL/Inline/Transforms",
"//compiler/src/iree/compiler/Modules/HAL/Loader/IR:HALLoaderDialect",
@@ -140,7 +121,6 @@
],
deps = [
":init_compiler_modules",
- ":init_input_passes_and_dialects",
":init_iree_passes_and_dialects",
":init_mlir_passes_and_dialects",
"//compiler/src/iree/compiler/Codegen",
diff --git a/compiler/src/iree/compiler/Tools/CMakeLists.txt b/compiler/src/iree/compiler/Tools/CMakeLists.txt
index 61a1609..475a06f 100644
--- a/compiler/src/iree/compiler/Tools/CMakeLists.txt
+++ b/compiler/src/iree/compiler/Tools/CMakeLists.txt
@@ -40,29 +40,6 @@
list(APPEND IREE_VERSION_TARGET_COPTS "-DIREE_RELEASE_VERSION=\"${IREE_RELEASE_VERSION}\"")
endif()
-# Enable input dialects based on options.
-set(IREE_INPUT_DEPS "")
-if(IREE_INPUT_STABLEHLO)
- list(APPEND IREE_INPUT_DEPS iree::compiler::InputConversion::StableHLO)
- list(APPEND IREE_INPUT_DEPS ChloOps)
- list(APPEND IREE_INPUT_DEPS StablehloOps)
-endif()
-
-iree_cc_library(
- NAME
- init_input_passes_and_dialects
- HDRS
- "init_input_dialects.h"
- "init_input_passes.h"
- SRCS
- "init_input_dialects.cc"
- "init_input_passes.cc"
- DEPS
- ${IREE_INPUT_DEPS}
- iree::compiler::InputConversion::Common
- PUBLIC
-)
-
iree_cc_library(
NAME
init_iree_passes_and_dialects
@@ -98,6 +75,7 @@
iree::compiler::Dialect::VMVX::IR::VMVXDialect
iree::compiler::Dialect::VMVX::Transforms
iree::compiler::Dialect::Vulkan::IR
+ iree::compiler::InputConversion::Common
iree::compiler::Modules::HAL::Inline::IR::HALInlineDialect
iree::compiler::Modules::HAL::Inline::Transforms
iree::compiler::Modules::HAL::Loader::IR::HALLoaderDialect
@@ -154,7 +132,6 @@
"init_passes.h"
DEPS
::init_compiler_modules
- ::init_input_passes_and_dialects
::init_iree_passes_and_dialects
::init_mlir_passes_and_dialects
iree::compiler::Codegen::Codegen
diff --git a/compiler/src/iree/compiler/Tools/init_dialects.h b/compiler/src/iree/compiler/Tools/init_dialects.h
index 62fb776..c8f294b 100644
--- a/compiler/src/iree/compiler/Tools/init_dialects.h
+++ b/compiler/src/iree/compiler/Tools/init_dialects.h
@@ -13,7 +13,6 @@
#define IREE_COMPILER_TOOLS_INIT_DIALECTS_H_
#include "iree/compiler/Tools/init_compiler_modules.h"
-#include "iree/compiler/Tools/init_input_dialects.h"
#include "iree/compiler/Tools/init_iree_dialects.h"
#include "iree/compiler/Tools/init_mlir_dialects.h"
@@ -22,7 +21,6 @@
inline void registerAllDialects(DialectRegistry ®istry) {
registerMlirDialects(registry);
- registerInputDialects(registry);
registerIreeDialects(registry);
mlir::iree_compiler::registerIreeCompilerModuleDialects(registry);
diff --git a/compiler/src/iree/compiler/Tools/init_input_dialects.cc b/compiler/src/iree/compiler/Tools/init_input_dialects.cc
deleted file mode 100644
index 2ab2f7c..0000000
--- a/compiler/src/iree/compiler/Tools/init_input_dialects.cc
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright 2022 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
-
-#include "iree/compiler/Tools/init_input_dialects.h"
-
-#ifdef IREE_HAVE_STABLEHLO_INPUT
-#include "stablehlo/dialect/ChloOps.h"
-#include "stablehlo/dialect/StablehloOps.h"
-#endif // IREE_HAVE_STABLEHLO_INPUT
-
-namespace mlir {
-namespace iree_compiler {
-
-void registerInputDialects(DialectRegistry ®istry) {
-#ifdef IREE_HAVE_STABLEHLO_INPUT
- registry.insert<mlir::chlo::ChloDialect, mlir::stablehlo::StablehloDialect>();
-#endif // IREE_HAVE_STABLEHLO_INPUT
-}
-
-} // namespace iree_compiler
-} // namespace mlir
diff --git a/compiler/src/iree/compiler/Tools/init_input_dialects.h b/compiler/src/iree/compiler/Tools/init_input_dialects.h
deleted file mode 100644
index d4d2957..0000000
--- a/compiler/src/iree/compiler/Tools/init_input_dialects.h
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2022 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
-
-// This files defines a helper to trigger the registration of dialects to
-// the system.
-//
-// Based on MLIR's InitAllDialects but for IREE input dialects.
-
-#ifndef IREE_COMPILER_TOOLS_INIT_INPUT_DIALECTS_H_
-#define IREE_COMPILER_TOOLS_INIT_INPUT_DIALECTS_H_
-
-#include "mlir/IR/Dialect.h"
-
-namespace mlir {
-namespace iree_compiler {
-
-void registerInputDialects(DialectRegistry ®istry);
-
-} // namespace iree_compiler
-} // namespace mlir
-
-#endif // IREE_COMPILER_TOOLS_INIT_INPUT_DIALECTS_H_
diff --git a/compiler/src/iree/compiler/Tools/init_input_passes.cc b/compiler/src/iree/compiler/Tools/init_input_passes.cc
deleted file mode 100644
index 1259d2c..0000000
--- a/compiler/src/iree/compiler/Tools/init_input_passes.cc
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2022 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
-
-#include "iree/compiler/Tools/init_input_passes.h"
-
-#include "iree/compiler/InputConversion/Common/Passes.h"
-
-#ifdef IREE_HAVE_STABLEHLO_INPUT
-#include "iree/compiler/InputConversion/StableHLO/Passes.h"
-#endif // IREE_HAVE_STABLEHLO_INPUT
-
-namespace mlir {
-namespace iree_compiler {
-
-void registerInputPasses() {
- registerCommonInputConversionPasses();
-
-#ifdef IREE_HAVE_STABLEHLO_INPUT
- stablehlo::registerStableHLOConversionPasses();
-#endif // IREE_HAVE_STABLEHLO_INPUT
-}
-
-} // namespace iree_compiler
-} // namespace mlir
diff --git a/compiler/src/iree/compiler/Tools/init_input_passes.h b/compiler/src/iree/compiler/Tools/init_input_passes.h
deleted file mode 100644
index ae338c2..0000000
--- a/compiler/src/iree/compiler/Tools/init_input_passes.h
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright 2022 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
-
-// This file defines a helper to trigger the registration of passes to
-// the system.
-//
-// Based on MLIR's InitAllPasses but for IREE input passes.
-
-#ifndef IREE_COMPILER_TOOLS_INIT_INPUT_PASSES_H_
-#define IREE_COMPILER_TOOLS_INIT_INPUT_PASSES_H_
-
-namespace mlir {
-namespace iree_compiler {
-
-// Registers IREE input conversion passes with the global registry.
-void registerInputPasses();
-
-} // namespace iree_compiler
-} // namespace mlir
-
-#endif // IREE_COMPILER_TOOLS_INIT_INPUT_PASSES_H_
diff --git a/compiler/src/iree/compiler/Tools/init_iree_passes.h b/compiler/src/iree/compiler/Tools/init_iree_passes.h
index 784143f..46ac342 100644
--- a/compiler/src/iree/compiler/Tools/init_iree_passes.h
+++ b/compiler/src/iree/compiler/Tools/init_iree_passes.h
@@ -26,6 +26,7 @@
#include "iree/compiler/Dialect/VM/Transforms/Passes.h"
#include "iree/compiler/Dialect/VMVX/Transforms/Passes.h"
#include "iree/compiler/GlobalOptimization/Passes.h"
+#include "iree/compiler/InputConversion/Common/Passes.h"
#include "iree/compiler/Modules/HAL/Inline/Transforms/Passes.h"
#include "iree/compiler/Modules/HAL/Loader/Transforms/Passes.h"
#include "iree/compiler/Pipelines/Pipelines.h"
@@ -47,6 +48,7 @@
IREE::TFLite::registerPasses();
IREE::TFLite::registerTransformPassPipeline();
+ registerCommonInputConversionPasses();
ConstEval::registerConstEvalPasses();
GlobalOptimization::registerGlobalOptimizationPipeline();
IREE::Flow::registerFlowPasses();
diff --git a/compiler/src/iree/compiler/Tools/init_passes.h b/compiler/src/iree/compiler/Tools/init_passes.h
index b8ea190..3d49ac5 100644
--- a/compiler/src/iree/compiler/Tools/init_passes.h
+++ b/compiler/src/iree/compiler/Tools/init_passes.h
@@ -13,7 +13,6 @@
#include "iree/compiler/Codegen/Passes.h"
#include "iree/compiler/Dialect/HAL/Conversion/Passes.h"
-#include "iree/compiler/Tools/init_input_passes.h"
#include "iree/compiler/Tools/init_iree_passes.h"
#include "iree/compiler/Tools/init_mlir_passes.h"
@@ -24,7 +23,6 @@
inline void registerAllPasses() {
registerAllIreePasses();
registerCodegenPasses();
- registerInputPasses();
registerMlirPasses();
registerHALConversionPasses();
}