From b06baae910b6f66938169b258a1013a732591feb Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Fri, 14 May 2021 12:56:46 -0700 Subject: [PATCH] Fixing nondeterminism in pattern application. The ReduceRegion* patterns are matching on the same ops as the PointwiseToLinalg* patterns and on certain toolchains (MSVC) the order can be wrong. If the pointwise runs first then it converts the op *within* the reduction before the reduction one runs, leading to nested linalg op weirdness. PiperOrigin-RevId: 373848269 --- lib/Dialect/mhlo/transforms/legalize_to_linalg.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Dialect/mhlo/transforms/legalize_to_linalg.cc b/lib/Dialect/mhlo/transforms/legalize_to_linalg.cc index d74994f..bd1cb53 100644 --- a/lib/Dialect/mhlo/transforms/legalize_to_linalg.cc +++ b/lib/Dialect/mhlo/transforms/legalize_to_linalg.cc @@ -2354,7 +2354,8 @@ void populateHLOToLinalgConversionPattern(MLIRContext* context, ReduceRegionXLAOpConversion, ReduceRegionXLAOpConversion, ReduceRegionXLAOpConversion, - ReduceRegionReturnOpConversion>(context); + ReduceRegionReturnOpConversion>(context, + PatternBenefit(1000)); } std::unique_ptr> createLegalizeHloToLinalgPass() {