Last active
October 19, 2022 01:27
-
-
Save AmosLewis/aedbf1488a9b2a9b8068ac6010f79a9c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(mlir_venv) nod% torch-mlir-opt -convert-torch-to-tosa /tmp/where.mlir | |
module { | |
func.func @torch.aten.where.self(%arg0: !torch.vtensor<[1,1,5,5],i1>, %arg1: !torch.vtensor<[1,12,5,5],f32>, %arg2: !torch.vtensor<[],f32>) -> !torch.vtensor<[1,12,5,5],f32> { | |
%0 = torch_c.to_builtin_tensor %arg0 : !torch.vtensor<[1,1,5,5],i1> -> tensor<1x1x5x5xi1> | |
%1 = torch_c.to_builtin_tensor %arg1 : !torch.vtensor<[1,12,5,5],f32> -> tensor<1x12x5x5xf32> | |
%2 = torch_c.to_builtin_tensor %arg2 : !torch.vtensor<[],f32> -> tensor<f32> | |
%3 = "tosa.select"(%0, %1, %2) : (tensor<1x1x5x5xi1>, tensor<1x12x5x5xf32>, tensor<f32>) -> tensor<1x12x5x5xf32> | |
%4 = torch_c.from_builtin_tensor %3 : tensor<1x12x5x5xf32> -> !torch.vtensor<[1,12,5,5],f32> | |
return %4 : !torch.vtensor<[1,12,5,5],f32> | |
} | |
} | |
(mlir_venv) nod% torch-mlir-opt -convert-torch-to-tosa -torch-decompose-complex-ops="legal-ops=torch.aten.where.self" /tmp/where.mlir | |
module { | |
func.func @torch.aten.where.self(%arg0: !torch.vtensor<[1,1,5,5],i1>, %arg1: !torch.vtensor<[1,12,5,5],f32>, %arg2: !torch.vtensor<[],f32>) -> !torch.vtensor<[1,12,5,5],f32> { | |
%0 = torch_c.to_builtin_tensor %arg0 : !torch.vtensor<[1,1,5,5],i1> -> tensor<1x1x5x5xi1> | |
%1 = torch_c.to_builtin_tensor %arg1 : !torch.vtensor<[1,12,5,5],f32> -> tensor<1x12x5x5xf32> | |
%2 = torch_c.to_builtin_tensor %arg2 : !torch.vtensor<[],f32> -> tensor<f32> | |
%3 = "tosa.select"(%0, %1, %2) : (tensor<1x1x5x5xi1>, tensor<1x12x5x5xf32>, tensor<f32>) -> tensor<1x12x5x5xf32> | |
%4 = torch_c.from_builtin_tensor %3 : tensor<1x12x5x5xf32> -> !torch.vtensor<[1,12,5,5],f32> | |
return %4 : !torch.vtensor<[1,12,5,5],f32> | |
} | |
} | |
(mlir_venv) nod% torch-mlir-opt -torch-backend-to-tosa-backend-pipeline -torch-decompose-complex-ops="legal-ops=torch.aten.where.self" /tmp/where.mlir | |
module { | |
func.func @torch.aten.where.self(%arg0: tensor<1x1x5x5xi1>, %arg1: tensor<1x12x5x5xf32>, %arg2: tensor<f32>) -> tensor<1x12x5x5xf32> { | |
%0 = "tosa.select"(%arg0, %arg1, %arg2) : (tensor<1x1x5x5xi1>, tensor<1x12x5x5xf32>, tensor<f32>) -> tensor<1x12x5x5xf32> | |
return %0 : tensor<1x12x5x5xf32> | |
} | |
} | |
(mlir_venv) nod% torch-mlir-opt -convert-torch-to-tosa /tmp/where.mlir | |
module { | |
func.func @torch.aten.where.self(%arg0: !torch.vtensor<[1,1,5,5],i1>, %arg1: !torch.vtensor<[1,12,5,5],f32>, %arg2: !torch.vtensor<[],f32>) -> !torch.vtensor<[1,12,5,5],f32> { | |
%0 = torch_c.to_builtin_tensor %arg0 : !torch.vtensor<[1,1,5,5],i1> -> tensor<1x1x5x5xi1> | |
%1 = torch_c.to_builtin_tensor %arg1 : !torch.vtensor<[1,12,5,5],f32> -> tensor<1x12x5x5xf32> | |
%2 = torch_c.to_builtin_tensor %arg2 : !torch.vtensor<[],f32> -> tensor<f32> | |
%3 = "tosa.select"(%0, %1, %2) : (tensor<1x1x5x5xi1>, tensor<1x12x5x5xf32>, tensor<f32>) -> tensor<1x12x5x5xf32> | |
%4 = torch_c.from_builtin_tensor %3 : tensor<1x12x5x5xf32> -> !torch.vtensor<[1,12,5,5],f32> | |
return %4 : !torch.vtensor<[1,12,5,5],f32> | |
} | |
} | |
Author
AmosLewis
commented
Oct 19, 2022
•
(mlir_venv) nod% torch-mlir-opt -torch-decompose-complex-ops -convert-torch-to-tosa test/Dialect/Torch/decompose-complex-ops-legal.mlir
test/Dialect/Torch/decompose-complex-ops-legal.mlir:8:10: error: failed to legalize operation 'torch.aten.max.dim' that was explicitly marked illegal
%ret = torch.aten.softmax.int %t, %dim, %none : !torch.tensor<[2,3],f32>, !torch.int, !torch.none -> !torch.tensor<[2,3],f32>
^
test/Dialect/Torch/decompose-complex-ops-legal.mlir:8:10: note: see current operation: %3:2 = "torch.aten.max.dim"(%arg0, %1, %2) : (!torch.tensor<[2,3],f32>, !torch.int, !torch.bool) -> (!torch.tensor<[2,1],f32>, !torch.tensor<[2,1],si64>)
(mlir_venv) nod% torch-mlir-opt -torch-decompose-complex-ops -convert-torch-to-linalg test/Dialect/Torch/decompose-complex-ops-legal.mlir
torch-mlir-opt: /home/chi/src/ubuntu20/shark/torch-mlir/externals/llvm-project/llvm/include/llvm/Support/Casting.h:566: decltype(auto) llvm::cast(const From &) [To = mlir::RankedTensorType, From = mlir::Type]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' 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/chi/src/ubuntu20/shark/torch-mlir/build/bin/torch-mlir-opt -torch-decompose-complex-ops -convert-torch-to-linalg test/Dialect/Torch/decompose-complex-ops-legal.mlir
#0 0x000000000501843a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/chi/src/ubuntu20/shark/torch-mlir/externals/llvm-project/llvm/lib/Support/Unix/Signals.inc:569:11
#1 0x000000000501860b PrintStackTraceSignalHandler(void*) /home/chi/src/ubuntu20/shark/torch-mlir/externals/llvm-project/llvm/lib/Support/Unix/Signals.inc:636:1
#2 0x0000000005016b7b llvm::sys::RunSignalHandlers() /home/chi/src/ubuntu20/shark/torch-mlir/externals/llvm-project/llvm/lib/Support/Signals.cpp:103:5
#3 0x0000000005018d81 SignalHandler(int) /home/chi/src/ubuntu20/shark/torch-mlir/externals/llvm-project/llvm/lib/Support/Unix/Signals.inc:407:1
#4 0x00007f116532f420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#5 0x00007f1164cdf00b raise /build/glibc-SzIz7B/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
#6 0x00007f1164cbe859 abort /build/glibc-SzIz7B/glibc-2.31/stdlib/abort.c:81:7
#7 0x00007f1164cbe729 get_sysdep_segment_value /build/glibc-SzIz7B/glibc-2.31/intl/loadmsgcat.c:509:8
#8 0x00007f1164cbe729 _nl_load_domain /build/glibc-SzIz7B/glibc-2.31/intl/loadmsgcat.c:970:34
#9 0x00007f1164ccffd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#10 0x00000000007eaee5 decltype(auto) llvm::cast<mlir::RankedTensorType, mlir::Type>(mlir::Type const&) /home/chi/src/ubuntu20/shark/torch-mlir/externals/llvm-project/llvm/include/llvm/Support/Casting.h:567:43
#11 0x00000000007d6455 mlir::RankedTensorType mlir::Type::cast<mlir::RankedTensorType>() const /home/chi/src/ubuntu20/shark/torch-mlir/externals/llvm-project/llvm/../mlir/include/mlir/IR/Types.h:280:10
#12 0x00000000033b029f (anonymous namespace)::ConvertAtenMaxDimOp::matchAndRewrite(mlir::torch::Torch::AtenMaxDimOp, mlir::torch::Torch::AtenMaxDimOpAdaptor, mlir::ConversionPatternRewriter&) const /home/chi/src/ubuntu20/shark/torch-mlir/lib/Conversion/TorchToLinalg/Reduction.cpp:57:14
#13 0x00000000033b5cc5 mlir::OpConversionPattern<mlir::torch::Torch::AtenMaxDimOp>::matchAndRewrite(mlir::Operation*, llvm::ArrayRef<mlir::Value>, mlir::ConversionPatternRewriter&) const /home/chi/src/ubuntu20/shark/torch-mlir/externals/llvm-project/llvm/../mlir/include/mlir/Transforms/DialectConversion.h:424:12
#14 0x0000000004b298d3 mlir::ConversionPattern::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const /home/chi/src/ubuntu20/shark/torch-mlir/externals/llvm-project/mlir/lib/Transforms/Utils/DialectConversion.cpp:1702:10
#15 0x0000000004b91b60 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/chi/src/ubuntu20/shark/torch-mlir/externals/llvm-project/mlir/lib/Rewrite/PatternApplicator.cpp:201:25
#16 0x0000000004b3411a (anonymous namespace)::OperationLegalizer::legalizeWithPattern(mlir::Operation*, mlir::ConversionPatternRewriter&) /home/chi/src/ubuntu20/shark/torch-mlir/externals/llvm-project/mlir/lib/Transforms/Utils/DialectConversion.cpp:1984:21
#17 0x0000000004b337b4 (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*, mlir::ConversionPatternRewriter&) /home/chi/src/ubuntu20/shark/torch-mlir/externals/llvm-project/mlir/lib/Transforms/Utils/DialectConversion.cpp:1892:17
#18 0x0000000004b32c82 (anonymous namespace)::OperationConverter::convert(mlir::ConversionPatternRewriter&, mlir::Operation*) /home/chi/src/ubuntu20/shark/torch-mlir/externals/llvm-project/mlir/lib/Transforms/Utils/DialectConversion.cpp:2405:26
#19 0x0000000004b2b892 (anonymous namespace)::OperationConverter::convertOperations(llvm::ArrayRef<mlir::Operation*>, llvm::function_ref<void (mlir::Diagnostic&)>) /home/chi/src/ubuntu20/shark/torch-mlir/externals/llvm-project/mlir/lib/Transforms/Utils/DialectConversion.cpp:2454:16
#20 0x0000000004b2b539 mlir::applyPartialConversion(llvm::ArrayRef<mlir::Operation*>, mlir::ConversionTarget&, mlir::FrozenRewritePatternSet const&, llvm::DenseSet<mlir::Operation*, llvm::DenseMapInfo<mlir::Operation*, void>>*) /home/chi/src/ubuntu20/shark/torch-mlir/externals/llvm-project/mlir/lib/Transforms/Utils/DialectConversion.cpp:3266:22
#21 0x0000000004b2bae2 mlir::applyPartialConversion(mlir::Operation*, mlir::ConversionTarget&, mlir::FrozenRewritePatternSet const&, llvm::DenseSet<mlir::Operation*, llvm::DenseMapInfo<mlir::Operation*, void>>*) /home/chi/src/ubuntu20/shark/torch-mlir/externals/llvm-project/mlir/lib/Transforms/Utils/DialectConversion.cpp:3272:10
#22 0x000000000333f25d (anonymous namespace)::ConvertTorchToLinalg::runOnOperation() /home/chi/src/ubuntu20/shark/torch-mlir/lib/Conversion/TorchToLinalg/TorchToLinalg.cpp:84:16
#23 0x0000000004bdb530 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) /home/chi/src/ubuntu20/shark/torch-mlir/externals/llvm-project/mlir/lib/Pass/Pass.cpp:470:21
#24 0x0000000004bdbb3a mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) /home/chi/src/ubuntu20/shark/torch-mlir/externals/llvm-project/mlir/lib/Pass/Pass.cpp:533:16
#25 0x0000000004be1316 mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_12::operator()(mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo&) const /home/chi/src/ubuntu20/shark/torch-mlir/externals/llvm-project/mlir/lib/Pass/Pass.cpp:753:36
#26 0x0000000004be0f5c mlir::LogicalResult mlir::failableParallelForEach<__gnu_cxx::__normal_iterator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>>>, mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_12&>(mlir::MLIRContext*, __gnu_cxx::__normal_iterator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>>>, __gnu_cxx::__normal_iterator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>>>, mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_12&) /home/chi/src/ubuntu20/shark/torch-mlir/externals/llvm-project/mlir/include/mlir/IR/Threading.h:46:18
#27 0x0000000004bdce86 mlir::LogicalResult mlir::failableParallelForEach<std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>>&, mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_12&>(mlir::MLIRContext*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>>&, mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_12&) /home/chi/src/ubuntu20/shark/torch-mlir/externals/llvm-project/mlir/include/mlir/IR/Threading.h:92:10
#28 0x0000000004bdc706 mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool) /home/chi/src/ubuntu20/shark/torch-mlir/externals/llvm-project/mlir/lib/Pass/Pass.cpp:763:14
#29 0x0000000004bdb7ed mlir::detail::OpToOpPassAdaptor::runOnOperation(bool) /home/chi/src/ubuntu20/shark/torch-mlir/externals/llvm-project/mlir/lib/Pass/Pass.cpp:654:5
#30 0x0000000004bdb51e mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) /home/chi/src/ubuntu20/shark/torch-mlir/externals/llvm-project/mlir/lib/Pass/Pass.cpp:467:5
#31 0x0000000004bdbb3a mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) /home/chi/src/ubuntu20/shark/torch-mlir/externals/llvm-project/mlir/lib/Pass/Pass.cpp:533:16
#32 0x0000000004bdd4f3 mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) /home/chi/src/ubuntu20/shark/torch-mlir/externals/llvm-project/mlir/lib/Pass/Pass.cpp:836:10
#33 0x0000000004bdd401 mlir::PassManager::run(mlir::Operation*) /home/chi/src/ubuntu20/shark/torch-mlir/externals/llvm-project/mlir/lib/Pass/Pass.cpp:816:60
#34 0x000000000045e56a performActions(llvm::raw_ostream&, bool, bool, llvm::SourceMgr&, mlir::MLIRContext*, llvm::function_ref<mlir::LogicalResult (mlir::PassManager&)>, bool, bool) /home/chi/src/ubuntu20/shark/torch-mlir/externals/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:91:17
#35 0x000000000045e1c3 processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, bool, bool, bool, bool, bool, bool, llvm::function_ref<mlir::LogicalResult (mlir::PassManager&)>, mlir::DialectRegistry&, llvm::ThreadPool*) /home/chi/src/ubuntu20/shark/torch-mlir/externals/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:139:12
#36 0x000000000045df66 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<mlir::LogicalResult (mlir::PassManager&)>, mlir::DialectRegistry&, bool, bool, bool, bool, bool, bool, bool)::$_0::operator()(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) const /home/chi/src/ubuntu20/shark/torch-mlir/externals/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:181:12
#37 0x000000000045de45 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>>, llvm::function_ref<mlir::LogicalResult (mlir::PassManager&)>, mlir::DialectRegistry&, bool, bool, bool, bool, bool, bool, bool)::$_0>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) /home/chi/src/ubuntu20/shark/torch-mlir/externals/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:12
#38 0x0000000004e90f81 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/chi/src/ubuntu20/shark/torch-mlir/externals/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:12
#39 0x0000000004e90501 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/chi/src/ubuntu20/shark/torch-mlir/externals/llvm-project/mlir/lib/Support/ToolUtilities.cpp:28:12
#40 0x000000000045cede mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<mlir::LogicalResult (mlir::PassManager&)>, mlir::DialectRegistry&, bool, bool, bool, bool, bool, bool, bool) /home/chi/src/ubuntu20/shark/torch-mlir/externals/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:186:10
#41 0x000000000045d06a mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::PassPipelineCLParser const&, mlir::DialectRegistry&, bool, bool, bool, bool, bool, bool, bool) /home/chi/src/ubuntu20/shark/torch-mlir/externals/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:205:10
#42 0x000000000045dc64 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&, bool) /home/chi/src/ubuntu20/shark/torch-mlir/externals/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:298:14
#43 0x0000000000418bbd main /home/chi/src/ubuntu20/shark/torch-mlir/tools/torch-mlir-opt/torch-mlir-opt.cpp:26:7
#44 0x00007f1164cc0083 __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:342:3
#45 0x0000000000418a7e _start (/home/chi/src/ubuntu20/shark/torch-mlir/build/bin/torch-mlir-opt+0x418a7e)
[9] 579801 abort (core dumped) /home/chi/src/ubuntu20/shark/torch-mlir/build/bin/torch-mlir-opt
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment