Skip to content

Conversation

@jpienaar
Copy link
Member

@jpienaar jpienaar commented May 2, 2024

No description provided.

@bjacob
Copy link
Contributor

bjacob commented May 7, 2024

The error there,

https://github.com/llvm/torch-mlir/actions/runs/8930048121/job/24533271831?pr=3279#step:8:1358

  python: /_work/torch-mlir/torch-mlir/externals/llvm-project/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp:1681: static void mlir::tensor::ExpandShapeOp::build(OpBuilder &, OperationState &, Type, Value, ArrayRef<ReassociationIndices>): Assertion `succeeded(outputShape) && "unable to infer output shape"' failed.

means that ExpandShapeOp::build now requires a new outputShape parameter that is effectively mandatory as guarded by that assertion, and apparently some C++ caller here needs to be updated to pass it.

@aartbik
Copy link
Contributor

aartbik commented May 7, 2024

Ah, note that I was also working on an MLIR bump (#3282) where I started to fix the deprecation stuff. This seems faster :-)

@bjacob
Copy link
Contributor

bjacob commented May 7, 2024

Finally got a stack trace to that failing outputShape assertion. It was not easy because it's wrapped in python; but I was able to edit the c++ code to programmatically dump the stack.

python: /home/benoit/torch-mlir/externals/llvm-project/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp:1686: static void mlir::tensor::ExpandShapeOp::build(OpBuilder &, OperationState &, Type, Value, ArrayRef<ReassociationIndices>): Assertion `succeeded(outputShape) && "unable to infer output shape"' failed.
[W507 11:16:45.287055790 TensorShape.cpp:3683] Warning: Tensor.T is deprecated on 0-D tensors. This function is the identity in these cases. (function operator())
[W507 11:16:45.398054949 TensorShape.cpp:3675] Warning: The use of `x.T` on tensors of dimension other than 2 to reverse their shape is deprecated and it will throw an error in a future release. Consider `x.mT` to transpose batches of matrices or `x.permute(*torch.arange(x.ndim - 1, -1, -1))` to reverse the dimensions of a tensor. (function operator())
 #0 0x0000742814db1eb8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/benoit/torch-mlir/build/tools/torch-mlir/python_packages/torch_mlir/torch_mlir/_mlir_libs/libTorchMLIRAggregateCAPI.so+0x39b1eb8)
 #1 0x000074281787fc43 mlir::tensor::ExpandShapeOp::build(mlir::OpBuilder&, mlir::OperationState&, mlir::Type, mlir::Value, llvm::ArrayRef<llvm::SmallVector<long, 2u>>) (/home/benoit/torch-mlir/build/tools/torch-mlir/python_packages/torch_mlir/torch_mlir/_mlir_libs/libTorchMLIRAggregateCAPI.so+0x647fc43)
 #2 0x000074281789f6a2 mlir::tensor::ExpandShapeOp::build(mlir::OpBuilder&, mlir::OperationState&, mlir::Type, mlir::Value, llvm::ArrayRef<llvm::SmallVector<mlir::AffineExpr, 2u>>) (/home/benoit/torch-mlir/build/tools/torch-mlir/python_packages/torch_mlir/torch_mlir/_mlir_libs/libTorchMLIRAggregateCAPI.so+0x649f6a2)
 #3 0x00007428163c2388 void mlir::OpBuilder::createOrFold<mlir::tensor::ExpandShapeOp, mlir::TensorType&, mlir::Value&, llvm::SmallVector<llvm::SmallVector<mlir::AffineExpr, 2u>, 1u>&>(llvm::SmallVectorImpl<mlir::Value>&, mlir::Location, mlir::TensorType&, mlir::Value&, llvm::SmallVector<llvm::SmallVector<mlir::AffineExpr, 2u>, 1u>&) TosaToTensor.cpp:0:0
 #4 0x00007428163c1079 (anonymous namespace)::ReshapeConverter::matchAndRewrite(mlir::tosa::ReshapeOp, mlir::tosa::ReshapeOpAdaptor, mlir::ConversionPatternRewriter&) const TosaToTensor.cpp:0:0
 #5 0x00007428163c05e0 mlir::OpConversionPattern<mlir::tosa::ReshapeOp>::matchAndRewrite(mlir::Operation*, llvm::ArrayRef<mlir::Value>, mlir::ConversionPatternRewriter&) const TosaToTensor.cpp:0:0
 #6 0x000074281a1df471 mlir::ConversionPattern::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const (/home/benoit/torch-mlir/build/tools/torch-mlir/python_packages/torch_mlir/torch_mlir/_mlir_libs/libTorchMLIRAggregateCAPI.so+0x8ddf471)
 #7 0x000074281a2293be void llvm::function_ref<void ()>::callback_fn<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&)>)::$_0>(long) PatternApplicator.cpp:0:0
 #8 0x000074281a225c4b 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/benoit/torch-mlir/build/tools/torch-mlir/python_packages/torch_mlir/torch_mlir/_mlir_libs/libTorchMLIRAggregateCAPI.so+0x8e25c4b)
 #9 0x000074281a1e0231 (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*, mlir::ConversionPatternRewriter&) DialectConversion.cpp:0:0
