Skip to content

Commit

Permalink
[StableHLO][CHLO] Port CHLO decomposition patterns
Browse files Browse the repository at this point in the history
These are ported from the mlir-hlo project. For more context, see the
initial import: iree-org#12957.

The biggest difference it the removal of most FileCheck CHECK lines in
tests. MHLO hardcoded thousands lines of exact decomposition sequences
that fell apart after due to different canonicalizations and folds.
Without a script to regenerate these CHECKs, these tests were not
maintanable and I decided to drop them. Now we only check that the
dialect conversion succeeded.

Other notable differences to the MHLO implementation:
-  Ported some utility functions and tablegen defs.
-  New `chlo.tan` lowering, since StableHLO does not provide a tan op.

Issue: iree-org#13803
  • Loading branch information
kuhar committed May 30, 2023
1 parent b218383 commit a7bee2c
Show file tree
Hide file tree
Showing 9 changed files with 2,730 additions and 52 deletions.
18 changes: 18 additions & 0 deletions compiler/src/iree/compiler/InputConversion/StableHLO/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,23 @@ iree_compiler_cc_library(
],
)

iree_gentbl_cc_library(
name = "CHLODecompositionPatterns",
tbl_outs = [
(
["--gen-rewriters"],
"CHLODecompositionPatterns.h.inc",
),
],
tblgen = "@llvm-project//mlir:mlir-tblgen",
td_file = "CHLODecompositionPatterns.td",
deps = [
"@llvm-project//mlir:ShapeTdFiles",
"@mlir-hlo//stablehlo:chlo_ops_td_files",
"@mlir-hlo//stablehlo:stablehlo_ops_td_files",
],
)

iree_compiler_cc_library(
name = "StableHLOLegalization",
srcs = [
Expand All @@ -66,6 +83,7 @@ iree_compiler_cc_library(
"VerifyCompilerInputLegality.cpp",
],
deps = [
":CHLODecompositionPatterns",
":PassHeaders",
"//compiler/src/iree/compiler/Dialect/Flow/IR",
"//compiler/src/iree/compiler/Dialect/Util/IR",
Expand Down
Loading

0 comments on commit a7bee2c

Please sign in to comment.