<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/61044>61044</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [mlir] Convert-Tensor-To-SPIRV Pass triggers Assertion Failure "ArrayType needs at least one element".
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          Colloportus0
      </td>
    </tr>
</table>

<pre>
    MLIR built at commit   398cddf6
Reproduced with:  
`mlir-opt --convert-tensor-to-spirv temp.mlir`

temp.mlir:
``` milr 
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:
```console  
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
```
 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWl1P67jW_jXhxqJKnO8LLroLaJBAIEBbet-bynFWW59x7BzbYdP59Ud2kjZpGzbM2WeGmdlVBU2yvPysDz9esU20Z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