Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure : unimplemented: found unhandled case of expansion/collapse in aten.view #16887

Open
gabeweisz opened this issue Mar 25, 2024 · 9 comments
Assignees
Labels
bug 🐞 Something isn't working

Comments

@gabeweisz
Copy link

What happened?

iree-compile: /path_to/iree/third_party/llvm-project/mlir/include/mlir/IR/UseDefLists.h:198: mlir::IRObjectWithUseListmlir::OpOperand::~IRObjectWithUseList() [OperandType = mlir::OpOperand]: Assertion `use_empty() && "Cannot destroy a value that still has uses!"' failed.

Steps to reproduce your issue

iree-build/tools/iree-compile model_small.mlir.txt
model_small.mlir.txt

What component(s) does this issue relate to?

No response

Version information

No response

Additional context

No response

@gabeweisz gabeweisz added the bug 🐞 Something isn't working label Mar 25, 2024
@stellaraccident stellaraccident self-assigned this Mar 25, 2024
@renxida
Copy link
Contributor

renxida commented Mar 25, 2024

llvm/torch-mlir#2969 (comment)

The above issue implements lowering for onnx.LSTM and i'm having similar issues lowering to linalg

@renxida
Copy link
Contributor

renxida commented Mar 25, 2024

from what @qedawkins told me, the "failure destroying a value" error might be a spurious error message generated by the unrolling process in the dialect conversion framework.

@gabeweisz could you post the full log & full error message of torch-mlir-opt?

@gabeweisz
Copy link
Author

It might be - I'm actually running this in the iree compiler. I posted this here rather than in their github because that is what the instructions at the top of the error message told me to do

Full stack when running on the .mlir file attached:
iree-compile: /path_to/iree/third_party/llvm-project/mlir/include/mlir/IR/UseDefLists.h:198: mlir::IRObjectWithUseListmlir::OpOperand::~IRObjectWithUseList() [OperandType = mlir::OpOperand]: Assertion `use_empty() && "Cannot destroy a value that still has uses!"' failed.
Please report issues to https://github.com/openxla/iree/issues and include the crash backtrace.
#0 0x00007f776ed58e36 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /path_to/iree/third_party/llvm-project/llvm/lib/Support/Unix/Signals.inc:723:13
#1 0x00007f776ed56ff0 llvm::sys::RunSignalHandlers() /path_to/iree/third_party/llvm-project/llvm/lib/Support/Signals.cpp:106:18
#2 0x00007f776ed594eb SignalHandler(int) /path_to/iree/third_party/llvm-project/llvm/lib/Support/Unix/Signals.inc:413:1
#3 0x00007f7768c644d0 (/usr/lib64/libc.so.6+0x384d0)
#4 0x00007f7768cb20bc (/usr/lib64/libc.so.6+0x860bc)
#5 0x00007f7768c64432 raise (/usr/lib64/libc.so.6+0x38432)
#6 0x00007f7768c4e4b2 abort (/usr/lib64/libc.so.6+0x224b2)
#7 0x00007f7768c4e3d5 (/usr/lib64/libc.so.6+0x223d5)
#8 0x00007f7768c5d362 (/usr/lib64/libc.so.6+0x31362)
#9 0x00007f776eda662f mlir::IRObjectWithUseListmlir::BlockOperand::~IRObjectWithUseList() /path_to/iree/third_party/llvm-project/mlir/include/mlir/IR/UseDefLists.h:198:5
#10 0x00007f776eda662f mlir::Block::~Block() /path_to/iree/third_party/llvm-project/mlir/lib/IR/Block.cpp:24:1
#11 0x00007f7772700e69 (anonymous namespace)::CreateBlockRewrite::rollback() /path_to/iree/third_party/llvm-project/mlir/lib/Transforms/Utils/DialectConversion.cpp:286:7
#12 0x00007f77726eacab bool std::operator==<std::unique_ptr<(anonymous namespace)::IRRewrite, std::default_delete<(anonymous namespace)::IRRewrite>>>(std::reverse_iterator<std::unique_ptr<(anonymous namespace)::IRRewrite, std::default_delete<(anonymous namespace)::IRRewrite>>> const&, std::reverse_iterator<std::unique_ptr<(anonymous namespace)::IRRewrite, std::default_delete<(anonymous namespace)::IRRewrite>>> const&) /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/bits/stl_iterator.h:446:25
#13 0x00007f77726eacab bool std::operator!=<std::unique_ptr<(anonymous namespace)::IRRewrite, std::default_delete<(anonymous namespace)::IRRewrite>>
>(std::reverse_iterator<std::unique_ptr<(anonymous namespace)::IRRewrite, std::default_delete<(anonymous namespace)::IRRewrite>>> const&, std::reverse_iterator<std::unique_ptr<(anonymous namespace)::IRRewrite, std::default_delete<(anonymous namespace)::IRRewrite>>> const&) /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/bits/stl_iterator.h:460:20
#14 0x00007f77726eacab mlir::detail::ConversionPatternRewriterImpl::undoRewrites(unsigned int) /path_to/iree/third_party/llvm-project/mlir/lib/Transforms/Utils/DialectConversion.cpp:1224:22
#15 0x00007f77726f0fd8 mlir::OperationConverter::convertOperations(llvm::ArrayRefmlir::Operation*) /path_to/iree/third_party/llvm-project/mlir/lib/Transforms/Utils/DialectConversion.cpp:0:27
#16 0x00007f77726f817c mlir::applyPartialConversion(llvm::ArrayRefmlir::Operation*, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig) /path_to/iree/third_party/llvm-project/mlir/lib/Transforms/Utils/DialectConversion.cpp:3610:22
#17 0x00007f77726f817c mlir::applyPartialConversion(mlir::Operation*, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig) /path_to/iree/third_party/llvm-project/mlir/lib/Transforms/Utils/DialectConversion.cpp:3616:10
#18 0x00007f776f85700b (anonymous namespace)::ConvertTorchToLinalg::runOnOperation() /path_to/iree/third_party/torch-mlir/lib/Conversion/TorchToLinalg/TorchToLinalg.cpp:87:16
#19 0x00007f776eeffc3f mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int)::$_1::operator()() const /path_to/iree/third_party/llvm-project/mlir/lib/Pass/Pass.cpp:0:17
#20 0x00007f776eeffc3f void llvm::function_ref<void ()>::callback_fn<mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int)::$_1>(long) /path_to/iree/third_party/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:12
#21 0x00007f776eeffc3f llvm::function_ref<void ()>::operator()() const /path_to/iree/third_party/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:12
#22 0x00007f776eeffc3f void mlir::MLIRContext::executeAction<mlir::PassExecutionAction, mlir::Pass&>(llvm::function_ref<void ()>, llvm::ArrayRefmlir::IRUnit, mlir::Pass&) /path_to/iree/third_party/llvm-project/mlir/include/mlir/IR/MLIRContext.h:275:7
#23 0x00007f776eeffc3f mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) /path_to/iree/third_party/llvm-project/mlir/lib/Pass/Pass.cpp:513:21
#24 0x00007f776ef00409 mlir::LogicalResult::failed() const /path_to/iree/third_party/llvm-project/mlir/include/mlir/Support/LogicalResult.h:44:33
#25 0x00007f776ef00409 mlir::failed(mlir::LogicalResult) /path_to/iree/third_party/llvm-project/mlir/include/mlir/Support/LogicalResult.h:72:58
#26 0x00007f776ef00409 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) /path_to/iree/third_party/llvm-project/mlir/lib/Pass/Pass.cpp:585:9
#27 0x00007f776ef05bbe mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_0::operator()(mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo&) const /path_to/iree/third_party/llvm-project/mlir/lib/Pass/Pass.cpp:810:5
#28 0x00007f776ef05c6e mlir::LogicalResult::failed() const /path_to/iree/third_party/llvm-project/mlir/include/mlir/Support/LogicalResult.h:44:33
#29 0x00007f776ef05c6e mlir::failed(mlir::LogicalResult) /path_to/iree/third_party/llvm-project/mlir/include/mlir/Support/LogicalResult.h:72:58
#30 0x00007f776ef05c6e mlir::LogicalResult mlir::failableParallelForEach<__gnu_cxx::__normal_iterator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocatormlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>>, mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_0&>(mlir::MLIRContext*, __gnu_cxx::__normal_iterator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocatormlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>>, __gnu_cxx::__normal_iterator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocatormlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>>, mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_0&)::'lambda'()::operator()() const /path_to/iree/third_party/llvm-project/mlir/include/mlir/IR/Threading.h:62:11
#31 0x00007f776ef05c6e __gnu_cxx::__normal_iterator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocatormlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>> std::__invoke_impl<void, mlir::LogicalResult mlir::failableParallelForEach<__gnu_cxx::__normal_iterator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocatormlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>>, mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_0&>(mlir::MLIRContext*, __gnu_cxx::__normal_iterator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocatormlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>>, __gnu_cxx::__normal_iterator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocatormlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>>, mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_0&)::'lambda'()&>(std::__invoke_other, mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_0&) /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/bits/invoke.h:61:14
#32 0x00007f776ef05c6e std::enable_if<is_invocable_r_v<__gnu_cxx::__normal_iterator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocatormlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>>, mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_0&>, __gnu_cxx::__normal_iterator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocatormlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>>>::type std::__invoke_r<void, mlir::LogicalResult mlir::failableParallelForEach<__gnu_cxx::__normal_iterator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocatormlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>>, mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_0&>(mlir::MLIRContext*, __gnu_cxx::__normal_iterator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocatormlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>>, __gnu_cxx::__normal_iterator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocatormlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>>, mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_0&)::'lambda'()&>(mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_0&) /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/bits/invoke.h:111:2
#33 0x00007f776ef05c6e std::_Function_handler<void (), mlir::LogicalResult mlir::failableParallelForEach<__gnu_cxx::__normal_iterator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocatormlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>>, mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_0&>(mlir::MLIRContext*, __gnu_cxx::__normal_iterator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocatormlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>>, __gnu_cxx::__normal_iterator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocatormlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>>, mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_0&)::'lambda'()>::_M_invoke(std::_Any_data const&) /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/bits/std_function.h:290:9
#34 0x00007f776ee61f48 std::__future_base::_Task_setter<std::unique_ptr<std::__future_base::_Result, std::__future_base::_Result_base::_Deleter>, std::thread::_Invoker<std::tuple<std::function<void ()>>>, void>::operator()() const /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/future:1440:20
#35 0x00007f776ee61f48 std::unique_ptr<std::__future_base::_Result, std::__future_base::_Result_base::_Deleter> std::__invoke_impl<std::unique_ptr<std::__future_base::_Result, std::__future_base::_Result_base::_Deleter>, std::__future_base::_Task_setter<std::unique_ptr<std::__future_base::_Result, std::__future_base::_Result_base::_Deleter>, std::thread::_Invoker<std::tuple<std::function<void ()>>>, void>&>(std::__invoke_other, std::__future_base::_Task_setter<std::unique_ptr<std::__future_base::_Result, std::__future_base::_Result_base::_Deleter>, std::thread::_Invoker<std::tuple<std::function<void ()>>>, void>&) /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/bits/invoke.h:61:14
#36 0x00007f776ee61f48 std::enable_if<is_invocable_r_v<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter>, std::__future_base::_Task_setter<std::unique_ptr<std::__future_base::_Result, std::__future_base::_Result_base::_Deleter>, std::thread::_Invoker<std::tuple<std::function<void ()>>>, void>&>, std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter>>::type std::__invoke_r<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter>, std::__future_base::_Task_setter<std::unique_ptr<std::__future_base::_Result, std::__future_base::_Result_base::_Deleter>, std::thread::_Invoker<std::tuple<std::function<void ()>>>, void>&>(std::__future_base::_Task_setter<std::unique_ptr<std::__future_base::_Result, std::__future_base::_Result_base::_Deleter>, std::thread::_Invoker<std::tuple<std::function<void ()>>>, void>&) /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/bits/invoke.h:114:9
#37 0x00007f776ee61f48 std::_Function_handler<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> (), std::__future_base::_Task_setter<std::unique_ptr<std::__future_base::_Result, std::__future_base::_Result_base::_Deleter>, std::thread::_Invoker<std::tuple<std::function<void ()>>>, void>>::_M_invoke(std::_Any_data const&) /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/bits/std_function.h:290:9
#38 0x00007f776ee61e9a std::__future_base::_State_baseV2::_M_do_set(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>, bool) /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/future:591:13
#39 0x00007f7768cb5227 (/usr/lib64/libc.so.6+0x89227)
#40 0x00007f776ee6227a void std::call_once<void (std::__future_base::_State_baseV2::)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>, bool>(std::once_flag&, void (std::__future_base::_State_baseV2::&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>&&, bool&&) /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/mutex:859:15
#41 0x00007f776ee6227a std::__future_base::_State_baseV2::_M_set_result(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>, bool) /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/future:426:2
#42 0x00007f776ee6227a std::__future_base::_Deferred_state<std::thread::_Invoker<std::tuple<std::function<void ()>>>, void>::_M_complete_async() /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/future:1703:9
#43 0x00007f776ee62315 std::__atomic_base::load(std::memory_order) const /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/bits/atomic_base.h:488:9
#44 0x00007f776ee62315 std::__atomic_futex_unsigned<2147483648u>::_M_load(std::memory_order) /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/bits/atomic_futex.h:86:22
#45 0x00007f776ee62315 std::__atomic_futex_unsigned<2147483648u>::_M_load_when_equal(unsigned int, std::memory_order) /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/bits/atomic_futex.h:208:22
#46 0x00007f776ee62315 std::__future_base::_State_baseV2::wait() /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/future:351:12
#47 0x00007f776ee62315 std::__basic_future::wait() const /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/future:714:19
#48 0x00007f776ee62315 std::shared_future llvm::ThreadPoolInterface::asyncImpl(std::function<void ()>, llvm::ThreadPoolTaskGroup*)::'lambda'()::operator()() const /path_to/iree/third_party/llvm-project/llvm/include/llvm/Support/ThreadPool.h:114:38
#49 0x00007f776ee62315 void std::__invoke_impl<void, std::shared_future llvm::ThreadPoolInterface::asyncImpl(std::function<void ()>, llvm::ThreadPoolTaskGroup*)::'lambda'()&>(std::__invoke_other, std::shared_future llvm::ThreadPoolInterface::asyncImpl(std::function<void ()>, llvm::ThreadPoolTaskGroup*)::'lambda'()&) /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/bits/invoke.h:61:14
#50 0x00007f776ee62315 std::enable_if<is_invocable_r_v<void, std::shared_future llvm::ThreadPoolInterface::asyncImpl(std::function<void ()>, llvm::ThreadPoolTaskGroup*)::'lambda'()&>, void>::type std::__invoke_r<void, std::shared_future llvm::ThreadPoolInterface::asyncImpl(std::function<void ()>, llvm::ThreadPoolTaskGroup*)::'lambda'()&>(std::shared_future llvm::ThreadPoolInterface::asyncImpl(std::function<void ()>, llvm::ThreadPoolTaskGroup*)::'lambda'()&) /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/bits/invoke.h:111:2
#51 0x00007f776ee62315 std::_Function_handler<void (), std::shared_future llvm::ThreadPoolInterface::asyncImpl(std::function<void ()>, llvm::ThreadPoolTaskGroup*)::'lambda'()>::_M_invoke(std::_Any_data const&) /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/bits/std_function.h:290:9
#52 0x00007f776ed11514 std::function<void ()>::operator()() const /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/bits/std_function.h:0:9
#53 0x00007f776ed11514 llvm::StdThreadPool::processTasks(llvm::ThreadPoolTaskGroup*) /path_to/iree/third_party/llvm-project/llvm/lib/Support/ThreadPool.cpp:100:5
#54 0x00007f776ed12b27 std::default_delete<std::tuplellvm::StdThreadPool::grow(int)::$_0>::operator()(std::tuplellvm::StdThreadPool::grow(int)::$_0) const /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/bits/unique_ptr.h:95:2
#55 0x00007f776ed12b27 std::unique_ptr<std::tuplellvm::StdThreadPool::grow(int)::$_0, std::default_delete<std::tuplellvm::StdThreadPool::grow(int)::$_0>>::~unique_ptr() /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/bits/unique_ptr.h:396:4
#56 0x00007f776ed12b27 void llvm::thread::GenericThreadProxy<std::tuplellvm::StdThreadPool::grow(int)::$_0>(void
) /path_to/iree/third_party/llvm-project/llvm/include/llvm/Support/thread.h:46:3
#57 0x00007f776ed12b27 void* llvm::thread::ThreadProxy<std::tuplellvm::StdThreadPool::grow(int)::$_0>(void*) /path_to/iree/third_party/llvm-project/llvm/include/llvm/Support/thread.h:55:5
#58 0x00007f7768cb03ac (/usr/lib64/libc.so.6+0x843ac)
#59 0x00007f7768d3026c (/usr/lib64/libc.so.6+0x10426c)

