Skip to content

[mlir] -one-shot-bufferize crashes #120886

@Anonymous7i0em3yd

Description

@Anonymous7i0em3yd

git version: bc29fc9

system: Ubuntu 18.04.6 LTS

reproduce with: mlir-opt -one-shot-bufferize a.mlir

a.mlir:

module {
  func.func @test_reshape_3d_same_d2d(%arg0: tensor<2x?xf32>) -> (tensor<?x?xf32>, tensor<?x?xf32>, tensor<?x?xf32>) {
    %collapsed = tensor.collapse_shape %arg0 [[0, 1]] : tensor<2x?xf32> into tensor<?xf32>
    %c0 = arith.constant 0 : index
    %dim = tensor.dim %collapsed, %c0 : tensor<?xf32>
    %c2 = arith.constant 2 : index
    %0 = arith.divui %dim, %c2 : index
    %expanded = tensor.expand_shape %collapsed [[0, 1]] output_shape [2, %0] : tensor<?xf32> into tensor<2x?xf32>
    %cast = tensor.cast %expanded : tensor<2x?xf32> to tensor<?x?xf32>
    %dim_replaced = tensor.dim %cast, %c0 : tensor<?x?xf32>
    %c1 = arith.constant 1 : index
    %1 = arith.divui %dim_replaced, %c1 : index
    %expanded_0 = tensor.expand_shape %collapsed [[0, 1]] output_shape [2, %1] : tensor<?xf32> into tensor<2x?xf32>
    %cast_1 = tensor.cast %expanded_0 : tensor<2x?xf32> to tensor<?x?xf32>
    %c0_2 = arith.constant 0 : index
    %dim_replaced_3 = tensor.dim %cast_1, %c0_2 : tensor<?x?xf32>
    %c1_4 = arith.constant 1 : index
    %expanded_5 = tensor.expand_shape %collapsed [[0, 1]] output_shape [%dim_replaced_3, %c1_4] : tensor<?xf32> into tensor<?x?xf32>
    return %cast, %cast_1, %expanded_5 : tensor<?x?xf32>, tensor<?x?xf32>, tensor<?x?xf32>
  }
}

stack trace:

mlir-opt: /data/szy/MLIR/llvm-release/llvm-project/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp:2315: static void mlir::memref::ExpandShapeOp::build(OpBuilder &, OperationState &, Type, Value, ArrayRef<ReassociationIndices>): Assertion `succeeded(outputShape) && "unable to infer output shape"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt -one-shot-bufferize /data/szy/MLIR/seed/seed14/tmp.hNYivZemUi.mlir
 #0 0x000055c527a4a418 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x11ee418)
 #1 0x000055c527a47f2e llvm::sys::RunSignalHandlers() (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x11ebf2e)
 #2 0x000055c527a4adad SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f548ef53420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x00007f548e59000b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #5 0x00007f548e56f859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7
 #6 0x00007f548e56f729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8
 #7 0x00007f548e56f729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34
 #8 0x00007f548e580fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #9 0x000055c5292b6681 (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x2a5a681)
#10 0x000055c529f91b6b mlir::memref::ExpandShapeOp mlir::OpBuilder::create<mlir::memref::ExpandShapeOp, llvm::ArrayRef<long>, mlir::Value&, llvm::SmallVector<llvm::SmallVector<long, 2u>, 4u>>(mlir::Location, llvm::ArrayRef<long>&&, mlir::Value&, llvm::SmallVector<llvm::SmallVector<long, 2u>, 4u>&&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x3735b6b)
#11 0x000055c529f912ea mlir::bufferization::detail::BufferizableOpInterfaceInterfaceTraits::FallbackModel<mlir::tensor::(anonymous namespace)::ExpandShapeOpInterface>::bufferize(mlir::bufferization::detail::BufferizableOpInterfaceInterfaceTraits::Concept const*, mlir::Operation*, mlir::RewriterBase&, mlir::bufferization::BufferizationOptions const&) BufferizableOpInterfaceImpl.cpp:0:0
#12 0x000055c527fa2340 mlir::bufferization::bufferizeOp(mlir::Operation*, mlir::bufferization::BufferizationOptions const&, mlir::bufferization::BufferizationStatistics*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x1746340)
#13 0x000055c527fa604d (anonymous namespace)::OneShotBufferizePass::runOnOperation() Bufferize.cpp:0:0
#14 0x000055c52a9aad66 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x414ed66)
#15 0x000055c52a9ab690 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x414f690)
#16 0x000055c52a9adc62 mlir::PassManager::run(mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x4151c62)
#17 0x000055c52a9a63da performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#18 0x000055c52a9a602d 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&)::$_0>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#19 0x000055c52aa51985 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) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x41f5985)
#20 0x000055c52a9a0015 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x4144015)
#21 0x000055c52a9a02bf mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x41442bf)
#22 0x000055c52a9a05ee mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x41445ee)
#23 0x000055c527a2af07 main (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x11cef07)
#24 0x00007f548e571083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3
#25 0x000055c527a2aa7e _start (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x11cea7e)

Metadata

Metadata

Assignees

No one assigned

    Labels

    crashPrefer [crash-on-valid] or [crash-on-invalid]mlir:bufferizationBufferization infrastructure

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions