[mlir] Unranked memref type has no rank
authorJacques Pienaar <jpienaar@google.com>
Tue, 9 Jun 2020 01:00:35 +0000 (18:00 -0700)
committerJacques Pienaar <jpienaar@google.com>
Tue, 9 Jun 2020 01:08:14 +0000 (18:08 -0700)
Summary:
UnrankedMemRefType doesn't have a rank but previously this was just
checking for unranked tensor. Avoids failure later if one queries the shape
post checking if ranked.

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

mlir/lib/IR/StandardTypes.cpp

index 7a823ee..117cd68 100644 (file)
@@ -199,7 +199,9 @@ int64_t ShapedType::getNumElements() const {
 
 int64_t ShapedType::getRank() const { return getShape().size(); }
 
-bool ShapedType::hasRank() const { return !isa<UnrankedTensorType>(); }
+bool ShapedType::hasRank() const {
+  return !isa<UnrankedMemRefType>() && !isa<UnrankedTensorType>();
+}
 
 int64_t ShapedType::getDimSize(unsigned idx) const {
   assert(idx < getRank() && "invalid index for shaped type");