[mlir][sparse] convert a sparse tensor slice to sparse tensor correctly.

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D147074
This commit is contained in:
Peiming Liu
2023-03-28 19:54:34 +00:00
parent 9f15f1f0f3
commit 33267f4007
5 changed files with 51 additions and 2 deletions

View File

@@ -701,6 +701,11 @@ LogicalResult ConvertOp::verify() {
if (auto tp2 = getDest().getType().dyn_cast<RankedTensorType>()) {
if (tp1.getRank() != tp2.getRank())
return emitError("unexpected conversion mismatch in rank");
auto dstEnc =
tp2.getEncoding().dyn_cast_or_null<SparseTensorEncodingAttr>();
if (dstEnc && dstEnc.isSlice())
return emitError("cannot convert to a sparse tensor slice");
auto shape1 = tp1.getShape();
auto shape2 = tp2.getShape();
// Accept size matches between the source and the destination type