Skip to content

Commit af8ba04

Browse files
authored
fixes #2751
1 parent 8855028 commit af8ba04

File tree

8 files changed

+43
-46
lines changed

8 files changed

+43
-46
lines changed

BUILD.bazel

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,9 +1578,8 @@ cc_library(
15781578
srcs = [
15791579
"stablehlo/conversions/tosa/transforms/StablehloLegalizeToTosa.cpp",
15801580
"stablehlo/conversions/tosa/transforms/StablehloPrepareForTosa.cpp",
1581-
# TODO: un-comment the following once #2751 is fixed
1582-
# "stablehlo/conversions/tosa/transforms/StablehloQuantLegalizeToTosaRescale.cpp",
1583-
# "stablehlo/conversions/tosa/transforms/TosaRescaleLegalizeToStablehlo.cpp",
1581+
"stablehlo/conversions/tosa/transforms/StablehloQuantLegalizeToTosaRescale.cpp",
1582+
"stablehlo/conversions/tosa/transforms/TosaRescaleLegalizeToStablehlo.cpp",
15841583
],
15851584
hdrs = [
15861585
"stablehlo/conversions/tosa/transforms/Passes.h",

WORKSPACE.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ workspace(name = "stablehlo")
1717

1818
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
1919

20-
LLVM_COMMIT = "0230d63b4a8b9f420b0aaac373891df1199715a8"
20+
LLVM_COMMIT = "dd3addf954ac7e704fccc7d011217ba10461c883"
2121

22-
LLVM_SHA256 = "27641dbb2ee0fecb6f084a4300b0c27ac692c2d1214fad236dc5e19dd7962693"
22+
LLVM_SHA256 = "f2f7ef9a6eb597b8a53186878122269d673fca742470f3bdb5bac18a47e9b8be"
2323

2424
http_archive(
2525
name = "llvm-raw",

build_tools/llvm_version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0230d63b4a8b9f420b0aaac373891df1199715a8
1+
dd3addf954ac7e704fccc7d011217ba10461c883

docs/generated/stablehlo_tosa_passes.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,17 @@ _Prepare StableHLO for legalization to TOSA_
1010

1111
This pass adds rewriters to make StableHLO ops more compatible with TOSA ops.
1212
Currently simplifies stablehlo.dot_general into stablehlo.dot for easier lowering.
13+
14+
### `-stablehlo-quant-legalize-to-tosa-rescale`
15+
16+
_Legalize StableHLO Quantized operations to TOSA rescale operations_
17+
18+
This pass rewrites StableHLO quantized operations to integer operations
19+
by inserting TOSA rescale operations at the inputs and outputs of the
20+
integer operations.
21+
22+
### `-tosa-rescale-legalize-to-stablehlo`
23+
24+
_Legalize TOSA rescales to StableHlo primitive math operations_
25+
26+
This pass rewrites TOSA rescale operations to StableHLO primitive math operations.

stablehlo/conversions/tosa/tests/BUILD.bazel

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,7 @@ RUNFILES_DIR = LITE_CFG_PY.parents[4].absolute().as_posix()''',
5555
tags = ["stablehlo_tosa_tests"],
5656
deps = ["@rules_python//python/runfiles"],
5757
)
58-
# TODO: remove the following excludes once #2751 is fixed.
59-
for src in glob(
60-
["**/*.mlir"],
61-
exclude = [
62-
"legalize_quant_ops_to_tosa_rescale.mlir",
63-
"legalize_tosa_rescale_to_stablehlo.mlir",
64-
"rescale_interpreter.mlir",
65-
"binary.mlir",
66-
"nullary.mlir",
67-
"unary.mlir",
68-
],
69-
)
58+
for src in glob(["**/*.mlir"])
7059
]
7160

7261
test_suite(

stablehlo/conversions/tosa/tests/lit.cfg.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
2626
config.suffixes = ['.mlir']
2727
config.test_source_root = os.path.dirname(__file__)
28-
# TODO: remove the following once #2751 is fixed.
29-
config.excludes = ['legalize_quant_ops_to_tosa_rescale.mlir', 'legalize_tosa_rescale_to_stablehlo.mlir', 'rescale_interpreter.mlir', 'binary.mlir', 'nullary.mlir', 'unary.mlir']
3028

3129
# Disallow reusing variables across CHECK-LABEL matches.
3230
# A variable can eschew this (be made "global") by prefixing its name with $.

stablehlo/conversions/tosa/transforms/CMakeLists.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,9 @@ add_mlir_pdll_library(StablehloTOSAPDLLPatternsIncGen
2525
add_mlir_library(StablehloTOSATransforms
2626
StablehloLegalizeToTosa.cpp
2727
StablehloPrepareForTosa.cpp
28-
# TODO: un-comment the following once #2751 is fixed.
29-
# StablehloQuantLegalizeToTosaRescale.cpp
30-
# TosaRescaleLegalizeToStablehlo.cpp
28+
StablehloQuantLegalizeToTosaRescale.cpp
29+
TosaRescaleLegalizeToStablehlo.cpp
3130

32-
PARTIAL_SOURCES_INTENDED
3331
DEPENDS
3432
StablehloTOSATransformsPassIncGen
3533
StablehloTOSAPDLLPatternsIncGen

stablehlo/conversions/tosa/transforms/Passes.td

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,24 @@ def StablehloPrepareForTosaPass : Pass<"stablehlo-prepare-for-tosa", "mlir::func
3333
let dependentDialects = ["::mlir::tosa::TosaDialect"];
3434
}
3535

36-
// TODO: un-comment the following once #2751 is fixed.
37-
// def StablehloQuantLegalizeToTosaRescalePass : Pass<"stablehlo-quant-legalize-to-tosa-rescale", "mlir::func::FuncOp"> {
38-
// let summary = "Legalize StableHLO Quantized operations to TOSA rescale operations";
39-
// let description = [{
40-
// This pass rewrites StableHLO quantized operations to integer operations
41-
// by inserting TOSA rescale operations at the inputs and outputs of the
42-
// integer operations.
43-
// }];
44-
// let dependentDialects = [
45-
// "::mlir::tosa::TosaDialect",
46-
// ];
47-
// }
48-
//
49-
// def TosaRescaleLegalizeToStablehloPass : Pass<"tosa-rescale-legalize-to-stablehlo", "mlir::func::FuncOp"> {
50-
// let summary = "Legalize TOSA rescales to StableHlo primitive math operations";
51-
// let description = [{
52-
// This pass rewrites TOSA rescale operations to StableHLO primitive math operations.
53-
// }];
54-
// let dependentDialects = [
55-
// "::mlir::stablehlo::StablehloDialect"
56-
// ];
57-
// }
36+
def StablehloQuantLegalizeToTosaRescalePass : Pass<"stablehlo-quant-legalize-to-tosa-rescale", "mlir::func::FuncOp"> {
37+
let summary = "Legalize StableHLO Quantized operations to TOSA rescale operations";
38+
let description = [{
39+
This pass rewrites StableHLO quantized operations to integer operations
40+
by inserting TOSA rescale operations at the inputs and outputs of the
41+
integer operations.
42+
}];
43+
let dependentDialects = [
44+
"::mlir::tosa::TosaDialect",
45+
];
46+
}
47+
48+
def TosaRescaleLegalizeToStablehloPass : Pass<"tosa-rescale-legalize-to-stablehlo", "mlir::func::FuncOp"> {
49+
let summary = "Legalize TOSA rescales to StableHlo primitive math operations";
50+
let description = [{
51+
This pass rewrites TOSA rescale operations to StableHLO primitive math operations.
52+
}];
53+
let dependentDialects = [
54+
"::mlir::stablehlo::StablehloDialect"
55+
];
56+
}

0 commit comments

Comments
 (0)