[mlir][sparse] Change getUnorderedCOOFromType to propagate the overhead types.
authorbixia1 <bixia@google.com>
Mon, 17 Oct 2022 21:09:44 +0000 (14:09 -0700)
committerbixia1 <bixia@google.com>
Tue, 18 Oct 2022 15:01:16 +0000 (08:01 -0700)
Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D136112

mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp

index 73f428a..2654887 100644 (file)
@@ -146,12 +146,13 @@ static RankedTensorType getUnorderedCOOFromType(RankedTensorType src) {
   // level should the COO has a unique level at the end. Ends by a unordered
   // unique singleton level.
   dims.push_back(SparseTensorEncodingAttr::DimLevelType::SingletonNo);
+  SparseTensorEncodingAttr encSrc = getSparseTensorEncoding(src);
   // TODO: Maybe pick the bitwidth based on input/output tensors (probably the
   // largest one among them) in the original operation instead of using the
   // default value.
   auto enc = SparseTensorEncodingAttr::get(
-      ctx, dims, AffineMap::getMultiDimIdentityMap(rank, ctx), AffineMap(), 0,
-      0);
+      ctx, dims, AffineMap::getMultiDimIdentityMap(rank, ctx), AffineMap(),
+      encSrc.getPointerBitWidth(), encSrc.getIndexBitWidth());
   return RankedTensorType::get(src.getShape(), src.getElementType(), enc);
 }