Skip to content

[mlir] affine-parallelize pass crashed with assertion failure "non-terminal symbol / loop IV expected". #64287

@Colloportus0

Description

@Colloportus0

MLIR built at commit b4c54b2
Reproduced with:
mlir-opt --affine-parallelize="max-nested=1 parallel-reductions" temp.mlir

temp.mlir:


  func.func @func1(%arg0: memref<9x9xi32>, %arg1: i1) {
    %idx1879048192 = index.constant 1879048192
    %idx0 = index.constant 0
    %c6 = arith.constant 6 : index
    %c0_i64 = arith.constant 0 : i64
    %c1_i64 = arith.constant 1 : i64
    %c807538455_i64 = arith.constant 807538455 : i64
    %c0 = arith.constant 0 : index
    %c1 = arith.constant 1 : index
    %c2 = arith.constant 2 : index 
    %8 = tensor.empty(%c1, %c1) : tensor<?x?x6xi1>
    %14 = tensor.empty() : tensor<31x31xf16>
    %20 = bufferization.to_memref %8 : memref<?x?x6xi1>
    %26 = scf.index_switch %c1 -> tensor<?x31x6xf16> 
    case 2 {
      %alloc_62 = memref.alloc(%c1, %c2) : memref<?x?x6x9xi1>
      %dim = memref.dim %20, %c0 : memref<?x?x6xi1>
      %dim_63 = memref.dim %20, %c1 : memref<?x?x6xi1>
      affine.for %arg2 = 0 to %dim {
        affine.for %arg3 = 0 to %dim_63 {
          affine.for %arg4 = 0 to 6 {
            affine.for %arg5 = 0 to 9 {
              %38 = affine.load %20[%arg2, %arg3, %arg4] : memref<?x?x6xi1>
              affine.store %38, %alloc_62[%arg2, %arg3, %arg4, %arg5] : memref<?x?x6x9xi1>
            }
          }
        }
      }
      %38 = tensor.empty(%idx0) : tensor<?x31x6xf16>
      scf.yield %38 : tensor<?x31x6xf16>
    }
    default {
      %37 = scf.parallel (%arg2) = (%c1) to (%c2) step (%c1) init (%c807538455_i64) -> i64 {
        scf.reduce(%c0_i64)  : i64 {
        ^bb0(%arg3: i64, %arg4: i64):
          %extracted_62 = tensor.extract %14[%c1, %c0] : tensor<31x31xf16>
          scf.reduce.return %c1_i64 : i64
        }
        scf.yield
      }
      %38 = tensor.empty(%c6) : tensor<?x31x6xf16>
      scf.yield %38 : tensor<?x31x6xf16>
    } 
    return
  }

trace:

Assertion failed: ((isTopLevelValue(val) || isAffineInductionVar(val)) && "non-terminal symbol / loop IV expected"), function addInductionVarOrTerminalSymbol, file AffineStructures.cpp, line 44.
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 "--affine-parallelize=max-nested=1 parallel-reductions" temp.mlir
 #0 0x00000001026a0548 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/workspace/build/bin/mlir-opt+0x1002f8548)
 #1 0x000000010269e7e4 llvm::sys::RunSignalHandlers() (/workspace/build/bin/mlir-opt+0x1002f67e4)
 #2 0x00000001026a0bf4 SignalHandler(int) (/workspace/build/bin/mlir-opt+0x1002f8bf4)
 #3 0x00000001a46cd4c4 (/usr/lib/system/libsystem_platform.dylib+0x1803414c4)
 #4 0x00000001a46b5ee0 (/usr/lib/system/libsystem_pthread.dylib+0x180329ee0)
 #5 0x00000001a45f0340 (/usr/lib/system/libsystem_c.dylib+0x180264340)
 #6 0x00000001a45ef754 (/usr/lib/system/libsystem_c.dylib+0x180263754)
 #7 0x00000001064be744 mlir::affine::FlatAffineValueConstraints::addAffineForOpDomain(mlir::affine::AffineForOp) (.cold.1) (/workspace/build/bin/mlir-opt+0x104116744)
 #8 0x00000001026ec348 mlir::affine::FlatAffineValueConstraints::addInductionVarOrTerminalSymbol(mlir::Value) (/workspace/build/bin/mlir-opt+0x100344348)
 #9 0x00000001026ecc44 mlir::affine::FlatAffineValueConstraints::addBound(mlir::presburger::BoundType, unsigned int, mlir::AffineMap, mlir::ValueRange) (/workspace/build/bin/mlir-opt+0x100344c44)