@renxida
Copy link
Contributor

renxida commented Mar 25, 2024

@gabeweisz when i encountered this error, there were two error messages & two stack traces. do you see the same or is this all you got?

@benvanik benvanik changed the title Assert failure destroying a value that still has uses Assert failure destroying a value that still has uses during TorchToLinalg Mar 25, 2024
@gabeweisz
Copy link
Author

gabeweisz commented Mar 25, 2024

This is all that I got - I'm running iree-compile (commit aa72368 from March 21) with the attached file and no other options. It is a "release with debug info" build

@ScottTodd
Copy link
Collaborator

If I were triaging this I'd run the reproducer .mlir file through the compiler with --mlir-print-before-all (and possibly also -debug, but start with just the IR) then attach the IR (and pass name) just before the crash to the issue.

@gabeweisz
Copy link
Author

iree-build/tools/iree-compile model_small.mlir --print-before-all --debug >stdout.txt 2>stderr.txt
Without --debug I did not get anything printed but the stack trace,
This is what is right before the crash:
//===-------------------------------------------===//
Legalizing operation : 'torch.aten.view'(0x56194dc70670) {
%182 = "torch.aten.view"(%168, %181) : (!torch.vtensor<[?,16,768],f32>, !torch.list) -> !torch.vtensor<[?,768],f32>

  • Fold {
    } -> FAILURE : unable to fold

  • Pattern : 'torch.aten.view -> ()' {
    Trying to match "(anonymous namespace)::ConvertAtenViewOp"
    ** Insert : 'arith.constant'(0x7f99080568c0)
    ** Insert : 'tensor.dim'(0x7f990803cdf0)
    ** Insert : 'arith.constant'(0x7f9908033b90)
    ** Insert : 'arith.constant'(0x7f99080569b0)
    ** Insert : 'arith.constant'(0x7f9908033980)
    ** Insert : 'arith.constant'(0x7f9908038ba0)
    ** Insert : 'torch_c.to_i64'(0x7f9908037280)
    ** Insert : 'torch_c.to_i64'(0x7f9908038c10)
    ** Failure : unimplemented: found unhandled case of expansion/collapse in aten.view
    "(anonymous namespace)::ConvertAtenViewOp" result 0
    } -> FAILURE : pattern failed to match

  • Pattern : 'torch.aten.view -> ()' {
    Trying to match "(anonymous namespace)::ConvertAtenScalarToTensorLike"
    ** Failure : not a supported Scalar to Tensor like op
    "(anonymous namespace)::ConvertAtenScalarToTensorLike" result 0
    } -> FAILURE : pattern failed to match

  • Pattern : 'torch.aten.view -> ()' {
    Trying to match "(anonymous namespace)::ConvertElementwiseOp"
    ** Failure : not a supported elementwise op
    "(anonymous namespace)::ConvertElementwiseOp" result 0
    } -> FAILURE : pattern failed to match

  • Pattern : 'torch.aten.view -> ()' {
    Trying to match "(anonymous namespace)::ConvertReductionOp"
    ** Failure : not a supported reduce op
    "(anonymous namespace)::ConvertReductionOp" result 0
    } -> FAILURE : pattern failed to match
    } -> FAILURE : no matched legalization pattern

