[Mlir-commits] [mlir] [mlir][linalg] Add pattern to bubble-up pack through expand shape op (PR #93529)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Tue Jun 25 17:52:16 PDT 2024


================

----------------
AmosLewis wrote:

I got similar issue for mit-b0 model. The issue could be fixed by revert this commit.

```
(gdb) bt
#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=140737352719616) at ./nptl/pthread_kill.c:44
#1  __pthread_kill_internal (signo=6, threadid=140737352719616) at ./nptl/pthread_kill.c:78
#2  __GI___pthread_kill (threadid=140737352719616, signo=signo at entry=6) at ./nptl/pthread_kill.c:89
#3  0x00007fffdd442476 in __GI_raise (sig=sig at entry=6) at ../sysdeps/posix/raise.c:26
#4  0x00007fffdd4287f3 in __GI_abort () at ./stdlib/abort.c:79
#5  0x00007fffdd42871b in __assert_fail_base (fmt=0x7fffdd5dd130 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", 
    assertion=0x7fffe22dc65a "input.size() == permutation.size() && \"expected input rank to equal permutation rank\"", 
    file=0x7fffe12f935b "iree/third_party/llvm-project/mlir/include/mlir/Dialect/Utils/IndexingUtils.h", line=204, function=<optimized out>) at ./assert/assert.c:92
#6  0x00007fffdd439e96 in __GI___assert_fail (assertion=0x7fffe22dc65a "input.size() == permutation.size() && \"expected input rank to equal permutation rank\"", 
    file=0x7fffe12f935b "iree/third_party/llvm-project/mlir/include/mlir/Dialect/Utils/IndexingUtils.h", line=204, 
    function=0x7fffe23b6a01 "SmallVector<T> mlir::applyPermutation(ArrayRef<T>, ArrayRef<int64_t>) [T = llvm::SmallVector<long, 2>]") at ./assert/assert.c:101
#7  0x00007fffec368e98 in mlir::applyPermutation<llvm::SmallVector<long, 2u> > (input=..., permutation=...)
    at /home/chi/src/iree/third_party/llvm-project/mlir/include/mlir/Dialect/Utils/IndexingUtils.h:203

#8  0x00007fffec368dd9 in mlir::applyPermutation<llvm::SmallVector<long, 2u> > (input=..., permutation=...)
    at /home/chi/src/iree/third_party/llvm-project/mlir/include/mlir/Dialect/Utils/IndexingUtils.h:214
#9  0x00007fffec368979 in mlir::applyPermutationToVector<llvm::SmallVector<long, 2u>, 1u> (inVec=..., permutation=...)
    at /home/chi/src/iree/third_party/llvm-project/mlir/include/mlir/Dialect/Utils/IndexingUtils.h:225
#10 0x00007fffef5599c5 in (anonymous namespace)::applyPermutationAndReindexReassoc (reassocIndices=..., permutation=...)
    at /home/chi/src/iree/third_party/llvm-project/mlir/lib/Dialect/Linalg/Transforms/DataLayoutPropagation.cpp:608
#11 0x00007fffef5594e6 in (anonymous namespace)::bubbleUpPackOpThroughCollapseShape (collapseOp=..., packOp=..., rewriter=...)
    at /home/chi/src/iree/third_party/llvm-project/mlir/lib/Dialect/Linalg/Transforms/DataLayoutPropagation.cpp:685
#12 0x00007fffef559057 in (anonymous namespace)::BubbleUpPackOpThroughReshapeOp::matchAndRewrite(mlir::tensor::PackOp, mlir::PatternRewriter&) const::{lambda(mlir::tensor::CollapseShapeOp)#1}::operat--Type <RET> for more, q to quit, c to continue without paging--
or()(mlir::tensor::CollapseShapeOp) const (this=0x7fffffff8fc0, op=...) at /home/chi/src/iree/third_party/llvm-project/mlir/lib/Dialect/Linalg/Transforms/DataLayoutPropagation.cpp:851
#13 0x00007fffef558fef in llvm::TypeSwitch<mlir::Operation*, mlir::LogicalResult>::Case<mlir::tensor::CollapseShapeOp, (anonymous namespace)::BubbleUpPackOpThroughReshapeOp::matchAndRewrite(mlir::tensor::PackOp, mlir::PatternRewriter&) const::{lambda(mlir::tensor::CollapseShapeOp)#1}>((anonymous namespace)::BubbleUpPackOpThroughReshapeOp::matchAndRewrite(mlir::tensor::PackOp, mlir::PatternRewriter&) const::{lambda(mlir::tensor::CollapseShapeOp)#1}&&) (this=0x7fffffff8fd0, caseFn=...) at /home/chi/src/iree/third_party/llvm-project/llvm/include/llvm/ADT/TypeSwitch.h:102
#14 0x00007fffef558b45 in llvm::detail::TypeSwitchBase<llvm::TypeSwitch<mlir::Operation*, mlir::LogicalResult>, mlir::Operation*>::Case<(anonymous namespace)::BubbleUpPackOpThroughReshapeOp::matchAndRewrite(mlir::tensor::PackOp, mlir::PatternRewriter&) const::{lambda(mlir::tensor::CollapseShapeOp)#1}>((anonymous namespace)::BubbleUpPackOpThroughReshapeOp::matchAndRewrite(mlir::tensor::PackOp, mlir::PatternRewriter&) const::{lambda(mlir::tensor::CollapseShapeOp)#1}&&) (this=0x7fffffff8fd0, caseFn=...) at /home/chi/src/iree/third_party/llvm-project/llvm/include/llvm/ADT/TypeSwitch.h:60
#15 0x00007fffef558a91 in (anonymous namespace)::BubbleUpPackOpThroughReshapeOp::matchAndRewrite (this=0x5555557239d0, packOp=..., rewriter=...)
    at /home/chi/src/iree/third_party/llvm-project/mlir/lib/Dialect/Linalg/Transforms/DataLayoutPropagation.cpp:850
#16 0x00007fffec3b87eb in mlir::detail::OpOrInterfaceRewritePatternBase<mlir::tensor::PackOp>::matchAndRewrite (this=0x5555557239d0, op=0x555556649190, rewriter=...)
    at /home/chi/src/iree/third_party/llvm-project/mlir/include/mlir/IR/PatternMatch.h:331
#17 0x00007ffff16cf52e in mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<mlir::LogicalResult (mlir::Pattern const&)>)::$_0::operator()() const (this=0x7fffffff92b0)
    at /home/chi/src/iree/third_party/llvm-project/mlir/lib/Rewrite/PatternApplicator.cpp:212
#18 0x00007ffff16cf385 in llvm::function_ref<void ()>::callback_fn<mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<mlir::LogicalResult (mlir::Pattern const&)>)::$_0>(long) (callable=140737488327344)
    at /home/chi/src/iree/third_party/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45
#19 0x00007fffe93074a9 in llvm::function_ref<void ()>::operator()() const (this=0x7fffffff91f0) at /home/chi/src/iree/third_party/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68
#20 0x00007ffff16d0d55 in mlir::MLIRContext::executeAction<mlir::ApplyPatternAction, mlir::Pattern const&>(llvm::function_ref<void ()>, llvm::ArrayRef<mlir::IRUnit>, mlir::Pattern const&) (
    this=0x5555555ec710, actionFn=..., irUnits=..., args=...) at /home/chi/src/iree/third_party/llvm-project/mlir/include/mlir/IR/MLIRContext.h:275
#21 0x00007ffff16cde27 in mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<mlir::LogicalResult (mlir::Pattern const&)>) (this=0x7fffffff9ed0, op=0x555556649190, rewriter=..., canApply=..., onFailure=..., onSuccess=...)
--Type <RET> for more, q to quit, c to continue without paging--
    at /home/chi/src/iree/third_party/llvm-project/mlir/lib/Rewrite/PatternApplicator.cpp:195
#22 0x00007ffff16898db in (anonymous namespace)::GreedyPatternRewriteDriver::processWorklist (this=0x7fffffff9dd0)
    at /home/chi/src/iree/third_party/llvm-project/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp:615
#23 0x00007ffff1688b61 in (anonymous namespace)::RegionPatternRewriteDriver::simplify(bool*) &&::$_2::operator()() const (this=0x7fffffff9c80)
    at /home/chi/src/iree/third_party/llvm-project/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp:874
#24 0x00007ffff1688b35 in llvm::function_ref<void ()>::callback_fn<(anonymous namespace)::RegionPatternRewriteDriver::simplify(bool*) &&::$_2>(long) (callable=140737488329856)
    at /home/chi/src/iree/third_party/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45
#25 0x00007fffe93074a9 in llvm::function_ref<void ()>::operator()() const (this=0x7fffffff9c20) at /home/chi/src/iree/third_party/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68
#26 0x00007ffff1688285 in mlir::MLIRContext::executeAction<(anonymous namespace)::GreedyPatternRewriteIteration, long&>(llvm::function_ref<void ()>, llvm::ArrayRef<mlir::IRUnit>, long&) (
    this=0x5555555ec710, actionFn=..., irUnits=..., args=@0x7fffffff9d88: 2) at /home/chi/src/iree/third_party/llvm-project/mlir/include/mlir/IR/MLIRContext.h:275
#27 0x00007ffff168670e in (anonymous namespace)::RegionPatternRewriteDriver::simplify(bool*) && (this=0x7fffffff9dd0, changed=0x7fffffff9fd7)
    at /home/chi/src/iree/third_party/llvm-project/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp:872
#28 0x00007ffff16863f7 in mlir::applyPatternsAndFoldGreedily (region=..., patterns=..., config=..., changed=0x7fffffff9fd7)
    at /home/chi/src/iree/third_party/llvm-project/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp:919
#29 0x00007fffe924a105 in mlir::applyPatternsAndFoldGreedily (op=0x5555557d1cf0, patterns=..., config=..., changed=0x0)
    at /home/chi/src/iree/third_party/llvm-project/mlir/include/mlir/Transforms/GreedyPatternRewriteDriver.h:159
#30 0x00007fffec31f23b in mlir::iree_compiler::GlobalOptimization::(anonymous namespace)::DataLayoutPropagationPass::runOnOperation (this=0x55555663f1d0)
    at /home/chi/src/iree/compiler/src/iree/compiler/GlobalOptimization/DataLayoutPropagation.cpp:31
#31 0x00007fffe980335b in mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int)::$_1::operator()() const (this=0x7fffffffa428)
    at /home/chi/src/iree/third_party/llvm-project/mlir/lib/Pass/Pass.cpp:527
#32 0x00007fffe98032f5 in llvm::function_ref<void ()>::callback_fn<mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int)::$_1>(long) (
    callable=140737488331816) at /home/chi/src/iree/third_party/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45
--Type <RET> for more, q to quit, c to continue without paging--
#33 0x00007fffe93074a9 in llvm::function_ref<void ()>::operator()() const (this=0x7fffffffa3b0) at /home/chi/src/iree/third_party/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68
#34 0x00007fffe9806175 in mlir::MLIRContext::executeAction<mlir::PassExecutionAction, mlir::Pass&>(llvm::function_ref<void ()>, llvm::ArrayRef<mlir::IRUnit>, mlir::Pass&) (this=0x5555555ec710, 
    actionFn=..., irUnits=..., args=...) at /home/chi/src/iree/third_party/llvm-project/mlir/include/mlir/IR/MLIRContext.h:275
#35 0x00007fffe97feab3 in mlir::detail::OpToOpPassAdaptor::run (pass=0x55555663f1d0, op=0x5555557d1cf0, am=..., verifyPasses=true, parentInitGeneration=1)
    at /home/chi/src/iree/third_party/llvm-project/mlir/lib/Pass/Pass.cpp:521
#36 0x00007fffe97ff034 in mlir::detail::OpToOpPassAdaptor::runPipeline (pm=..., op=0x5555557d1cf0, am=..., verifyPasses=true, parentInitGeneration=1, instrumentor=0x5555557f5ee0, 
    parentInfo=0x7fffffffaae0) at /home/chi/src/iree/third_party/llvm-project/mlir/lib/Pass/Pass.cpp:593
#37 0x00007fffe98045e5 in mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_0::operator()(mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo&) const (
    this=0x7fffffffaa78, opInfo=...) at /home/chi/src/iree/third_party/llvm-project/mlir/lib/Pass/Pass.cpp:813
#38 0x00007fffe9804269 in mlir::failableParallelForEach<__gnu_cxx::__normal_iterator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo> > >, mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_0&>(mlir::MLIRContext*, __gnu_cxx::__normal_iterator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo> > >, __gnu_cxx::__normal_iterator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo> > >, mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_0&) (context=0x5555555ec710, begin={passManagerIdx = 0, op = 0x5555557d1cf0, am = {impl = 0x5555557d2ce0}}, 
    end={passManagerIdx = 129, op = 0x55555578f6a0, am = {impl = 0x55555578ef00}}, func=...) at /home/chi/src/iree/third_party/llvm-project/mlir/include/mlir/IR/Threading.h:46
#39 0x00007fffe98002eb in mlir::failableParallelForEach<std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo> >&, mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_0&>(mlir::MLIRContext*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo> >&, mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_0&) (
    context=0x5555555ec710, range=std::vector of length 1, capacity 1 = {...}, func=...) at /home/chi/src/iree/third_party/llvm-project/mlir/include/mlir/IR/Threading.h:92
#40 0x00007fffe97ffbfa in mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl (this=0x555555804b30, verifyPasses=true) at /home/chi/src/iree/third_party/llvm-project/mlir/lib/Pass/Pass.cpp:823
#41 0x00007fffe97ff727 in mlir::detail::OpToOpPassAdaptor::runOnOperation (this=0x555555804b30, verifyPasses=true) at /home/chi/src/iree/third_party/llvm-project/mlir/lib/Pass/Pass.cpp:714
--Type <RET> for more, q to quit, c to continue without paging--
#42 0x00007fffe9803346 in mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int)::$_1::operator()() const (this=0x7fffffffade8)
    at /home/chi/src/iree/third_party/llvm-project/mlir/lib/Pass/Pass.cpp:525
#43 0x00007fffe98032f5 in llvm::function_ref<void ()>::callback_fn<mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int)::$_1>(long) (
    callable=140737488334312) at /home/chi/src/iree/third_party/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45
#44 0x00007fffe93074a9 in llvm::function_ref<void ()>::operator()() const (this=0x7fffffffad70) at /home/chi/src/iree/third_party/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68
#45 0x00007fffe9806175 in mlir::MLIRContext::executeAction<mlir::PassExecutionAction, mlir::Pass&>(llvm::function_ref<void ()>, llvm::ArrayRef<mlir::IRUnit>, mlir::Pass&) (this=0x5555555ec710, 
    actionFn=..., irUnits=..., args=...) at /home/chi/src/iree/third_party/llvm-project/mlir/include/mlir/IR/MLIRContext.h:275
#46 0x00007fffe97feab3 in mlir::detail::OpToOpPassAdaptor::run (pass=0x555555804b30, op=0x5555557f5690, am=..., verifyPasses=true, parentInitGeneration=1)
    at /home/chi/src/iree/third_party/llvm-project/mlir/lib/Pass/Pass.cpp:521
#47 0x00007fffe97ff034 in mlir::detail::OpToOpPassAdaptor::runPipeline (pm=..., op=0x5555557f5690, am=..., verifyPasses=true, parentInitGeneration=1, instrumentor=0x0, parentInfo=0x0)
    at /home/chi/src/iree/third_party/llvm-project/mlir/lib/Pass/Pass.cpp:593
#48 0x00007fffe9800a78 in mlir::PassManager::runPasses (this=0x555555739cb0, op=0x5555557f5690, am=...) at /home/chi/src/iree/third_party/llvm-project/mlir/lib/Pass/Pass.cpp:904
#49 0x00007fffe98009a2 in mlir::PassManager::run (this=0x555555739cb0, op=0x5555557f5690) at /home/chi/src/iree/third_party/llvm-project/mlir/lib/Pass/Pass.cpp:884
#50 0x00007fffe9251cba in mlir::iree_compiler::embed::(anonymous namespace)::Invocation::runPipeline (this=0x55555565add0, pipeline=IREE_COMPILER_PIPELINE_STD)
    at /home/chi/src/iree/compiler/src/iree/compiler/API/Internal/CompilerDriver.cpp:995
#51 0x00007fffe9251593 in ireeCompilerInvocationPipeline (inv=0x55555565add0, pipeline=IREE_COMPILER_PIPELINE_STD)
    at /home/chi/src/iree/compiler/src/iree/compiler/API/Internal/CompilerDriver.cpp:1430
#52 0x00007fffe978a88e in mlir::iree_compiler::runIreecMain(int, char**)::$_2::operator()(iree_compiler_source_t*) const (this=0x7fffffffc0e8, source=0x55555565aba0)
    at /home/chi/src/iree/compiler/src/iree/compiler/Tools/iree_compile_lib.cc:254
#53 0x00007fffe9789d1e in mlir::iree_compiler::runIreecMain (argc=4, argv=0x7fffffffdbd8) at /home/chi/src/iree/compiler/src/iree/compiler/Tools/iree_compile_lib.cc:355
#54 0x00007fffe929baab in ireeCompilerRunMain (argc=4, argv=0x7fffffffdbd8) at /home/chi/src/iree/compiler/src/iree/compiler/API/Internal/IREECompileToolEntryPoint.cpp:12
#55 0x00005555555557a2 in main (argc=4, argv=0x7fffffffdbd8) at /home/chi/src/iree/tools/iree-compile-main.cc:9
```



https://github.com/llvm/llvm-project/pull/93529


More information about the Mlir-commits mailing list