[mlir][sparse] adding SparseTensorType::get{Pointer,Index}Type methods

Depends On D143800

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D143946
This commit is contained in:
wren romano
2023-02-15 13:31:05 -08:00
parent 8bd0e9481c
commit ae7942e296
5 changed files with 26 additions and 13 deletions

View File

@@ -114,18 +114,19 @@ SparseTensorDimSliceAttr::verify(function_ref<InFlightDiagnostic()> emitError,
<< "expect positive value or ? for slice offset/size/stride";
}
static Type getIntegerOrIndexType(MLIRContext *ctx, unsigned bitwidth) {
Type mlir::sparse_tensor::detail::getIntegerOrIndexType(MLIRContext *ctx,
unsigned bitwidth) {
if (bitwidth)
return IntegerType::get(ctx, bitwidth);
return IndexType::get(ctx);
}
Type SparseTensorEncodingAttr::getPointerType() const {
return getIntegerOrIndexType(getContext(), getPointerBitWidth());
return detail::getIntegerOrIndexType(getContext(), getPointerBitWidth());
}
Type SparseTensorEncodingAttr::getIndexType() const {
return getIntegerOrIndexType(getContext(), getIndexBitWidth());
return detail::getIntegerOrIndexType(getContext(), getIndexBitWidth());
}
SparseTensorEncodingAttr SparseTensorEncodingAttr::withoutOrdering() const {