Skip to content

Commit 955520c

Browse files
committed
chore: optionally enalbe these passes
1 parent e5a7a50 commit 955520c

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/Compiler.jl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,7 @@ function optimization_passes(
701701
recognize_comms::Bool=true,
702702
lower_comms::Bool=true,
703703
max_constant_threshold::Int=1024,
704+
backend::String="gpu",
704705
)
705706
transform_passes_list = [
706707
"patterns=compare_op_canon<16>",
@@ -902,9 +903,9 @@ function optimization_passes(
902903
# "compare_mul",
903904
"compare_convert",
904905
"add_selects",
905-
"self_subtract_to_convolution_like",
906-
"self_add_to_convolution_like",
907-
"self_mul_to_convolution_like",
906+
"self_subtract_to_convolution_like($(backend == "tpu"))",
907+
"self_add_to_convolution_like($(backend == "tpu"))",
908+
"self_mul_to_convolution_like($(backend == "tpu"))",
908909
"subtract_multiply_const_to_add_mul_const",
909910
]
910911

@@ -1630,10 +1631,10 @@ function compile_mlir!(
16301631
end
16311632

16321633
opt_passes = optimization_passes(
1633-
compile_options; sroa=true, recognize_comms, lower_comms
1634+
compile_options; sroa=true, recognize_comms, lower_comms, backend
16341635
)
16351636
opt_passes2 = optimization_passes(
1636-
compile_options; sroa=false, recognize_comms, lower_comms
1637+
compile_options; sroa=false, recognize_comms, lower_comms, backend
16371638
)
16381639

16391640
raise_passes = if raise isa String
@@ -1654,6 +1655,7 @@ function compile_mlir!(
16541655
dus_to_concat=true,
16551656
recognize_comms,
16561657
lower_comms,
1658+
backend
16571659
)
16581660
result = result * "," * opt_passes3
16591661
end
@@ -1943,6 +1945,7 @@ function compile_mlir!(
19431945
Reactant.__compile_options_with_reversed_propagation(compile_options);
19441946
recognize_comms,
19451947
lower_comms,
1948+
backend
19461949
),
19471950
"post_op_transpose_reshape",
19481951
)

0 commit comments

Comments
 (0)