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

vectorizedPipelineOp without outputs not supported #874

Open
m-birke opened this issue Oct 23, 2024 · 2 comments
Open

vectorizedPipelineOp without outputs not supported #874

m-birke opened this issue Oct 23, 2024 · 2 comments
Labels
bug A mistake in the code.

Comments

@m-birke
Copy link
Collaborator

m-birke commented Oct 23, 2024

Executing the following script with --vec it gives the error msg below

a = as.matrix([0.506232,0.112481,0.277686,0.147521]);
points = cbind(a, a);
//print(points);
[error]: Lowering pipeline error.{}
PassManager failed module lowering, responsible IR written to module_fail.log.
LowerToLLVMPass failed with the following message [ vectorizedPipelineOp without outputs not supported at the moment! ]
    | Source file -> ".../cbind.daphne":2:9
    |
  2 | points = cbind(a, a);
    |                ^~~

Uncommenting print(points); resolves the problem.

In more complicated scripts which loads data from file and does kernel casts, this error message is not given. It runs into a seg fault instead. By just adding a print statement at the end of the mentioned script, it runs.

Stacktrace:

#0  0x00000000020f3293 in mlir::FileLineColLoc::getFilename() const ()
#1  0x000000000162bda9 in ErrorHandler::compilerError(mlir::Location, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) ()
#2  0x000000000162c5fd in ErrorHandler::compilerError(mlir::Operation*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) ()
#3  0x00000000016a0235 in VectorizedPipelineOpLowering::matchAndRewrite(mlir::daphne::VectorizedPipelineOp, mlir::daphne::VectorizedPipelineOpAdaptor, mlir::ConversionPatternRewriter&) const ()
#4  0x0000000001688273 in mlir::OpConversionPattern<mlir::daphne::VectorizedPipelineOp>::matchAndRewrite(mlir::Operation*, llvm::ArrayRef<mlir::Value>, mlir::ConversionPatternRewriter&) const ()
#5  0x0000000001def638 in mlir::ConversionPattern::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const ()
#6  0x0000000001e3e123 in 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&)>) ()
#7  0x0000000001dfc6ea in (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*, mlir::ConversionPatternRewriter&) ()
#8  0x0000000001df22f4 in (anonymous namespace)::OperationConverter::convertOperations(llvm::ArrayRef<mlir::Operation*>, llvm::function_ref<void (mlir::Diagnostic&)>) ()
#9  0x0000000001df2a73 in mlir::applyFullConversion(mlir::Operation*, mlir::ConversionTarget&, mlir::FrozenRewritePatternSet const&) ()
#10 0x00000000016993f9 in (anonymous namespace)::DaphneLowerToLLVMPass::runOnOperation() ()
#11 0x0000000001ed02c5 in mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) ()
#12 0x0000000001ed0917 in mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) ()
#13 0x0000000001ed3150 in mlir::PassManager::run(mlir::Operation*) ()
#14 0x000000000144880f in DaphneIrExecutor::runPasses(mlir::ModuleOp) ()
#15 0x00000000013c69ea in startDAPHNE(int, char const**, DaphneLibResult*, int*, DaphneUserConfig&) ()
#16 0x00000000013cbe88 in mainInternal(int, char const**, DaphneLibResult*) ()
#17 0x00007ffff49c4d85 in __libc_start_main () from /lib64/libc.so.6
#18 0x00000000013a5d6e in _start ()
@m-birke m-birke added the bug A mistake in the code. label Oct 23, 2024
@philipportner
Copy link
Collaborator

Thanks @m-birke .

Trying our internal script, I can confirm that the error there is the same. We already fail somewhere in the VectorizedPipelineOpLowering rewrite pattern. When we fail there we try to create a readable exception, similar to the one you posted above, but probably have incorrect mlir::FileLineColLoc information so we segfault when creating the error.

More specifically, this happens here.

@philipportner
Copy link
Collaborator

philipportner commented Oct 23, 2024

This is happening because the code that is being vectorized is not used afterwards, so the canonicalize method of the VectorizedPipelineOp is pruning away stuff, leaving something that looks as follows:

"daphne.vectorizedPipeline"(%757, %927, %921, %943, %955, %939, %282) ({
}, {
}) {combines = [], operand_segment_sizes = array<i32: 6, 0, 0, 1>, splits = [1, 0, 1, 0, 0, 0]} : (!daphne.Matrix<?x?xf64>, f64, !daphne.Matrix<?x?xf64>, f64, f64, f64, !daphne.DaphneContext) -> ()

This should be deleted properly so we don't run into the intended exception for this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A mistake in the code.
Projects
None yet
Development

No branches or pull requests

2 participants