@gabeweisz
Copy link
Author

gabeweisz commented Mar 26, 2024

If I add the right flag for "--mlir-print-ir-before-all" I get this stderr
stderr.txt

The last thing printed was:
// -----// IR Dump Before ConvertTorchToArith (convert-torch-to-arith) //----- //
func.func @forward(%arg0: tensor<?x16xi32>) -> (tensor<?x16x50280xf32>, tensor<1x?x1536x16xf32>, tensor<1x?x1536x3xf32>) attributes {torch.args_schema = "[1, {\22type\22: \22builtins.tuple\22,iree-compile: /home/gweisz/iree/third_party/llvm-project/mlir/include/mlir/IR/UseDefLists.h:198: mlir::IRObjectWithUseList<mlir: :OpOperand>::~IRObjectWithUseList() [OperandType = mlir::OpOperand]: Assertion `use_empty() && "Cannot destroy a value that stil\l has uses!"' failed.
22coPlease report issues to https://github.com/openxla/iree/issues and include the crash backtrace.
ntext\22: \22null\22, \22children_spec\22: [{\22type\22: \22builtins.list\22, \22context\22: \22null\22, \22children_spec\22: [{\22type\22: null, \22context\22: null, \22children_spec\22: []}]}, {\22type\22: \22builtins.dict\22, \22context\22: \22[]\22, \22children_spec\22: []}]}]", torch.assume_strict_symbolic_shapes, torch.return_schema = "[1, {\22type\22: \22builtins.tuple\22, \22context\22: \22null\22, \22children_spec\22: [{\22type\22: null, \22context\22: null, \22children_spec\22: []}, {\22type\22: null, \22context\22: null, \22children_spec\22: []}, {\22type\22: null, \22context\22: null, \22children_spec\22: []}]}]"} {
%0 = torch_c.from_builtin_tensor %arg0 : tensor<?x16xi32> -> !torch.vtensor<[?,16],si32>
%1:3 = call @forward$1(%0) : (!torch.vtensor<[?,16],si32>) -> (!torch.vtensor<[?,16,50280],f32>, !torch.vtensor<[1,?,1536,16],f32>, !torch.vtensor<[1,?,1536,3],f32>)
%2 = torch_c.to_builtin_tensor %1#0 : !torch.vtensor<[?,16,50280],f32> -> tensor<?x16x50280xf32>
%3 = torch_c.to_builtin_tensor %1#1 : !torch.vtensor<[1,?,1536,16],f32> -> tensor<1x?x1536x16xf32>
%4 = torch_c.to_builtin_tensor %1#2 : !torch.vtensor<[1,?,1536,3],f32> -> tensor<1x?x1536x3xf32>
return %2, %3, %4 : tensor<?x16x50280xf32>, tensor<1x?x1536x16xf32>, tensor<1x?x1536x3xf32>
}

@gabeweisz gabeweisz changed the title Assert failure destroying a value that still has uses during TorchToLinalg Failure : unimplemented: found unhandled case of expansion/collapse in aten.view Mar 29, 2024
@gabeweisz
Copy link
Author

Still fails with commit 5cd0a0c

Some more from the log (with --mlir-print-ir-before-all --debug) :
//===-------------------------------------------===//

//===-------------------------------------------===//
Legalizing operation : 'torch.aten.mul.int'(0x556fc1511760) {
%180 = "torch.aten.mul.int"(%55, %24) : (!torch.int, !torch.int) -> !torch.int

  • Fold {
    } -> FAILURE : unable to fold

  • Pattern : 'torch.aten.mul.int -> ()' {
    Trying to match "(anonymous namespace)::ConvertAtenScalarToTensorLike"
    ** Failure : not a supported Scalar to Tensor like op
    "(anonymous namespace)::ConvertAtenScalarToTensorLike" result 0
    } -> FAILURE : pattern failed to match

  • Pattern : 'torch.aten.mul.int -> ()' {
    Trying to match "(anonymous namespace)::ConvertElementwiseOp"
    ** Failure : not a supported elementwise op
    "(anonymous namespace)::ConvertElementwiseOp" result 0
    } -> FAILURE : pattern failed to match

  • Pattern : 'torch.aten.mul.int -> ()' {
    Trying to match "(anonymous namespace)::ConvertReductionOp"
    ** Failure : not a supported reduce op
    "(anonymous namespace)::ConvertReductionOp" result 0
    } -> FAILURE : pattern failed to match
    } -> FAILURE : no matched legalization pattern
    //===-------------------------------------------===//

//===-------------------------------------------===//
Legalizing operation : 'torch.prim.ListConstruct'(0x556fc1511da0) {
%181 = "torch.prim.ListConstruct"(%180, %12) : (!torch.int, !torch.int) -> !torch.list

  • Fold {
    } -> FAILURE : unable to fold

  • Pattern : 'torch.prim.ListConstruct -> ()' {
    Trying to match "(anonymous namespace)::ConvertAtenScalarToTensorLike"
    ** Failure : not a supported Scalar to Tensor like op
    "(anonymous namespace)::ConvertAtenScalarToTensorLike" result 0
    } -> FAILURE : pattern failed to match

  • Pattern : 'torch.prim.ListConstruct -> ()' {
    Trying to match "(anonymous namespace)::ConvertElementwiseOp"
    ** Failure : not a supported elementwise op
    "(anonymous namespace)::ConvertElementwiseOp" result 0
    } -> FAILURE : pattern failed to match

  • Pattern : 'torch.prim.ListConstruct -> ()' {
    Trying to match "(anonymous namespace)::ConvertReductionOp"
    ** Failure : not a supported reduce op
    "(anonymous namespace)::ConvertReductionOp" result 0
    } -> FAILURE : pattern failed to match
    } -> FAILURE : no matched legalization pattern
    //===-------------------------------------------===//

//===-------------------------------------------===//
Legalizing operation : 'torch.aten.view'(0x556fc1511eb0) {
%182 = "torch.aten.view"(%168, %181) : (!torch.vtensor<[?,16,768],f32>, !torch.list) -> !torch.vtensor<[?,768],f32>

  • Fold {
    } -> FAILURE : unable to fold

  • Pattern : 'torch.aten.view -> ()' {
    Trying to match "(anonymous namespace)::ConvertAtenViewOp"
    ** Insert : 'arith.constant'(0x7f2ab4000bc0)
    ** Insert : 'tensor.dim'(0x7f2ab401a080)
    ** Insert : 'arith.constant'(0x7f2ab40337d0)
    ** Insert : 'arith.constant'(0x7f2ab4000c30)
    ** Insert : 'arith.constant'(0x7f2ab4000ca0)
    ** Insert : 'arith.constant'(0x7f2ab4000d10)
    ** Insert : 'torch_c.to_i64'(0x7f2ab404f820)
    ** Insert : 'torch_c.to_i64'(0x7f2ab4040920)
    ** Failure : unimplemented: found unhandled case of expansion/collapse in aten.view
    "(anonymous namespace)::ConvertAtenViewOp" result 0
    } -> FAILURE : pattern failed to match

  • Pattern : 'torch.aten.view -> ()' {
    Trying to match "(anonymous namespace)::ConvertAtenScalarToTensorLike"
    ** Failure : not a supported Scalar to Tensor like op
    "(anonymous namespace)::ConvertAtenScalarToTensorLike" result 0
    } -> FAILURE : pattern failed to match

  • Pattern : 'torch.aten.view -> ()' {
    Trying to match "(anonymous namespace)::ConvertElementwiseOp"
    ** Failure : not a supported elementwise op
    "(anonymous namespace)::ConvertElementwiseOp" result 0
    } -> FAILURE : pattern failed to match

  • Pattern : 'torch.aten.view -> ()' {
    Trying to match "(anonymous namespace)::ConvertReductionOp"
    ** Failure : not a supported reduce op
    "(anonymous namespace)::ConvertReductionOp" result 0
    } -> FAILURE : pattern failed to match
    } -> FAILURE : no matched legalization pattern

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants