Open
Description
This seems to be caused by a failure in typeConverter->materializeTargetConversion
Replicating example:
func.func @test_whileloop_tensorargs() -> !torch.tensor {
%false = torch.constant.bool false
%int6 = torch.constant.int 6
%none_0 = torch.constant.none
%int5 = torch.constant.int 5
%int9223372036854775807 = torch.constant.int 9223372036854775807
%int0 = torch.constant.int 0
%int10 = torch.constant.int 10
%int1 = torch.constant.int 1
%1 = torch.prim.ListConstruct %int5 : (!torch.int) -> !torch.list<int>
%2 = torch.aten.zeros %1, %none_0, %none_0, %none_0, %none_0 : !torch.list<int>, !torch.none, !torch.none, !torch.none, !torch.none -> !torch.tensor
%3 = torch.aten.to.dtype %2, %int6, %false, %false, %none_0 : !torch.tensor, !torch.int, !torch.bool, !torch.bool, !torch.none -> !torch.tensor
%4 = torch.aten.select.int %3, %int0, %int0 : !torch.tensor, !torch.int, !torch.int -> !torch.tensor
%5 = torch.aten.lt.Scalar %4, %int10 : !torch.tensor, !torch.int -> !torch.tensor
%6 = torch.aten.Bool.Tensor %5 : !torch.tensor -> !torch.bool
%7 = torch.prim.Loop %int9223372036854775807, %6, init(%3) {
^bb0(%arg1: !torch.int, %arg2: !torch.tensor):
%8 = torch.aten.add.Scalar %arg2, %int1, %int1 : !torch.tensor, !torch.int, !torch.int -> !torch.tensor
%9 = torch.aten.select.int %8, %int0, %int0 : !torch.tensor, !torch.int, !torch.int -> !torch.tensor
%10 = torch.aten.lt.Scalar %9, %int10 : !torch.tensor, !torch.int -> !torch.tensor
%11 = torch.aten.Bool.Tensor %10 : !torch.tensor -> !torch.bool
torch.prim.Loop.condition %11, iter(%8 : !torch.tensor)
} : (!torch.int, !torch.bool, !torch.tensor) -> !torch.tensor
return %7 : !torch.tensor
}
Error message:
} -> SUCCESS : operation marked legal by the target
//===-------------------------------------------===//
//===-------------------------------------------===//
Legalizing operation : 'torch.aten.lt.Scalar'(0x55b1e9707740) {
%15 = "torch.aten.lt.Scalar"(%14, %7) : (!torch.tensor, !torch.int) -> !torch.tensor
} -> SUCCESS : operation marked legal by the target
//===-------------------------------------------===//
//===-------------------------------------------===//
Legalizing operation : 'torch.aten.Bool.Tensor'(0x55b1e9707c00) {
%16 = "torch.aten.Bool.Tensor"(%15) : (!torch.tensor) -> !torch.bool
} -> SUCCESS : operation marked legal by the target
//===-------------------------------------------===//
//===-------------------------------------------===//
Legalizing operation : 'torch.prim.Loop'(0x55b1e96ad050) {
* Fold {
} -> FAILURE : unable to fold
* Pattern : 'torch.prim.Loop -> ()' {
Trying to match "(anonymous namespace)::ConvertTorchPrimLoopForLikeOp"
"(anonymous namespace)::ConvertTorchPrimLoopForLikeOp" result 0
} -> FAILURE : pattern failed to match
* Pattern : 'torch.prim.Loop -> ()' {
Trying to match "(anonymous namespace)::ConvertTorchPrimLoopWhileLikeOp"
** Insert : 'scf.while'(0x55b1e97085a0)
** Insert : 'scf.condition'(0x55b1e96dba90)
** Insert : 'torch_c.to_i1'(0x55b1e96de2a0)
torchArg: mlir-asm-printer: Verifying operation: builtin.module
ImplicitTypeIDRegistry::lookupOrInsert(mlir::OpTrait::NRegions<2>::Impl<Empty>)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::LoopLikeOpInterface::Trait<Empty>)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::OpTrait::HasRecursiveMemoryEffects<Empty>)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::OpTrait::HasParent<mlir::scf::WhileOp>::Impl<Empty>)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::OpTrait::OneTypedResult<mlir::IntegerType>::Impl<Empty>)
'scf.while' op expects the 'after' region to terminate with 'scf.yield'
mlir-asm-printer: 'builtin.module' failed to verify and will be printed in generic form
%21 = "torch.aten.add.Tensor"(%arg0, %14, %0) : (!torch.tensor, !torch.tensor, !torch.int) -> !torch.tensor
arg: <<NULL VALUE>>
** Failure : unsupported type of the operand
"(anonymous namespace)::ConvertTorchPrimLoopWhileLikeOp" result 0
} -> FAILURE : pattern failed to match
} -> FAILURE : no matched legalization pattern
//===-------------------------------------------===//
<stdin>:19:11: error: failed to legalize operation 'torch.prim.Loop' that was explicitly marked illegal
%10 = torch.prim.Loop %int9223372036854775807, %9, init(%3) {
^
<stdin>:19:11: note: see current operation:
%17 = "torch.prim.Loop"(%5, %16, %10) ({
^bb0(%arg0: !torch.int, %arg1: !torch.tensor):
"torch.prim.Loop.condition"(<<UNKNOWN SSA VALUE>>, <<UNKNOWN SSA VALUE>>) : (!torch.bool, !torch.tensor) -> ()
}) : (!torch.int, !torch.bool, !torch.tensor) -> !torch.tensor
ImplicitTypeIDRegistry::lookupOrInsert(mlir::detail::PreservedAnalyses::AllAnalysesType)
// -----// IR Dump After ConvertTorchToSCF Failed (convert-torch-to-scf) //----- //
mlir-asm-printer: Verifying operation: func.func
operation's operand is unlinked
mlir-asm-printer: 'func.func' failed to verify and will be printed in generic form
"func.func"() <{function_type = () -> !torch.tensor, sym_name = "test_whileloop_tensorargs"}> ({
%0 = "torch.constant.int"() <{value = 1 : i64}> : () -> !torch.int
%1 = "torch.constant.bool"() <{value = false}> : () -> !torch.bool
%2 = "torch.constant.int"() <{value = 6 : i64}> : () -> !torch.int
%3 = "torch.constant.none"() : () -> !torch.none
%4 = "torch.constant.int"() <{value = 5 : i64}> : () -> !torch.int
%5 = "torch.constant.int"() <{value = 9223372036854775807 : i64}> : () -> !torch.int
%6 = "torch.constant.int"() <{value = 0 : i64}> : () -> !torch.int
%7 = "torch.constant.int"() <{value = 10 : i64}> : () -> !torch.int
%8 = "torch.prim.ListConstruct"(%4) : (!torch.int) -> !torch.list<int>
%9 = "torch.aten.zeros"(%8, %3, %3, %3, %3) : (!torch.list<int>, !torch.none, !torch.none, !torch.none, !torch.none) -> !torch.tensor
%10 = "torch.aten.to.dtype"(%9, %2, %1, %1, %3) : (!torch.tensor, !torch.int, !torch.bool, !torch.bool, !torch.none) -> !torch.tensor
%11 = "torch.prim.ListConstruct"(%4) : (!torch.int) -> !torch.list<int>
%12 = "torch.aten.ones"(%11, %3, %3, %3, %3) : (!torch.list<int>, !torch.none, !torch.none, !torch.none, !torch.none) -> !torch.tensor
%13 = "torch.aten.to.dtype"(%12, %2, %1, %1, %3) : (!torch.tensor, !torch.int, !torch.bool, !torch.bool, !torch.none) -> !torch.tensor
%14 = "torch.aten.select.int"(%10, %6, %6) : (!torch.tensor, !torch.int, !torch.int) -> !torch.tensor
%15 = "torch.aten.lt.Scalar"(%14, %7) : (!torch.tensor, !torch.int) -> !torch.tensor
%16 = "torch.aten.Bool.Tensor"(%15) : (!torch.tensor) -> !torch.bool
%17 = "torch.prim.Loop"(%5, %16, %10) ({
^bb0(%arg0: !torch.int, %arg1: !torch.tensor):
"torch.prim.Loop.condition"(<<UNKNOWN SSA VALUE>>, <<UNKNOWN SSA VALUE>>) : (!torch.bool, !torch.tensor) -> ()
}) : (!torch.int, !torch.bool, !torch.tensor) -> !torch.tensor
"func.return"(%17) : (!torch.tensor) -> ()
}) : () -> ()
mlir-asm-printer: Verifying operation: torch.aten.add.Tensor
null operand found
mlir-asm-printer: 'torch.aten.add.Tensor' failed to verify and will be printed in generic form
<stdin>:15:10: error: 'torch.aten.to.dtype' op operation destroyed but still has uses
%6 = torch.aten.to.dtype %5, %int6, %false, %false, %none_0 : !torch.tensor, !torch.int, !torch.bool, !torch.bool, !torch.none -> !torch.tensor
^
<stdin>:15:10: note: see current operation: %0 = "torch.aten.to.dtype"(<<NULL VALUE>>, <<NULL VALUE>>, <<NULL VALUE>>, <<NULL VALUE>>, <<NULL VALUE>>) : (<<NULL TYPE>>, <<NULL TYPE>>, <<NULL TYPE>>, <<NULL TYPE>>, <<NULL TYPE>>) -> !torch.tensor
<stdin>:21:13: note: - use: %0 = "torch.aten.add.Tensor"(<<NULL VALUE>>, <<UNKNOWN SSA VALUE>>, <<UNKNOWN SSA VALUE>>) : (<<NULL TYPE>>, !torch.tensor, !torch.int) -> !torch.tensor
%11 = torch.aten.add.Tensor %arg2, %6, %int1 : !torch.tensor, !torch.tensor, !torch.int -> !torch.tensor
^
LLVM ERROR: operation destroyed but still has uses
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: ./build/bin/torch-mlir-opt --convert-torch-to-scf -debug --mlir-print-ir-after-all --mlir-disable-threading
#0 0x000055b1e56f921d llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/azureuser/torch-mlir/externals/llvm-project/llvm/lib/Support/Unix/Signals.inc:723:11
#1 0x000055b1e56f970b PrintStackTraceSignalHandler(void*) /home/azureuser/torch-mlir/externals/llvm-project/llvm/lib/Support/Unix/Signals.inc:798:1
#2 0x000055b1e56f7776 llvm::sys::RunSignalHandlers() /home/azureuser/torch-mlir/externals/llvm-project/llvm/lib/Support/Signals.cpp:105:5
#3 0x000055b1e56f9ec5 SignalHandler(int) /home/azureuser/torch-mlir/externals/llvm-project/llvm/lib/Support/Unix/Signals.inc:413:1
#4 0x00007f0cec83c460 (/lib/x86_64-linux-gnu/libc.so.6+0x3c460)
#5 0x00007f0cec89152b pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x9152b)
#6 0x00007f0cec83c3b6 raise (/lib/x86_64-linux-gnu/libc.so.6+0x3c3b6)
#7 0x00007f0cec82287c abort (/lib/x86_64-linux-gnu/libc.so.6+0x2287c)
#8 0x000055b1e563fc44 llvm::report_fatal_error(llvm::Twine const&, bool) /home/azureuser/torch-mlir/externals/llvm-project/llvm/lib/Support/ErrorHandling.cpp:125:5
#9 0x000055b1e563fab2 /home/azureuser/torch-mlir/externals/llvm-project/llvm/lib/Support/ErrorHandling.cpp:83:3
#10 0x000055b1e5575547 mlir::Operation::~Operation() /home/azureuser/torch-mlir/externals/llvm-project/mlir/lib/IR/Operation.cpp:0:5
#11 0x000055b1e557580e mlir::Operation::destroy() /home/azureuser/torch-mlir/externals/llvm-project/mlir/lib/IR/Operation.cpp:214:8
#12 0x000055b1e55767c5 llvm::ilist_traits<mlir::Operation>::deleteNode(mlir::Operation*) /home/azureuser/torch-mlir/externals/llvm-project/mlir/lib/IR/Operation.cpp:493:1
#13 0x000055b1e53f26a5 llvm::iplist_impl<llvm::simple_ilist<mlir::Operation>, llvm::ilist_traits<mlir::Operation>>::erase(llvm::ilist_iterator<llvm::ilist_detail::node_options<mlir::Operation, true, false, void, false>, false, false>) /home/azureuser/torch-mlir/externals/llvm-project/llvm/include/llvm/ADT/ilist.h:206:12
#14 0x000055b1e53f2671 llvm::iplist_impl<llvm::simple_ilist<mlir::Operation>, llvm::ilist_traits<mlir::Operation>>::pop_back() /home/azureuser/torch-mlir/externals/llvm-project/llvm/include/llvm/ADT/ilist.h:257:25
#15 0x000055b1e53f169e mlir::Block::clear() /home/azureuser/torch-mlir/externals/llvm-project/mlir/include/mlir/IR/Block.h:41:5
#16 0x000055b1e53ef980 mlir::Block::~Block() /home/azureuser/torch-mlir/externals/llvm-project/mlir/lib/IR/Block.cpp:21:3
#17 0x000055b1e2dd2877 llvm::ilist_alloc_traits<mlir::Block>::deleteNode(mlir::Block*) /home/azureuser/torch-mlir/externals/llvm-project/llvm/include/llvm/ADT/ilist.h:42:39
#18 0x000055b1e2dd2835 llvm::iplist_impl<llvm::simple_ilist<mlir::Block>, llvm::ilist_traits<mlir::Block>>::erase(llvm::ilist_iterator<llvm::ilist_detail::node_options<mlir::Block, true, false, void, false>, false, false>) /home/azureuser/torch-mlir/externals/llvm-project/llvm/include/llvm/ADT/ilist.h:206:12
#19 0x000055b1e2dd27eb llvm::iplist_impl<llvm::simple_ilist<mlir::Block>, llvm::ilist_traits<mlir::Block>>::erase(llvm::ilist_iterator<llvm::ilist_detail::node_options<mlir::Block, true, false, void, false>, false, false>, llvm::ilist_iterator<llvm::ilist_detail::node_options<mlir::Block, true, false, void, false>, false, false>) /home/azureuser/torch-mlir/externals/llvm-project/llvm/include/llvm/ADT/ilist.h:242:15
#20 0x000055b1e2dd270b llvm::iplist_impl<llvm::simple_ilist<mlir::Block>, llvm::ilist_traits<mlir::Block>>::clear() /home/azureuser/torch-mlir/externals/llvm-project/llvm/include/llvm/ADT/ilist.h:246:18
#21 0x000055b1e5597a85 llvm::iplist_impl<llvm::simple_ilist<mlir::Block>, llvm::ilist_traits<mlir::Block>>::~iplist_impl() /home/azureuser/torch-mlir/externals/llvm-project/llvm/include/llvm/ADT/ilist.h:147:29
#22 0x000055b1e5597715 llvm::iplist<mlir::Block>::~iplist() /home/azureuser/torch-mlir/externals/llvm-project/llvm/include/llvm/ADT/ilist.h:327:7
#23 0x000055b1e55961a2 mlir::Region::~Region() /home/azureuser/torch-mlir/externals/llvm-project/mlir/lib/IR/Region.cpp:20:1
#24 0x000055b1e5575685 mlir::Operation::~Operation() /home/azureuser/torch-mlir/externals/llvm-project/mlir/lib/IR/Operation.cpp:201:21
#25 0x000055b1e557580e mlir::Operation::destroy() /home/azureuser/torch-mlir/externals/llvm-project/mlir/lib/IR/Operation.cpp:214:8
#26 0x000055b1e55767c5 llvm::ilist_traits<mlir::Operation>::deleteNode(mlir::Operation*) /home/azureuser/torch-mlir/externals/llvm-project/mlir/lib/IR/Operation.cpp:493:1
#27 0x000055b1e53f26a5 llvm::iplist_impl<llvm::simple_ilist<mlir::Operation>, llvm::ilist_traits<mlir::Operation>>::erase(llvm::ilist_iterator<llvm::ilist_detail::node_options<mlir::Operation, true, false, void, false>, false, false>) /home/azureuser/torch-mlir/externals/llvm-project/llvm/include/llvm/ADT/ilist.h:206:12
#28 0x000055b1e53f2671 llvm::iplist_impl<llvm::simple_ilist<mlir::Operation>, llvm::ilist_traits<mlir::Operation>>::pop_back() /home/azureuser/torch-mlir/externals/llvm-project/llvm/include/llvm/ADT/ilist.h:257:25
#29 0x000055b1e53f169e mlir::Block::clear() /home/azureuser/torch-mlir/externals/llvm-project/mlir/include/mlir/IR/Block.h:41:5
#30 0x000055b1e53ef980 mlir::Block::~Block() /home/azureuser/torch-mlir/externals/llvm-project/mlir/lib/IR/Block.cpp:21:3
#31 0x000055b1e2dd2877 llvm::ilist_alloc_traits<mlir::Block>::deleteNode(mlir::Block*) /home/azureuser/torch-mlir/externals/llvm-project/llvm/include/llvm/ADT/ilist.h:42:39
#32 0x000055b1e2dd2835 llvm::iplist_impl<llvm::simple_ilist<mlir::Block>, llvm::ilist_traits<mlir::Block>>::erase(llvm::ilist_iterator<llvm::ilist_detail::node_options<mlir::Block, true, false, void, false>, false, false>) /home/azureuser/torch-mlir/externals/llvm-project/llvm/include/llvm/ADT/ilist.h:206:12
#33 0x000055b1e2dd27eb llvm::iplist_impl<llvm::simple_ilist<mlir::Block>, llvm::ilist_traits<mlir::Block>>::erase(llvm::ilist_iterator<llvm::ilist_detail::node_options<mlir::Block, true, false, void, false>, false, false>, llvm::ilist_iterator<llvm::ilist_detail::node_options<mlir::Block, true, false, void, false>, false, false>) /home/azureuser/torch-mlir/externals/llvm-project/llvm/include/llvm/ADT/ilist.h:242:15
#34 0x000055b1e2dd270b llvm::iplist_impl<llvm::simple_ilist<mlir::Block>, llvm::ilist_traits<mlir::Block>>::clear() /home/azureuser/torch-mlir/externals/llvm-project/llvm/include/llvm/ADT/ilist.h:246:18
#35 0x000055b1e5597a85 llvm::iplist_impl<llvm::simple_ilist<mlir::Block>, llvm::ilist_traits<mlir::Block>>::~iplist_impl() /home/azureuser/torch-mlir/externals/llvm-project/llvm/include/llvm/ADT/ilist.h:147:29
#36 0x000055b1e5597715 llvm::iplist<mlir::Block>::~iplist() /home/azureuser/torch-mlir/externals/llvm-project/llvm/include/llvm/ADT/ilist.h:327:7
#37 0x000055b1e55961a2 mlir::Region::~Region() /home/azureuser/torch-mlir/externals/llvm-project/mlir/lib/IR/Region.cpp:20:1
#38 0x000055b1e5575685 mlir::Operation::~Operation() /home/azureuser/torch-mlir/externals/llvm-project/mlir/lib/IR/Operation.cpp:201:21
#39 0x000055b1e557580e mlir::Operation::destroy() /home/azureuser/torch-mlir/externals/llvm-project/mlir/lib/IR/Operation.cpp:214:8
#40 0x000055b1e5576a2f mlir::Operation::erase() /home/azureuser/torch-mlir/externals/llvm-project/mlir/lib/IR/Operation.cpp:544:1
#41 0x000055b1e173ef4a mlir::OwningOpRef<mlir::Operation*>::~OwningOpRef() /home/azureuser/torch-mlir/externals/llvm-project/mlir/include/mlir/IR/OwningOpRef.h:39:3
#42 0x000055b1e1729242 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) /home/azureuser/torch-mlir/externals/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:426:1
#43 0x000055b1e1728aa8 processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, llvm::ThreadPool*) /home/azureuser/torch-mlir/externals/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:461:12
#44 0x000055b1e172888c mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::$_0::operator()(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) const /home/azureuser/torch-mlir/externals/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:532:12
#45 0x000055b1e1728826 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&)::$_0>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) /home/azureuser/torch-mlir/externals/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:12
#46 0x000055b1e55e4e12 llvm::function_ref<mlir::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>::operator()(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) const /home/azureuser/torch-mlir/externals/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:12
#47 0x000055b1e55e442d 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/azureuser/torch-mlir/externals/llvm-project/mlir/lib/Support/ToolUtilities.cpp:28:12
#48 0x000055b1e172575b mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) /home/azureuser/torch-mlir/externals/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:535:10
#49 0x000055b1e17259f5 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) /home/azureuser/torch-mlir/externals/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:570:14
#50 0x000055b1e1725bc8 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) /home/azureuser/torch-mlir/externals/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:586:10
#51 0x000055b1e17210e5 main /home/azureuser/torch-mlir/tools/torch-mlir-opt/torch-mlir-opt.cpp:43:33
#52 0x00007f0cec823a90 (/lib/x86_64-linux-gnu/libc.so.6+0x23a90)
#53 0x00007f0cec823b49 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x23b49)
#54 0x000055b1e1720f75 _start (./build/bin/torch-mlir-opt+0x236f75)
Aborted (core dumped)
Metadata
Assignees
Labels
No labels
Activity