Skip to content

[mlir][spirv][tensor] Convert-Tensor-To-SPIRV Pass triggers Assertion Failure "ArrayType needs at least one element" #61044

@Colloportus0

Description

@Colloportus0

MLIR built at commit 398cddf
Reproduced with:

mlir-opt --convert-tensor-to-spirv temp.mlir

temp.mlir:

module {
  func.func @main(%arg0: tensor<1x1x2x2x1xf16>) -> (tensor<1x1x2x2x2xf16> , tensor<1x1x2x0xf16>  ) {
    %0 = "tosa.const"() {value = dense<[[[[[6.835930e-01, 9.765620e-01]]]]]> : tensor<1x1x1x1x2xf16>} : () -> tensor<1x1x1x1x2xf16>
    %1 = "tosa.const"() {value = dense<> : tensor<1x1x2x0xf16>} : () -> tensor<1x1x2x0xf16>
    %2 = "tosa.reciprocal"(%0) : (tensor<1x1x1x1x2xf16>) -> tensor<1x1x1x1x2xf16>
    %3 = "tosa.mul"(%arg0, %2) {shift = 0 : i32} : (tensor<1x1x2x2x1xf16>, tensor<1x1x1x1x2xf16>) -> tensor<1x1x2x2x2xf16>
    return %3, %1 : tensor<1x1x2x2x2xf16>, tensor<1x1x2x0xf16>
  }
}

trace:

$ mlir-opt --convert-tensor-to-spirv temp.mlir
Assertion failed: (elementCount && "ArrayType needs at least one element"), function get, file SPIRVTypes.cpp, line 52.
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 --convert-tensor-to-spirv temp.mlir
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  mlir-opt                 0x0000000104ebc770 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  mlir-opt                 0x0000000104ebb7d8 llvm::sys::RunSignalHandlers() + 112
2  mlir-opt                 0x0000000104ebce08 SignalHandler(int) + 344
3  libsystem_platform.dylib 0x000000019cc194c4 _sigtramp + 56
4  libsystem_pthread.dylib  0x000000019cc01ee0 pthread_kill + 288
5  libsystem_c.dylib        0x000000019cb3c340 abort + 168
6  libsystem_c.dylib        0x000000019cb3b754 err + 0
7  mlir-opt                 0x0000000106c80d04 mlir::spirv::ArrayType::get(mlir::Type, unsigned int, unsigned int) (.cold.1) + 0
8  mlir-opt                 0x0000000105e06db8 mlir::spirv::ArrayType::get(mlir::Type, unsigned int) + 208
9  mlir-opt                 0x0000000105e18104 std::__1::__function::__func<std::__1::enable_if<std::is_invocable_v<mlir::SPIRVTypeConverter::SPIRVTypeConverter(mlir::spirv::TargetEnvAttr, mlir::SPIRVConversionOptions const&)::$_5, mlir::TensorType, llvm::SmallVectorImpl<mlir::Type>&, llvm::ArrayRef<mlir::Type>>, std::__1::function<std::__1::optional<mlir::LogicalResult> (mlir::Type, llvm::SmallVectorImpl<mlir::Type>&, llvm::ArrayRef<mlir::Type>)>>::type mlir::TypeConverter::wrapCallback<mlir::TensorType, std::__1::enable_if<std::is_invocable_v<mlir::SPIRVTypeConverter::SPIRVTypeConverter(mlir::spirv::TargetEnvAttr, mlir::SPIRVConversionOptions const&)::$_5, mlir::TensorType>, std::__1::function<std::__1::optional<mlir::LogicalResult> (mlir::Type, llvm::SmallVectorImpl<mlir::Type>&, llvm::ArrayRef<mlir::Type>)>>::type mlir::TypeConverter::wrapCallback<mlir::TensorType, mlir::SPIRVTypeConverter::SPIRVTypeConverter(mlir::spirv::TargetEnvAttr, mlir::SPIRVConversionOptions const&)::$_5>(mlir::SPIRVTypeConverter::SPIRVTypeConverter(mlir::spirv::TargetEnvAttr, mlir::SPIRVConversionOptions const&)::$_5&&)::'lambda'(mlir::TensorType, llvm::SmallVectorImpl<mlir::Type>&, llvm::ArrayRef<mlir::Type>)>(mlir::SPIRVTypeConverter::SPIRVTypeConverter(mlir::spirv::TargetEnvAttr, mlir::SPIRVConversionOptions const&)::$_5&&)::'lambda'(mlir::Type, llvm::SmallVectorImpl<mlir::Type>&, llvm::ArrayRef<mlir::Type>), std::__1::allocator<std::__1::enable_if<std::is_invocable_v<mlir::SPIRVTypeConverter::SPIRVTypeConverter(mlir::spirv::TargetEnvAttr, mlir::SPIRVConversionOptions const&)::$_5, mlir::TensorType, llvm::SmallVectorImpl<mlir::Type>&, llvm::ArrayRef<mlir::Type>>, std::__1::function<std::__1::optional<mlir::LogicalResult> (mlir::Type, llvm::SmallVectorImpl<mlir::Type>&, llvm::ArrayRef<mlir::Type>)>>::type mlir::TypeConverter::wrapCallback<mlir::TensorType, std::__1::enable_if<std::is_invocable_v<mlir::SPIRVTypeConverter::SPIRVTypeConverter(mlir::spirv::TargetEnvAttr, mlir::SPIRVConversionOptions const&)::$_5, mlir::TensorType>, std::__1::function<std::__1::optional<mlir::LogicalResult> (mlir::Type, llvm::SmallVectorImpl<mlir::Type>&, llvm::ArrayRef<mlir::Type>)>>::type mlir::TypeConverter::wrapCallback<mlir::TensorType, mlir::SPIRVTypeConverter::SPIRVTypeConverter(mlir::spirv::TargetEnvAttr, mlir::SPIRVConversionOptions const&)::$_5>(mlir::SPIRVTypeConverter::SPIRVTypeConverter(mlir::spirv::TargetEnvAttr, mlir::SPIRVConversionOptions const&)::$_5&&)::'lambda'(mlir::TensorType, llvm::SmallVectorImpl<mlir::Type>&, llvm::ArrayRef<mlir::Type>)>(mlir::SPIRVTypeConverter::SPIRVTypeConverter(mlir::spirv::TargetEnvAttr, mlir::SPIRVConversionOptions const&)::$_5&&)::'lambda'(mlir::Type, llvm::SmallVectorImpl<mlir::Type>&, llvm::ArrayRef<mlir::Type>)>, std::__1::optional<mlir::LogicalResult> (mlir::Type, llvm::SmallVectorImpl<mlir::Type>&, llvm::ArrayRef<mlir::Type>)>::operator()(mlir::Type&&, llvm::SmallVectorImpl<mlir::Type>&, llvm::ArrayRef<mlir::Type>&&) + 384
10 mlir-opt                 0x00000001066aa340 mlir::TypeConverter::convertType(mlir::Type, llvm::SmallVectorImpl<mlir::Type>&) + 764
11 mlir-opt                 0x00000001066a9c60 mlir::detail::ConversionPatternRewriterImpl::remapValues(llvm::StringRef, std::__1::optional<mlir::Location>, mlir::PatternRewriter&, mlir::ValueRange, llvm::SmallVectorImpl<mlir::Value>&) + 220
12 mlir-opt                 0x00000001066ae740 mlir::ConversionPattern::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const + 160
13 mlir-opt                 0x000000010691e0a0 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&)>) + 1420
14 mlir-opt                 0x00000001066b993c (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*, mlir::ConversionPatternRewriter&) + 1948
15 mlir-opt                 0x00000001066b2564 (anonymous namespace)::OperationConverter::convertOperations(llvm::ArrayRef<mlir::Operation*>, llvm::function_ref<void (mlir::Diagnostic&)>) + 960
16 mlir-opt                 0x00000001066b462c mlir::applyPartialConversion(mlir::Operation*, mlir::ConversionTarget&, mlir::FrozenRewritePatternSet const&, llvm::DenseSet<mlir::Operation*, llvm::DenseMapInfo<mlir::Operation*, void>>*) + 80
17 mlir-opt                 0x00000001062f3440 (anonymous namespace)::ConvertTensorToSPIRVPass::runOnOperation() + 316
18 mlir-opt                 0x0000000106677364 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) + 428
19 mlir-opt                 0x0000000106677894 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) + 320
20 mlir-opt                 0x0000000106679204 mlir::PassManager::run(mlir::Operation*) + 1148
21 mlir-opt                 0x0000000106672724 performActions(llvm::raw_ostream&, std::__1::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) + 476
22 mlir-opt                 0x0000000106672324 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&) + 520
23 mlir-opt                 0x00000001066dc7e8 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) + 656
24 mlir-opt                 0x000000010667056c mlir::MlirOptMain(llvm::raw_ostream&, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) + 132
25 mlir-opt                 0x0000000106670d5c mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&, bool) + 1972
26 mlir-opt                 0x0000000104d5a12c main + 108
27 dyld                     0x000000010a12d088 start + 516
zsh: abort      mlir-opt --convert-tensor-to-spirv temp.mlir

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions