-
Notifications
You must be signed in to change notification settings - Fork 15.5k
Closed
Labels
crashPrefer [crash-on-valid] or [crash-on-invalid]Prefer [crash-on-valid] or [crash-on-invalid]mlir:affine
Description
Test on commit: #902614d2
Steps to reproduce:
mlir-opt -lower-affine test.mlirMinimized test case:
#map = affine_map<() -> (13)>
#map1 = affine_map<() -> (21)>
#map2 = affine_map<(d0)[s0] -> (d0 * s0)>
#map3 = affine_map<() -> (3)>
#map4 = affine_map<(d0)[s0] -> (d0 mod s0)>
#map5 = affine_map<(d0)[s0] -> (d0 floordiv s0)>
module {
func.func @test_bitwise_xor(%arg0: tensor<13x21x1xi32>, %arg1: tensor<13x21x3xi32>) {
%collapsed = tensor.collapse_shape %arg0 [[0], [1, 2]] : tensor<13x21x1xi32> into tensor<13x21xi32>
%1 = bufferization.to_memref %collapsed : memref<13x21xi32>
%alloc_4 = memref.alloc() : memref<13x21xi32>
affine.parallel (%arg2) = (max()) to (min()) {
affine.parallel (%arg3) = (0) to (21) {
%8 = affine.load %1[%arg2, %arg3] : memref<13x21xi32>
affine.store %8, %alloc_4[%arg2, %arg3] : memref<13x21xi32>
}
}
return
}
}The execution crashes with following backtrace:
mlir-opt: /home/data/mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp:49: mlir::Value buildMinMaxReductionSeq(mlir::Location, mlir::arith::CmpIPredicate, mlir::ValueRange, mlir::OpBuilder&): Assertion `!values.empty() && "empty min/max chain"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: ./mlir-opt /home/ty/test.mlir -lower-affine
#0 0x00005635aecd46ea llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (./mlir-opt+0x1a76ea)
#1 0x00005635aecd1cfc SignalHandler(int) Signals.cpp:0:0
#2 0x00007f157b674980 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
#3 0x00007f157a76ce87 raise /build/glibc-CVJwZb/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
#4 0x00007f157a76e7f1 abort /build/glibc-CVJwZb/glibc-2.27/stdlib/abort.c:81:0
#5 0x00007f157a75e3fa __assert_fail_base /build/glibc-CVJwZb/glibc-2.27/assert/assert.c:89:0
#6 0x00007f157a75e472 (/lib/x86_64-linux-gnu/libc.so.6+0x30472)
#7 0x00005635afc710e0 lowerAffineMapMin(mlir::OpBuilder&, mlir::Location, mlir::AffineMap, mlir::ValueRange) AffineToStandard.cpp:0:0
#8 0x00005635afc7138d lowerAffineMapMax(mlir::OpBuilder&, mlir::Location, mlir::AffineMap, mlir::ValueRange) AffineToStandard.cpp:0:0
#9 0x00005635afc71cf8 (anonymous namespace)::AffineParallelLowering::matchAndRewrite(mlir::AffineParallelOp, mlir::PatternRewriter&) const AffineToStandard.cpp:0:0
#10 0x00005635afc6f516 mlir::detail::OpOrInterfaceRewritePatternBase<mlir::AffineParallelOp>::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const (./mlir-opt+0x1142516)
#11 0x00005635b071d2cd 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&)>) (./mlir-opt+0x1bf02cd)
#12 0x00005635b03d5d17 (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*, mlir::ConversionPatternRewriter&) DialectConversion.cpp:0:0
#13 0x00005635b03d670f (anonymous namespace)::OperationConverter::convertOperations(llvm::ArrayRef<mlir::Operation*>, llvm::function_ref<void (mlir::Diagnostic&)>) DialectConversion.cpp:0:0
#14 0x00005635b03da270 mlir::applyPartialConversion(mlir::Operation*, mlir::ConversionTarget&, mlir::FrozenRewritePatternSet const&, llvm::DenseSet<mlir::Operation*, llvm::DenseMapInfo<mlir::Operation*, void>>*) (./mlir-opt+0x18ad270)
#15 0x00005635afc79f7d (anonymous namespace)::LowerAffinePass::runOnOperation() AffineToStandard.cpp:0:0
#16 0x00005635b0360319 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (./mlir-opt+0x1833319)
#17 0x00005635b03610a9 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (.constprop.489) Pass.cpp:0:0
#18 0x00005635b03617dd mlir::PassManager::run(mlir::Operation*) (./mlir-opt+0x18347dd)
#19 0x00005635b035358b performActions(llvm::raw_ostream&, bool, bool, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, llvm::function_ref<mlir::LogicalResult (mlir::PassManager&)>, bool, bool) (.constprop.273) MlirOptMain.cpp:0:0
#20 0x00005635b0353c88 processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, bool, bool, bool, bool, bool, bool, llvm::function_ref<mlir::LogicalResult (mlir::PassManager&)>, mlir::DialectRegistry&, llvm::ThreadPool*) MlirOptMain.cpp:0:0
#21 0x00005635b035408f mlir::LogicalResult llvm::function_ref<mlir::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>>, llvm::function_ref<mlir::LogicalResult (mlir::PassManager&)>, mlir::DialectRegistry&, bool, bool, bool, bool, bool, bool, bool)::'lambda'(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#22 0x00005635b04153b0 mlir::splitAndProcessBuffer(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<mlir::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>, llvm::raw_ostream&, bool, bool) (./mlir-opt+0x18e83b0)
#23 0x00005635b0352446 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::PassPipelineCLParser const&, mlir::DialectRegistry&, bool, bool, bool, bool, bool, bool, bool, bool) (./mlir-opt+0x1825446)
#24 0x00005635b03544cb mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&, bool) (./mlir-opt+0x18274cb)
#25 0x00005635aeca1360 main (./mlir-opt+0x174360)
#26 0x00007f157a74fc87 __libc_start_main /build/glibc-CVJwZb/glibc-2.27/csu/../csu/libc-start.c:344:0
#27 0x00005635aecb3dea _start (./mlir-opt+0x186dea)
Aborted (core dumped)I think this bug is caused by specific optimization sequences -affine-loop-coalescing "-affine-data-copy-generate=generate-dma=false fast-mem-space=0 skip-non-unit-stride-loops" -affine-parallelize.
Following IR is a function in release/15.x/mlir/test/Dialect/Tosa/ops.mlir, you can use it to reproduce this bug:
func.func @test_bitwise_xor(%arg0: tensor<13x21x1xi32>, %arg1: tensor<13x21x3xi32>) -> tensor<13x21x3xi32> {
%0 = "tosa.bitwise_xor"(%arg0, %arg1) : (tensor<13x21x1xi32>, tensor<13x21x3xi32>) -> tensor<13x21x3xi32>
return %0 : tensor<13x21x3xi32>
}
Complete steps to reproduce :
mlir-opt test.mlir -pass-pipeline="builtin.module(func.func(tosa-to-linalg))" -o output.mlir
mlir-opt output.mlir -func-bufferize -linalg-bufferize -convert-linalg-to-affine-loops -affine-loop-coalescing -affine-data-copy-generate="generate-dma=false fast-mem-space=0 skip-non-unit-stride-loops" -affine-parallelize -lower-affineMetadata
Metadata
Assignees
Labels
crashPrefer [crash-on-valid] or [crash-on-invalid]Prefer [crash-on-valid] or [crash-on-invalid]mlir:affine