[Mlir-commits] [mlir] d824af5 - [mlir][sparse] Improving error-detection for `STEA::get{Pos, Crd}Type`
wren romano
llvmlistbot at llvm.org
Fri May 19 16:24:46 PDT 2023
Author: wren romano
Date: 2023-05-19T16:24:38-07:00
New Revision: d824af535cb9b6726d73dc062025ee41c149cd73
URL: https://github.com/llvm/llvm-project/commit/d824af535cb9b6726d73dc062025ee41c149cd73
DIFF: https://github.com/llvm/llvm-project/commit/d824af535cb9b6726d73dc062025ee41c149cd73.diff
LOG: [mlir][sparse] Improving error-detection for `STEA::get{Pos,Crd}Type`
Reviewed By: aartbik
Differential Revision: https://reviews.llvm.org/D150995
Added:
Modified:
mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorAttrDefs.td
mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorAttrDefs.td b/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorAttrDefs.td
index f8a66b349874..d3cbb297cc41 100644
--- a/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorAttrDefs.td
+++ b/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorAttrDefs.td
@@ -293,10 +293,14 @@ def SparseTensorEncodingAttr : SparseTensor_Attr<"SparseTensorEncoding",
];
let extraClassDeclaration = [{
- /// Returns the type for position storage based on posWidth
+ /// Returns the type for position storage based on posWidth.
+ /// Asserts that the encoding is non-null (since there's nowhere
+ /// to get the `MLIRContext` from).
Type getPosType() const;
- /// Returns the type for coordinate storage based on crdWidth
+ /// Returns the type for coordinate storage based on crdWidth.
+ /// Asserts that the encoding is non-null (since there's nowhere
+ /// to get the `MLIRContext` from).
Type getCrdType() const;
/// Constructs a new encoding with the dimOrdering and higherOrdering
diff --git a/mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp b/mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp
index e3f8d4cb9f96..41805107588a 100644
--- a/mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp
+++ b/mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp
@@ -254,10 +254,12 @@ Type mlir::sparse_tensor::detail::getIntegerOrIndexType(MLIRContext *ctx,
}
Type SparseTensorEncodingAttr::getPosType() const {
+ assert(getImpl() && "Uninitialized SparseTensorEncodingAttr");
return detail::getIntegerOrIndexType(getContext(), getPosWidth());
}
Type SparseTensorEncodingAttr::getCrdType() const {
+ assert(getImpl() && "Uninitialized SparseTensorEncodingAttr");
return detail::getIntegerOrIndexType(getContext(), getCrdWidth());
}
More information about the Mlir-commits
mailing list