#10 0x00000001026ec8c0 mlir::affine::FlatAffineValueConstraints::addAffineForOpDomain(mlir::affine::AffineForOp) (/workspace/build/bin/mlir-opt+0x1003448c0)
#11 0x00000001026ea4e8 mlir::affine::getIndexSet(llvm::MutableArrayRef<mlir::Operation*>, mlir::affine::FlatAffineValueConstraints*) (/workspace/build/bin/mlir-opt+0x1003424e8)
#12 0x00000001026ea6b8 mlir::affine::MemRefAccess::getAccessRelation(mlir::affine::FlatAffineRelation&) const (/workspace/build/bin/mlir-opt+0x1003426b8)
#13 0x00000001026e93fc mlir::affine::checkMemrefAccessDependence(mlir::affine::MemRefAccess const&, mlir::affine::MemRefAccess const&, unsigned int, mlir::affine::FlatAffineValueConstraints*, llvm::SmallVector<mlir::affine::DependenceComponent, 2u>*, bool) (/workspace/build/bin/mlir-opt+0x1003413fc)
#14 0x00000001026e9044 mlir::affine::isLoopMemoryParallel(mlir::affine::AffineForOp) (/workspace/build/bin/mlir-opt+0x100341044)
#15 0x00000001026e8e70 mlir::affine::isLoopParallel(mlir::affine::AffineForOp, llvm::SmallVectorImpl<mlir::affine::LoopReduction>*) (/workspace/build/bin/mlir-opt+0x100340e70)
#16 0x000000010275baa8 void llvm::function_ref<void (mlir::Operation*)>::callback_fn<std::__1::enable_if<!llvm::is_one_of<mlir::affine::AffineForOp, mlir::Operation*, mlir::Region*, mlir::Block*>::value && std::is_same<void, void>::value, void>::type mlir::detail::walk<(mlir::WalkOrder)0, mlir::ForwardIterator, (anonymous namespace)::AffineParallelize::runOnOperation()::$_0, mlir::affine::AffineForOp, void>(mlir::Operation*, (anonymous namespace)::AffineParallelize::runOnOperation()::$_0&&)::'lambda'(mlir::Operation*)>(long, mlir::Operation*) (/workspace/build/bin/mlir-opt+0x1003b3aa8)
#17 0x0000000102a43b2c void mlir::detail::walk<mlir::ForwardIterator>(mlir::Operation*, llvm::function_ref<void (mlir::Operation*)>, mlir::WalkOrder) (/workspace/build/bin/mlir-opt+0x10069bb2c)
#18 0x0000000102a43ba0 void mlir::detail::walk<mlir::ForwardIterator>(mlir::Operation*, llvm::function_ref<void (mlir::Operation*)>, mlir::WalkOrder) (/workspace/build/bin/mlir-opt+0x10069bba0)
#19 0x0000000102a43ba0 void mlir::detail::walk<mlir::ForwardIterator>(mlir::Operation*, llvm::function_ref<void (mlir::Operation*)>, mlir::WalkOrder) (/workspace/build/bin/mlir-opt+0x10069bba0)
#20 0x000000010275b49c (anonymous namespace)::AffineParallelize::runOnOperation() (/workspace/build/bin/mlir-opt+0x1003b349c)
#21 0x0000000104d29e34 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/workspace/build/bin/mlir-opt+0x102981e34)
#22 0x0000000104d2a524 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/workspace/build/bin/mlir-opt+0x102982524)
#23 0x0000000104d2b5d8 mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool) (/workspace/build/bin/mlir-opt+0x1029835d8)
#24 0x0000000104d29f90 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/workspace/build/bin/mlir-opt+0x102981f90)
#25 0x0000000104d2a524 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/workspace/build/bin/mlir-opt+0x102982524)
#26 0x0000000104d2c3bc mlir::PassManager::run(mlir::Operation*) (/workspace/build/bin/mlir-opt+0x1029843bc)
#27 0x0000000104d24808 performActions(llvm::raw_ostream&, std::__1::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) (/workspace/build/bin/mlir-opt+0x10297c808)
#28 0x0000000104d23d30 mlir::LogicalResult llvm::function_ref<mlir::LogicalResult (std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>::callback_fn<mlir::MlirOptMain(llvm::raw_ostream&, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::$_1>(long, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) (/workspace/build/bin/mlir-opt+0x10297bd30)
#29 0x0000000104da2be0 mlir::splitAndProcessBuffer(std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<mlir::LogicalResult (std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>, llvm::raw_ostream&, bool, bool) (/workspace/build/bin/mlir-opt+0x1029fabe0)
#30 0x0000000104d1e6e4 mlir::MlirOptMain(llvm::raw_ostream&, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/workspace/build/bin/mlir-opt+0x1029766e4)
#31 0x0000000104d1eb54 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/workspace/build/bin/mlir-opt+0x102976b54)
#32 0x00000001023ab58c main (/workspace/build/bin/mlir-opt+0x10000358c)
#33 0x000000010dced088 

Metadata

Metadata

Assignees

Labels

crashPrefer [crash-on-valid] or [crash-on-invalid]mlir:affine

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions