Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chlo decompose patterns #1984

Merged
merged 9 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,22 @@ cc_library(
],
)

gentbl_cc_library(
name = "chlo_rewriters_inc_gen",
tbl_outs = [
(
["--gen-rewriters"],
"stablehlo/transforms/ChloDecompositionPatterns.h.inc",
),
],
tblgen = "@llvm-project//mlir:mlir-tblgen",
td_file = "stablehlo/transforms/ChloDecompositionPatterns.td",
deps = [
":chlo_ops_td_files",
":stablehlo_ops_td_files",
],
)

cc_library(
name = "interpreter_ops",
srcs = [
Expand Down Expand Up @@ -909,7 +925,9 @@ gentbl_cc_library(
cc_library(
name = "stablehlo_passes",
srcs = [
"stablehlo/transforms/ChloLegalizeToStablehlo.cpp",
"stablehlo/transforms/PassPipelines.cpp",
"stablehlo/transforms/StablehloAggressiveSimplification.cpp",
"stablehlo/transforms/StablehloCanonicalizeDynamism.cpp",
"stablehlo/transforms/StablehloInstrumentWithProbe.cpp",
"stablehlo/transforms/StablehloLegalizeToVhlo.cpp",
Expand All @@ -929,13 +947,18 @@ cc_library(
":interpreter_ops",
":stablehlo_ops",
":stablehlo_ops_inc_gen",
":broadcast_utils",
":chlo_rewriters_inc_gen",
GleasonK marked this conversation as resolved.
Show resolved Hide resolved
":stablehlo_pass_inc_gen",
":stablehlo_type_inference",
":version",
":vhlo_ops",
":vhlo_types",
"@llvm-project//llvm:Support",
"@llvm-project//mlir:CommonFolders",
"@llvm-project//mlir:ComplexDialect",
"@llvm-project//mlir:FuncDialect",
"@llvm-project//mlir:FunctionInterfaces",
"@llvm-project//mlir:IR",
"@llvm-project//mlir:InferTypeOpInterface",
"@llvm-project//mlir:Pass",
Expand Down
15 changes: 9 additions & 6 deletions stablehlo/transforms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,36 +18,39 @@ add_public_tablegen_target(PassesIncGen)

set(LLVM_TARGET_DEFINITIONS ChloDecompositionPatterns.td)
linuxlonelyeagle marked this conversation as resolved.
Show resolved Hide resolved
mlir_tablegen(ChloDecompositionPatterns.h.inc --gen-rewriters)
add_public_tablegen_target(ChloDecompositionPatterns)
add_public_tablegen_target(ChloDecompositionPatternsIncGen)

add_mlir_dialect_library(StablehloPasses
PARTIAL_SOURCES_INTENDED
ChloLegalizeToStablehlo.cpp
PassPipelines.cpp
StablehloAggressiveSimplification.cpp
StablehloCanonicalizeDynamism.cpp
StablehloInstrumentWithProbe.cpp
StablehloLegalizeToVhlo.cpp
StablehloRefineShapes.cpp
VhloLegalizeToStablehlo.cpp
VhloToVersion.cpp
ChloLegalizeToStablehlo.cpp
StablehloAggressiveSimplification.cpp


DEPENDS
ChloDecompositionPatternsIncGen
PassesIncGen
ChloDecompositionPatterns

LINK_LIBS PUBLIC
ChloOps
InterpreterOps
MLIRComplexDialect
MLIRFuncDialect
MLIRFunctionInterfaces
MLIRIR
MLIRInferTypeOpInterface
MLIRQuantDialect
MLIRSupport
MLIRTensorDialect
MLIRTransformUtils
StablehloBase
StablehloTypeInference
StablehloBroadcastUtils
StablehloOps
StablehloTypeInference
VhloOps
)
6 changes: 2 additions & 4 deletions stablehlo/transforms/ChloLegalizeToStablehlo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

#include "llvm/ADT/STLExtras.h"
#include "mlir/Dialect/Complex/IR/Complex.h"
#include "mlir/Dialect/SCF/IR/SCF.h"
#include "mlir/Dialect/Shape/IR/Shape.h"
#include "mlir/Dialect/Tensor/IR/Tensor.h"
#include "mlir/IR/BuiltinTypes.h"
Expand Down Expand Up @@ -2164,7 +2163,7 @@ struct ConvertZetaOp final : OpConversionPattern<mlir::chlo::ZetaOp> {
struct ChloLegalizeToStablehloPass final
: impl::ChloLegalizeToStablehloPassBase<ChloLegalizeToStablehloPass> {
void getDependentDialects(DialectRegistry &registry) const override {
registry.insert<mlir::scf::SCFDialect, mlir::shape::ShapeDialect,
registry.insert<mlir::shape::ShapeDialect,
mlir::stablehlo::StablehloDialect,
mlir::tensor::TensorDialect>();
}
Expand All @@ -2178,8 +2177,7 @@ struct ChloLegalizeToStablehloPass final
conversionTarget.addLegalOp<chlo::MinimumBroadcastShapesOp>();
conversionTarget.addLegalDialect<
mlir::stablehlo::StablehloDialect, mlir::arith::ArithDialect,
mlir::shape::ShapeDialect, mlir::scf::SCFDialect,
mlir::tensor::TensorDialect>();
mlir::shape::ShapeDialect, mlir::tensor::TensorDialect>();

populateChloToStablehloPatterns(ctx, &conversionPatterns);
if (failed(applyPartialConversion(getOperation(), conversionTarget,
Expand Down
Loading