Skip to content

[MLIR] Assertion `mesh.getRank() == 1 && "Only 1D meshes are currently supported."' failed. #128801

Open
@RiRi114

Description

@RiRi114

Test on commit: release 19.1.4
steps to reproduce:
mlir-opt test.mlir -test-mesh-resharding-spmdization

test case:

func.func @sharding_example(
%arg0: tensor<4x3xf32>
) -> tensor<4x3xf32> {
 %0 = mesh.shard %arg0 to <@mesh_2d, [[]]> : tensor<4x3xf32>
 %1 = mesh.shard %0 to <@mesh_2d, [[0]]> annotate_for_users : tensor<4x3xf32>
 %2 = tosa.add %1, %1 : (tensor<4x3xf32>, tensor<4x3xf32>) -> tensor<4x3xf32>
 %3 = mesh.shard %2 to <@mesh_2d, [[0]]> : tensor<4x3xf32>
 %4 = mesh.shard %3 to <@mesh_2d, [[]]> annotate_for_users : tensor<4x3xf32>
 return %4 : tensor<4x3xf32>
}

mesh.mesh @mesh_2d(shape = 4x3)

crash trace:

mlir-opt: /home/fuzzing/llvm-project-llvmorg-19.1.4/mlir/lib/Dialect/Mesh/Transforms/Spmdization.cpp:447: TypedValue<mlir::ShapedType> mlir::mesh::reshardOn1DMesh(mlir::ImplicitLocOpBuilder &, mlir::mesh::MeshOp, mlir::mesh::MeshShardingAttr, mlir::mesh::MeshShardingAttr, TypedValue<mlir::ShapedType>, TypedValue<mlir::ShapedType>): Assertion `mesh.getRank() == 1 && "Only 1D meshes are currently supported."' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /home/fuzzing/llvm-project-llvmorg-19.1.4/build/bin/mlir-opt test.mlir -test-mesh-resharding-spmdization
 #0 0x00000000013906e7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/fuzzing/llvm-project-llvmorg-19.1.4/llvm/lib/Support/Unix/Signals.inc:723:13
 #1 0x000000000138c27a llvm::sys::RunSignalHandlers() /home/fuzzing/llvm-project-llvmorg-19.1.4/llvm/lib/Support/Signals.cpp:0:5
 #2 0x0000000001391c24 SignalHandler(int) /home/fuzzing/llvm-project-llvmorg-19.1.4/llvm/lib/Support/Unix/Signals.inc:413:1
 #3 0x000078919a72f520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x000078919a7839fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x000078919a72f476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x000078919a7157f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x000078919a71571b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #8 0x000078919a726e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #9 0x00000000049c4903 mlir::mesh::handlePartialAxesDuringResharding(mlir::OpBuilder&, mlir::mesh::MeshShardingAttr, mlir::mesh::MeshShardingAttr, mlir::detail::TypedValue<mlir::ShapedType>) /home/fuzzing/llvm-project-llvmorg-19.1.4/mlir/lib/Dialect/Mesh/Transforms/Spmdization.cpp:75:3
