[Mlir-commits] [mlir] 50a7c77 - [mlir][sparse] Calling `SparseTensorType::get{Pos, Crd}Type` directly

wren romano llvmlistbot at llvm.org
Thu May 18 12:29:03 PDT 2023


Author: wren romano
Date: 2023-05-18T12:28:54-07:00
New Revision: 50a7c77389b031de1127c88266a22bc04063aca7

URL: https://github.com/llvm/llvm-project/commit/50a7c77389b031de1127c88266a22bc04063aca7
DIFF: https://github.com/llvm/llvm-project/commit/50a7c77389b031de1127c88266a22bc04063aca7.diff

LOG: [mlir][sparse] Calling `SparseTensorType::get{Pos,Crd}Type` directly

The `SparseTensorType` versions of these methods have some special handling to ensure that they work for unannotated tensors; whereas, the `stt.getEncoding().get{Pos,Crd}Type()` idiom can cause segfaults.

Reviewed By: Peiming

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

Added: 
    

Modified: 
    mlir/lib/Dialect/SparseTensor/Transforms/CodegenUtils.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Dialect/SparseTensor/Transforms/CodegenUtils.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/CodegenUtils.cpp
index ace8a8867081d..131add5e7fc98 100644
--- a/mlir/lib/Dialect/SparseTensor/Transforms/CodegenUtils.cpp
+++ b/mlir/lib/Dialect/SparseTensor/Transforms/CodegenUtils.cpp
@@ -664,7 +664,7 @@ Value sparse_tensor::reshapeValuesToLevels(OpBuilder &builder, Location loc,
 Value sparse_tensor::genToPositions(OpBuilder &builder, Location loc,
                                     Value tensor, Level lvl) {
   const auto srcTp = getSparseTensorType(tensor);
-  const Type posTp = srcTp.getEncoding().getPosType();
+  const Type posTp = srcTp.getPosType();
   const Type memTp = get1DMemRefType(posTp, /*withLayout=*/false);
   return builder.create<ToPositionsOp>(loc, memTp, tensor,
                                        builder.getIndexAttr(lvl));
@@ -673,7 +673,7 @@ Value sparse_tensor::genToPositions(OpBuilder &builder, Location loc,
 Value sparse_tensor::genToCoordinates(OpBuilder &builder, Location loc,
                                       Value tensor, Level lvl, Level cooStart) {
   const auto srcTp = getSparseTensorType(tensor);
-  const Type crdTp = srcTp.getEncoding().getCrdType();
+  const Type crdTp = srcTp.getCrdType();
   const Type memTp = get1DMemRefType(crdTp, /*withLayout=*/lvl >= cooStart);
   return builder.create<ToCoordinatesOp>(loc, memTp, tensor,
                                          builder.getIndexAttr(lvl));
@@ -682,7 +682,7 @@ Value sparse_tensor::genToCoordinates(OpBuilder &builder, Location loc,
 Value sparse_tensor::genToCoordinatesBuffer(OpBuilder &builder, Location loc,
                                             Value tensor) {
   const auto srcTp = getSparseTensorType(tensor);
-  const Type crdTp = srcTp.getEncoding().getCrdType();
+  const Type crdTp = srcTp.getCrdType();
   const Type memTp = get1DMemRefType(crdTp, /*withLayout=*/false);
   return builder.create<ToCoordinatesBufferOp>(loc, memTp, tensor);
 }


        


More information about the Mlir-commits mailing list