<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61383>61383</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[MLIR]Converting tosa to linalg crashed with Assertion Failure `isIntOrFloat() && "only integers and floats have a bitwidth"'
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
BealZephyr
</td>
</tr>
</table>
<pre>
Test on commit: https://github.com/llvm/llvm-project/commit/e0282cb4da9402de5712ac7855af6c71a03d0c19
The same crash occurred in [LLVM 16](https://github.com/llvm/llvm-project/tree/release/16.x)
steps to reproduce:
```
mlir-opt -pass-pipeline=builtin.module(func.func(tosa-to-linalg)) test.mlir
```
test case:
```
func.func @main(%arg0: tensor<13x21x3x!quant.uniform<u8:f32, 0.015655439347028732:127>>) {
%0 = "tosa.rescale"(%arg0) {double_round = false, input_zp = 127 : i32, multiplier = array<i32: 1073741824>, output_zp = -1 : i32, per_channel = false, scale32 = true, shift = array<i32: 30>} : (tensor<13x21x3x!quant.uniform<u8:f32, 0.015655439347028732:127>>) -> tensor<13x21x3x!quant.uniform<i8:f32, 0.015655439347028732:-1>>
return
}
```
crash trace:
```
mlir-opt: /home/verify/llvm-project/mlir/lib/IR/Types.cpp:112: unsigned int mlir::Type::getIntOrFloatBitWidth() const: Assertion `isIntOrFloat() && "only integers and floats have a bitwidth"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /home/verify/llvm-project/build/bin/mlir-opt -pass-pipeline=builtin.module(func.func(tosa-to-linalg)) test.mlir
#0 0x0000560b7c6ee05a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/verify/llvm-project/build/bin/mlir-opt+0x22205a)
#1 0x0000560b7c6eb55c SignalHandler(int) Signals.cpp:0:0
#2 0x00007f4fe17de980 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
#3 0x00007f4fe08d6e87 raise /build/glibc-CVJwZb/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
#4 0x00007f4fe08d87f1 abort /build/glibc-CVJwZb/glibc-2.27/stdlib/abort.c:81:0
#5 0x00007f4fe08c83fa __assert_fail_base /build/glibc-CVJwZb/glibc-2.27/assert/assert.c:89:0
#6 0x00007f4fe08c8472 (/lib/x86_64-linux-gnu/libc.so.6+0x30472)
#7 0x0000560b7e1540bf mlir::Type::getIntOrFloatBitWidth() const (/home/verify/llvm-project/build/bin/mlir-opt+0x1c880bf)
#8 0x0000560b7db4a00b (anonymous namespace)::RescaleConverter::matchAndRewrite(mlir::tosa::RescaleOp, mlir::PatternRewriter&) const::'lambda0'(mlir::OpBuilder&, mlir::Location, mlir::ValueRange)::operator()(mlir::OpBuilder&, mlir::Location, mlir::ValueRange) const TosaToLinalg.cpp:0:0
#9 0x0000560b7cbfa184 buildGenericRegion(mlir::OpBuilder&, mlir::Location, mlir::Region&, mlir::ValueRange, mlir::ValueRange, llvm::function_ref<void (mlir::OpBuilder&, mlir::Location, mlir::ValueRange)>) LinalgOps.cpp:0:0
#10 0x0000560b7cc155d7 mlir::linalg::GenericOp::build(mlir::OpBuilder&, mlir::OperationState&, mlir::TypeRange, mlir::ValueRange, mlir::ValueRange, llvm::ArrayRef<mlir::AffineMap>, llvm::ArrayRef<mlir::utils::IteratorType>, llvm::StringRef, llvm::StringRef, llvm::function_ref<void (mlir::OpBuilder&, mlir::Location, mlir::ValueRange)>, llvm::ArrayRef<mlir::NamedAttribute>) (/home/verify/llvm-project/build/bin/mlir-opt+0x7495d7)
#11 0x0000560b7cc1576a mlir::linalg::GenericOp::build(mlir::OpBuilder&, mlir::OperationState&, mlir::TypeRange, mlir::ValueRange, mlir::ValueRange, llvm::ArrayRef<mlir::AffineMap>, llvm::ArrayRef<mlir::utils::IteratorType>, llvm::function_ref<void (mlir::OpBuilder&, mlir::Location, mlir::ValueRange)>, llvm::ArrayRef<mlir::NamedAttribute>) (/home/verify/llvm-project/build/bin/mlir-opt+0x74976a)
#12 0x0000560b7db6b170 (anonymous namespace)::RescaleConverter::matchAndRewrite(mlir::tosa::RescaleOp, mlir::PatternRewriter&) const TosaToLinalg.cpp:0:0
#13 0x0000560b7db424c8 mlir::detail::OpOrInterfaceRewritePatternBase<mlir::tosa::RescaleOp>::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const (/home/verify/llvm-project/build/bin/mlir-opt+0x16764c8)
#14 0x0000560b7e38a639 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&)>) (/home/verify/llvm-project/build/bin/mlir-opt+0x1ebe639)
#15 0x0000560b7e028607 (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*, mlir::ConversionPatternRewriter&) DialectConversion.cpp:0:0
#16 0x0000560b7e0292a8 (anonymous namespace)::OperationConverter::convertOperations(llvm::ArrayRef<mlir::Operation*>, llvm::function_ref<void (mlir::Diagnostic&)>) DialectConversion.cpp:0:0
#17 0x0000560b7e02ce7f mlir::applyFullConversion(mlir::Operation*, mlir::ConversionTarget&, mlir::FrozenRewritePatternSet const&) (/home/verify/llvm-project/build/bin/mlir-opt+0x1b60e7f)
#18 0x0000560b7db3942b (anonymous namespace)::TosaToLinalg::runOnOperation() TosaToLinalgPass.cpp:0:0
#19 0x0000560b7dfabea9 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/home/verify/llvm-project/build/bin/mlir-opt+0x1adfea9)
#20 0x0000560b7dfac1ca mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/home/verify/llvm-project/build/bin/mlir-opt+0x1ae01ca)
#21 0x0000560b7dfac548 mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::'lambda'(mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo&)::operator()(mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo&) const Pass.cpp:0:0
#22 0x0000560b7dfab685 mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool) (/home/verify/llvm-project/build/bin/mlir-opt+0x1adf685)
#23 0x0000560b7dfabe1a mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/home/verify/llvm-project/build/bin/mlir-opt+0x1adfe1a)
#24 0x0000560b7dfacd03 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (.constprop.495) Pass.cpp:0:0
#25 0x0000560b7dfad3ed mlir::PassManager::run(mlir::Operation*) (/home/verify/llvm-project/build/bin/mlir-opt+0x1ae13ed)
#26 0x0000560b7dfa03f3 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#27 0x0000560b7dfa0b29 processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, llvm::ThreadPool*) MlirOptMain.cpp:0:0
#28 0x0000560b7dfa0e51 mlir::LogicalResult llvm::function_ref<mlir::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&)::'lambda'(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#29 0x0000560b7e066c80 mlir::splitAndProcessBuffer(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<mlir::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>, llvm::raw_ostream&, bool, bool) (/home/verify/llvm-project/build/bin/mlir-opt+0x1b9ac80)
#30 0x0000560b7df9db33 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/home/verify/llvm-project/build/bin/mlir-opt+0x1ad1b33)
#31 0x0000560b7dfa1238 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&, bool) (/home/verify/llvm-project/build/bin/mlir-opt+0x1ad5238)
#32 0x0000560b7c6ba470 main (/home/verify/llvm-project/build/bin/mlir-opt+0x1ee470)
#33 0x00007f4fe08b9c87 __libc_start_main /build/glibc-CVJwZb/glibc-2.27/csu/../csu/libc-start.c:344:0
#34 0x0000560b7c6cd10a _start (/home/verify/llvm-project/build/bin/mlir-opt+0x20110a)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWt1T4zgS_2vEi4qULPnzgYcAkzuu4KAYaq9qX1KyLCe6VSSvJM-Q_euvJBuwDZmEIbs3u7VVM8QfUn_9ulvdsqi1YqU4PwPJOUguT2jr1tqcnXMqf-bNemtOSl1tzx64dVAryPRmIxwgc7h2rrGAzAFeALxYCbduyxnTG4AXUn55-jltjP4vZw7gRT8VLzjCOWZlXN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