#10 0x000074281a1df507 mlir::OperationConverter::convert(mlir::ConversionPatternRewriter&, mlir::Operation*) (/home/benoit/torch-mlir/build/tools/torch-mlir/python_packages/torch_mlir/torch_mlir/_mlir_libs/libTorchMLIRAggregateCAPI.so+0x8ddf507)
#11 0x000074281a1e0750 mlir::OperationConverter::convertOperations(llvm::ArrayRef<mlir::Operation*>) (/home/benoit/torch-mlir/build/tools/torch-mlir/python_packages/torch_mlir/torch_mlir/_mlir_libs/libTorchMLIRAggregateCAPI.so+0x8de0750)
#12 0x000074281a1e85bb mlir::applyPartialConversion(mlir::Operation*, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig) (/home/benoit/torch-mlir/build/tools/torch-mlir/python_packages/torch_mlir/torch_mlir/_mlir_libs/libTorchMLIRAggregateCAPI.so+0x8de85bb)
#13 0x00007428163bc79c (anonymous namespace)::TosaToTensor::runOnOperation() TosaToTensorPass.cpp:0:0
#14 0x0000742814cf856f mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/home/benoit/torch-mlir/build/tools/torch-mlir/python_packages/torch_mlir/torch_mlir/_mlir_libs/libTorchMLIRAggregateCAPI.so+0x38f856f)
#15 0x0000742814cf8e80 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/home/benoit/torch-mlir/build/tools/torch-mlir/python_packages/torch_mlir/torch_mlir/_mlir_libs/libTorchMLIRAggregateCAPI.so+0x38f8e80)
#16 0x0000742814cfaafe mlir::detail::OpToOpPassAdaptor::runOnOperationImpl(bool) (/home/benoit/torch-mlir/build/tools/torch-mlir/python_packages/torch_mlir/torch_mlir/_mlir_libs/libTorchMLIRAggregateCAPI.so+0x38faafe)
#17 0x0000742814cf86c0 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/home/benoit/torch-mlir/build/tools/torch-mlir/python_packages/torch_mlir/torch_mlir/_mlir_libs/libTorchMLIRAggregateCAPI.so+0x38f86c0)
#18 0x0000742814cf8e80 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/home/benoit/torch-mlir/build/tools/torch-mlir/python_packages/torch_mlir/torch_mlir/_mlir_libs/libTorchMLIRAggregateCAPI.so+0x38f8e80)
#19 0x0000742814cfb67f mlir::PassManager::run(mlir::Operation*) (/home/benoit/torch-mlir/build/tools/torch-mlir/python_packages/torch_mlir/torch_mlir/_mlir_libs/libTorchMLIRAggregateCAPI.so+0x38fb67f)
#20 0x0000742814c61dd6 mlirPassManagerRunOnOp (/home/benoit/torch-mlir/build/tools/torch-mlir/python_packages/torch_mlir/torch_mlir/_mlir_libs/libTorchMLIRAggregateCAPI.so+0x3861dd6)

@bjacob
Copy link
Contributor

bjacob commented May 7, 2024

bjacob added a commit to llvm/llvm-project that referenced this pull request May 7, 2024
Unblocking downstream integrate where an expected-to-fail test was
expecting this to be a runtime verifier error, not a compiler crash:
llvm/torch-mlir#3279.
@bjacob
Copy link
Contributor

bjacob commented May 7, 2024

Started #3300 to carry on the work started here.

@penguin-wwy penguin-wwy closed this May 9, 2024
@penguin-wwy penguin-wwy deleted the integrate-llvm-20240501 branch May 9, 2024 02:56
@penguin-wwy penguin-wwy restored the integrate-llvm-20240501 branch May 9, 2024 02:58
@penguin-wwy penguin-wwy reopened this May 9, 2024
@bjacob bjacob closed this May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants