From 94968e6cbc203eee47def9950e54b701966e519f Mon Sep 17 00:00:00 2001 From: Jacques Pienaar Date: Mon, 19 Aug 2024 14:42:11 -0700 Subject: [PATCH] [tosa] Make legalization pass operate top-down Some of these patterns, e.g., the reduce conversion one, assumes that the reduce op is converted before the body. But this wasn't required/enforced. --- .../conversions/tosa/transforms/StablehloLegalizeToTosa.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/stablehlo/conversions/tosa/transforms/StablehloLegalizeToTosa.cpp b/stablehlo/conversions/tosa/transforms/StablehloLegalizeToTosa.cpp index c582693a4af..91d7c047b5c 100644 --- a/stablehlo/conversions/tosa/transforms/StablehloLegalizeToTosa.cpp +++ b/stablehlo/conversions/tosa/transforms/StablehloLegalizeToTosa.cpp @@ -508,7 +508,9 @@ LogicalResult StablehloLegalizeToTosaPass::initialize(MLIRContext* ctx) { } void StablehloLegalizeToTosaPass::runOnOperation() { - (void)applyPatternsAndFoldGreedily(getOperation(), patterns); + GreedyRewriteConfig config; + config.useTopDownTraversal = true; + (void)applyPatternsAndFoldGreedily(getOperation(), patterns, config); } } // namespace