<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/60662>60662</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[mlir] tensor.from_elements on complex crashes during folding
</td>
</tr>
<tr>
<th>Labels</th>
<td>
mlir:core,
mlir:tensor,
crash
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
d0k
</td>
</tr>
</table>
<pre>
```
func.func @from_elements.constant_complex() -> tensor<3xcomplex<f32>> {
%c1 = arith.constant dense<(1.2, 2.3)> : tensor<complex<f32>>
%complex1 = tensor.extract %c1[] : tensor<complex<f32>>
%c2 = arith.constant dense<(3.2, 2.1)> : tensor<complex<f32>>
%complex2 = tensor.extract %c2[] : tensor<complex<f32>>
%tensor = tensor.from_elements %complex1, %complex2, %complex1 : tensor<3xcomplex<f32>>
return %tensor : tensor<3xcomplex<f32>>
}
```
```
$ mlir-opt -canonicalize complex.mlir
mlir-opt: mlir/lib/IR/BuiltinAttributes.cpp:902: static mlir::DenseElementsAttr mlir::DenseElementsAttr::get(mlir::ShapedType, ArrayRef<mlir::Attribute>): Assertion `attr.isa<StringAttr>() && "expected string value for non integer/index/float element"' 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 -canonicalize complex.mlir
...
#9 0x0000564e01be4779 mlir::DenseElementsAttr::get(mlir::ShapedType, llvm::ArrayRef<mlir::Attribute>) (bin/mlir-opt+0x4076779)
#10 0x0000564e012785a0 mlir::tensor::FromElementsOp::fold(mlir::tensor::FromElementsOpGenericAdaptor<llvm::ArrayRef<mlir::Attribute>>) (bin/mlir-opt+0x370a5a0)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVdtu4zYQ_Rr6ZRCBGupiP_hB8aUoUKCLTd8XlDSS2ZVIgaQWTr--oC5xDCTbZGsYtjScmXPmciTpnGo10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