#10 0x00000000049c4903 mlir::mesh::reshardOn1DMesh(mlir::ImplicitLocOpBuilder&, mlir::mesh::MeshOp, mlir::mesh::MeshShardingAttr, mlir::mesh::MeshShardingAttr, mlir::detail::TypedValue<mlir::ShapedType>, mlir::detail::TypedValue<mlir::ShapedType>) /home/fuzzing/llvm-project-llvmorg-19.1.4/mlir/lib/Dialect/Mesh/Transforms/Spmdization.cpp:450:7
#11 0x00000000049c4c82 mlir::mesh::reshard(mlir::OpBuilder&, mlir::mesh::MeshOp, mlir::mesh::ShardOp, mlir::mesh::ShardOp, mlir::detail::TypedValue<mlir::ShapedType>) /home/fuzzing/llvm-project-llvmorg-19.1.4/mlir/lib/Dialect/Mesh/Transforms/Spmdization.cpp:500:1
#12 0x000000000795203e (anonymous namespace)::TestMeshReshardingRewritePattern::matchAndRewrite(mlir::mesh::ShardOp, mlir::PatternRewriter&) const /home/fuzzing/llvm-project-llvmorg-19.1.4/mlir/test/lib/Dialect/Mesh/TestReshardingSpmdization.cpp:75:11
#13 0x000000000d79e74a mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<llvm::LogicalResult (mlir::Pattern const&)>)::$_2::operator()() const /home/fuzzing/llvm-project-llvmorg-19.1.4/mlir/lib/Rewrite/PatternApplicator.cpp:212:13
#14 0x000000000d79e74a void 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<llvm::LogicalResult (mlir::Pattern const&)>)::$_2>(long) /home/fuzzing/llvm-project-llvmorg-19.1.4/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:12
#15 0x000000000d797912 mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<llvm::LogicalResult (mlir::Pattern const&)>) /home/fuzzing/llvm-project-llvmorg-19.1.4/mlir/lib/Rewrite/PatternApplicator.cpp:233:9
#16 0x0000000008919a48 (anonymous namespace)::GreedyPatternRewriteDriver::processWorklist() /home/fuzzing/llvm-project-llvmorg-19.1.4/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp:0:17
#17 0x0000000008914773 (anonymous namespace)::RegionPatternRewriteDriver::simplify(bool*) &&::$_8::operator()() const /home/fuzzing/llvm-project-llvmorg-19.1.4/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp:874:11
#18 0x0000000008914773 void llvm::function_ref<void ()>::callback_fn<(anonymous namespace)::RegionPatternRewriteDriver::simplify(bool*) &&::$_8>(long) /home/fuzzing/llvm-project-llvmorg-19.1.4/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:12
#19 0x0000000008914773 llvm::function_ref<void ()>::operator()() const /home/fuzzing/llvm-project-llvmorg-19.1.4/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:12
#20 0x0000000008914773 void mlir::MLIRContext::executeAction<(anonymous namespace)::GreedyPatternRewriteIteration, long&>(llvm::function_ref<void ()>, llvm::ArrayRef<mlir::IRUnit>, long&) /home/fuzzing/llvm-project-llvmorg-19.1.4/mlir/include/mlir/IR/MLIRContext.h:275:7
#21 0x0000000008914773 (anonymous namespace)::RegionPatternRewriteDriver::simplify(bool*) && /home/fuzzing/llvm-project-llvmorg-19.1.4/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp:872:10
#22 0x0000000008914773 mlir::applyPatternsAndFoldGreedily(mlir::Region&, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig, bool*) /home/fuzzing/llvm-project-llvmorg-19.1.4/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp:919:47
#23 0x000000000160773d mlir::applyPatternsAndFoldGreedily(mlir::Operation*, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig, bool*) /home/fuzzing/llvm-project-llvmorg-19.1.4/mlir/include/mlir/Transforms/GreedyPatternRewriteDriver.h:0:9
#24 0x0000000007950c03 (anonymous namespace)::TestMeshReshardingPass::runOnOperation() /home/fuzzing/llvm-project-llvmorg-19.1.4/mlir/test/lib/Dialect/Mesh/TestReshardingSpmdization.cpp:0:16
#25 0x0000000008792bb3 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int)::$_7::operator()() const /home/fuzzing/llvm-project-llvmorg-19.1.4/mlir/lib/Pass/Pass.cpp:0:17
#26 0x0000000008792bb3 void llvm::function_ref<void ()>::callback_fn<mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int)::$_7>(long) /home/fuzzing/llvm-project-llvmorg-19.1.4/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:12
#27 0x0000000008792bb3 llvm::function_ref<void ()>::operator()() const /home/fuzzing/llvm-project-llvmorg-19.1.4/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:12
#28 0x0000000008792bb3 void mlir::MLIRContext::executeAction<mlir::PassExecutionAction, mlir::Pass&>(llvm::function_ref<void ()>, llvm::ArrayRef<mlir::IRUnit>, mlir::Pass&) /home/fuzzing/llvm-project-llvmorg-19.1.4/mlir/include/mlir/IR/MLIRContext.h:275:7
#29 0x0000000008792bb3 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) /home/fuzzing/llvm-project-llvmorg-19.1.4/mlir/lib/Pass/Pass.cpp:521:21
#30 0x0000000008793940 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) /home/fuzzing/llvm-project-llvmorg-19.1.4/mlir/lib/Pass/Pass.cpp:0:16
#31 0x0000000008798b92 mlir::PassManager::run(mlir::Operation*) /home/fuzzing/llvm-project-llvmorg-19.1.4/mlir/lib/Pass/Pass.cpp:0:0
#32 0x000000000878224b performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) /home/fuzzing/llvm-project-llvmorg-19.1.4/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:0:17
#33 0x0000000008781a78 processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, llvm::ThreadPoolInterface*) /home/fuzzing/llvm-project-llvmorg-19.1.4/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:473:12
#34 0x0000000008781a78 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::$_3::operator()(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >, llvm::raw_ostream&) const /home/fuzzing/llvm-project-llvmorg-19.1.4/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:548:12
#35 0x0000000008781a78 llvm::LogicalResult llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >, llvm::raw_ostream&)>::callback_fn<mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::$_3>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >, llvm::raw_ostream&) /home/fuzzing/llvm-project-llvmorg-19.1.4/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:12
#36 0x00000000089a9a3a llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >, llvm::raw_ostream&)>::operator()(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >, llvm::raw_ostream&) const /home/fuzzing/llvm-project-llvmorg-19.1.4/llvm/include/llvm/ADT/STLFunctionalExtras.h:0:12
#37 0x00000000089a932d mlir::splitAndProcessBuffer(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >, llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >, llvm::raw_ostream&)>, llvm::raw_ostream&, llvm::StringRef, llvm::StringRef) /home/fuzzing/llvm-project-llvmorg-19.1.4/mlir/lib/Support/ToolUtilities.cpp:0:12
#38 0x000000000877832a mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) /home/fuzzing/llvm-project-llvmorg-19.1.4/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:0:10
#39 0x0000000008778b58 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) /home/fuzzing/llvm-project-llvmorg-19.1.4/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:0:14
#40 0x00000000087796f3 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) /home/fuzzing/llvm-project-llvmorg-19.1.4/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:605:10
#41 0x0000000001305e9d main /home/fuzzing/llvm-project-llvmorg-19.1.4/mlir/tools/mlir-opt/mlir-opt.cpp:0:33
#42 0x000078919a716d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#43 0x000078919a716e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#44 0x00000000013057f5 _start (/home/fuzzing/llvm-project-llvmorg-19.1.4/build/bin/mlir-opt+0x13057f5)
Aborted (core dumped)

Metadata

Metadata

Assignees

No one assigned

    Labels

    crashPrefer [crash-on-valid] or [crash-on-invalid]mlir:meshIssues for the Mesh Dialect

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions