[mlir][sparse] codegen for sparse dealloc

Reviewed By: bixia

Differential Revision: https://reviews.llvm.org/D133171
This commit is contained in:
Aart Bik
2022-09-01 17:18:56 -07:00
parent 11881a8f3f
commit 2ddfacd95c
3 changed files with 56 additions and 9 deletions

View File

@@ -124,8 +124,7 @@ struct SparseTensorConversionPass
});
// The following operations and dialects may be introduced by the
// rewriting rules, and are therefore marked as legal.
target.addLegalOp<bufferization::ToMemrefOp, bufferization::ToTensorOp,
complex::ConstantOp, complex::NotEqualOp, linalg::FillOp,
target.addLegalOp<complex::ConstantOp, complex::NotEqualOp, linalg::FillOp,
linalg::YieldOp, tensor::ExtractOp>();
target.addLegalDialect<
arith::ArithmeticDialect, bufferization::BufferizationDialect,
@@ -160,7 +159,9 @@ struct SparseTensorCodegenPass
// Almost everything in the sparse dialect must go!
target.addIllegalDialect<SparseTensorDialect>();
target.addLegalOp<StorageGetOp, StorageSetOp>();
// All dynamic rules below accept new function, call, return.
// All dynamic rules below accept new function, call, return, and various
// tensor and bufferization operations as legal output of the rewriting
// provided that all sparse tensor types have been fully rewritten.
target.addDynamicallyLegalOp<func::FuncOp>([&](func::FuncOp op) {
return converter.isSignatureLegal(op.getFunctionType());
});
@@ -170,6 +171,10 @@ struct SparseTensorCodegenPass
target.addDynamicallyLegalOp<func::ReturnOp>([&](func::ReturnOp op) {
return converter.isLegal(op.getOperandTypes());
});
target.addDynamicallyLegalOp<bufferization::DeallocTensorOp>(
[&](bufferization::DeallocTensorOp op) {
return converter.isLegal(op.getTensor().getType());
});
// Legal dialects may occur in generated code.
target.addLegalDialect<arith::ArithmeticDialect,
bufferization::BufferizationDialect,