[all-commits] [llvm/llvm-project] 09dfc5: [mlir] Enable decoupling two kinds of greedy behav...

Jacques Pienaar via All-commits all-commits at lists.llvm.org
Fri Dec 20 08:16:11 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 09dfc5713d7e2342bea4c8447d1ed76c85eb8225
      https://github.com/llvm/llvm-project/commit/09dfc5713d7e2342bea4c8447d1ed76c85eb8225
  Author: Jacques Pienaar <jpienaar at google.com>
  Date:   2024-12-20 (Fri, 20 Dec 2024)

  Changed paths:
    M flang/lib/Optimizer/HLFIR/Transforms/InlineElementals.cpp
    M flang/lib/Optimizer/HLFIR/Transforms/LowerHLFIRIntrinsics.cpp
    M flang/lib/Optimizer/HLFIR/Transforms/OptimizedBufferization.cpp
    M flang/lib/Optimizer/HLFIR/Transforms/SimplifyHLFIRIntrinsics.cpp
    M flang/lib/Optimizer/Transforms/AlgebraicSimplification.cpp
    M flang/lib/Optimizer/Transforms/AssumedRankOpConversion.cpp
    M flang/lib/Optimizer/Transforms/ConstantArgumentGlobalisation.cpp
    M flang/lib/Optimizer/Transforms/StackArrays.cpp
    M mlir/docs/PatternRewriter.md
    M mlir/examples/standalone/lib/Standalone/StandalonePasses.cpp
    M mlir/include/mlir/Transforms/GreedyPatternRewriteDriver.h
    M mlir/lib/CAPI/Transforms/Rewrite.cpp
    M mlir/lib/Conversion/ArithToAMDGPU/ArithToAMDGPU.cpp
    M mlir/lib/Conversion/ArithToArmSME/ArithToArmSME.cpp
    M mlir/lib/Conversion/ArmNeon2dToIntr/ArmNeon2dToIntr.cpp
    M mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
    M mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp
    M mlir/lib/Conversion/MeshToMPI/MeshToMPI.cpp
    M mlir/lib/Conversion/ShapeToStandard/ConvertShapeConstraints.cpp
    M mlir/lib/Conversion/VectorToArmSME/VectorToArmSMEPass.cpp
    M mlir/lib/Conversion/VectorToGPU/VectorToGPU.cpp
    M mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.cpp
    M mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp
    M mlir/lib/Conversion/VectorToXeGPU/VectorToXeGPU.cpp
    M mlir/lib/Dialect/Affine/TransformOps/AffineTransformOps.cpp
    M mlir/lib/Dialect/Affine/Transforms/AffineDataCopyGeneration.cpp
    M mlir/lib/Dialect/Affine/Transforms/AffineExpandIndexOps.cpp
    M mlir/lib/Dialect/Affine/Transforms/AffineExpandIndexOpsAsAffine.cpp
    M mlir/lib/Dialect/Affine/Transforms/SimplifyAffineStructures.cpp
    M mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp
    M mlir/lib/Dialect/Affine/Utils/Utils.cpp
    M mlir/lib/Dialect/Arith/Transforms/IntRangeOptimizations.cpp
    M mlir/lib/Dialect/ArmSME/Transforms/OuterProductFusion.cpp
    M mlir/lib/Dialect/ArmSVE/Transforms/LegalizeVectorStorage.cpp
    M mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp
    M mlir/lib/Dialect/Bufferization/Transforms/BufferDeallocationSimplification.cpp
    M mlir/lib/Dialect/Bufferization/Transforms/EmptyTensorToAllocTensor.cpp
    M mlir/lib/Dialect/EmitC/Transforms/FormExpressions.cpp
    M mlir/lib/Dialect/GPU/Transforms/DecomposeMemRefs.cpp
    M mlir/lib/Dialect/GPU/Transforms/EliminateBarriers.cpp
    M mlir/lib/Dialect/LLVMIR/Transforms/OptimizeForNVVM.cpp
    M mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
    M mlir/lib/Dialect/Linalg/Transforms/BlockPackMatmul.cpp
    M mlir/lib/Dialect/Linalg/Transforms/Detensorize.cpp
    M mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp
    M mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp
    M mlir/lib/Dialect/Linalg/Transforms/Generalization.cpp
    M mlir/lib/Dialect/Linalg/Transforms/InlineScalarOperands.cpp
    M mlir/lib/Dialect/Linalg/Transforms/Loops.cpp
    M mlir/lib/Dialect/Linalg/Transforms/NamedOpConversions.cpp
    M mlir/lib/Dialect/Linalg/Transforms/Specialize.cpp
    M mlir/lib/Dialect/Math/Transforms/UpliftToFMA.cpp
    M mlir/lib/Dialect/MemRef/Transforms/ExpandStridedMetadata.cpp
    M mlir/lib/Dialect/MemRef/Transforms/FoldMemRefAliasOps.cpp
    M mlir/lib/Dialect/MemRef/Transforms/ResolveShapedTypeResultDims.cpp
    M mlir/lib/Dialect/SCF/Transforms/ForToWhile.cpp
    M mlir/lib/Dialect/SCF/Transforms/LoopCanonicalization.cpp
    M mlir/lib/Dialect/SCF/Transforms/LoopSpecialization.cpp
    M mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp
    M mlir/lib/Dialect/SPIRV/Transforms/CanonicalizeGLPass.cpp
    M mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp
    M mlir/lib/Dialect/SPIRV/Transforms/SPIRVWebGPUTransforms.cpp
    M mlir/lib/Dialect/Shape/Transforms/OutlineShapeComputation.cpp
    M mlir/lib/Dialect/Shape/Transforms/RemoveShapeConstraints.cpp
    M mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorPasses.cpp
    M mlir/lib/Dialect/Tensor/Transforms/FoldTensorSubsetOps.cpp
    M mlir/lib/Dialect/Tosa/Transforms/TosaLayerwiseConstantFoldPass.cpp
    M mlir/lib/Dialect/Tosa/Transforms/TosaMakeBroadcastable.cpp
    M mlir/lib/Dialect/Tosa/Transforms/TosaOptionalDecompositions.cpp
    M mlir/lib/Dialect/Transform/IR/TransformOps.cpp
    M mlir/lib/Dialect/Vector/Transforms/LowerVectorMask.cpp
    M mlir/lib/Dialect/Vector/Transforms/LowerVectorMultiReduction.cpp
    M mlir/lib/Dialect/XeGPU/Transforms/XeGPUFoldAliasOps.cpp
    M mlir/lib/Reducer/ReductionTreePass.cpp
    M mlir/lib/Transforms/Canonicalizer.cpp
    M mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp
    M mlir/lib/Transforms/Utils/OneToNTypeConversion.cpp
    M mlir/test/Transforms/test-operation-folder.mlir
    M mlir/test/lib/Conversion/MathToVCIX/TestMathToVCIXConversion.cpp
    M mlir/test/lib/Conversion/VectorToSPIRV/TestVectorReductionToSPIRVDotProd.cpp
    M mlir/test/lib/Dialect/Affine/TestAffineDataCopy.cpp
    M mlir/test/lib/Dialect/ArmNeon/TestLowerToArmNeon.cpp
    M mlir/test/lib/Dialect/GPU/TestGpuRewrite.cpp
    M mlir/test/lib/Dialect/Linalg/TestDataLayoutPropagation.cpp
    M mlir/test/lib/Dialect/Linalg/TestLinalgDecomposeOps.cpp
    M mlir/test/lib/Dialect/Linalg/TestLinalgElementwiseFusion.cpp
    M mlir/test/lib/Dialect/Linalg/TestLinalgFusionTransforms.cpp
    M mlir/test/lib/Dialect/Linalg/TestLinalgRankReduceContractionOps.cpp
    M mlir/test/lib/Dialect/Linalg/TestLinalgTransforms.cpp
    M mlir/test/lib/Dialect/Linalg/TestPadFusion.cpp
    M mlir/test/lib/Dialect/Math/TestAlgebraicSimplification.cpp
    M mlir/test/lib/Dialect/Math/TestExpandMath.cpp
    M mlir/test/lib/Dialect/Math/TestPolynomialApproximation.cpp
    M mlir/test/lib/Dialect/MemRef/TestComposeSubView.cpp
    M mlir/test/lib/Dialect/Mesh/TestOpLowering.cpp
    M mlir/test/lib/Dialect/Mesh/TestReshardingSpmdization.cpp
    M mlir/test/lib/Dialect/Mesh/TestSimplifications.cpp
    M mlir/test/lib/Dialect/NVGPU/TestNVGPUTransforms.cpp
    M mlir/test/lib/Dialect/SCF/TestSCFUtils.cpp
    M mlir/test/lib/Dialect/SCF/TestSCFWrapInZeroTripCheck.cpp
    M mlir/test/lib/Dialect/SCF/TestUpliftWhileToFor.cpp
    M mlir/test/lib/Dialect/Tensor/TestTensorTransforms.cpp
    M mlir/test/lib/Dialect/Test/TestPatterns.cpp
    M mlir/test/lib/Dialect/Test/TestTraits.cpp
    M mlir/test/lib/Dialect/Tosa/TosaTestPasses.cpp
    M mlir/test/lib/Dialect/Vector/TestVectorTransforms.cpp
    M mlir/test/lib/Rewrite/TestPDLByteCode.cpp
    M mlir/test/lib/Tools/PDLL/TestPDLL.cpp
    M mlir/test/lib/Transforms/TestCommutativityUtils.cpp
    M mlir/test/lib/Transforms/TestMakeIsolatedFromAbove.cpp

  Log Message:
  -----------
  [mlir] Enable decoupling two kinds of greedy behavior. (#104649)

The greedy rewriter is used in many different flows and it has a lot of
convenience (work list management, debugging actions, tracing, etc). But
it combines two kinds of greedy behavior 1) how ops are matched, 2)
folding wherever it can.

These are independent forms of greedy and leads to inefficiency. E.g.,
cases where one need to create different phases in lowering and is
required to applying patterns in specific order split across different
passes. Using the driver one ends up needlessly retrying folding/having
multiple rounds of folding attempts, where one final run would have
sufficed.

Of course folks can locally avoid this behavior by just building their
own, but this is also a common requested feature that folks keep on
working around locally in suboptimal ways.

For downstream users, there should be no behavioral change. Updating
from the deprecated should just be a find and replace (e.g., `find ./
-type f -exec sed -i
's|applyPatternsAndFoldGreedily|applyPatternsGreedily|g' {} \;` variety)
as the API arguments hasn't changed between the two.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list