From: Geoffrey Martin-Noble Date: Sat, 25 May 2019 00:46:58 +0000 (-0700) Subject: Replace checks for rank -1 with direct calls to hasRank X-Git-Tag: llvmorg-11-init~1466^2~1605 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=15075d5a2262af82012909076a5a7d4556af1879;p=platform%2Fupstream%2Fllvm.git Replace checks for rank -1 with direct calls to hasRank Also removed a redundant check for rank after already checking for static shape (which implies rank) -- PiperOrigin-RevId: 249927636 --- diff --git a/mlir/lib/IR/Operation.cpp b/mlir/lib/IR/Operation.cpp index 582fb39..f6fc3ee 100644 --- a/mlir/lib/IR/Operation.cpp +++ b/mlir/lib/IR/Operation.cpp @@ -783,7 +783,7 @@ static LogicalResult verifyShapeMatch(Type type1, Type type2) { if (!sType1) return success(!sType2); - if (sType1.getRank() == -1 || sType2.getRank() == -1) + if (!sType1.hasRank() || !sType2.hasRank()) return success(); return success(sType1.getShape() == sType2.getShape()); diff --git a/mlir/lib/Parser/Parser.cpp b/mlir/lib/Parser/Parser.cpp index 1f37d2e..c2761a2 100644 --- a/mlir/lib/Parser/Parser.cpp +++ b/mlir/lib/Parser/Parser.cpp @@ -1383,7 +1383,7 @@ DenseElementsAttr Parser::parseDenseElementsAttr(ShapedType type) { /// /// shaped-type ::= vector-type | tensor-type /// -/// This method also checks the type has static shape and ranked. +/// This method also checks the type has static shape. ShapedType Parser::parseShapedType() { auto elementType = parseType(); if (!elementType) @@ -1397,9 +1397,8 @@ ShapedType Parser::parseShapedType() { if (parseToken(Token::comma, "expected ','")) return nullptr; - if (!type.hasStaticShape() || type.getRank() == -1) { - return (emitError("shaped literal must be ranked and have static shape"), - nullptr); + if (!type.hasStaticShape()) { + return (emitError("shaped literal must have static shape"), nullptr); } return type; } diff --git a/mlir/test/IR/invalid.mlir b/mlir/test/IR/invalid.mlir index 0b69c04..fef4119 100644 --- a/mlir/test/IR/invalid.mlir +++ b/mlir/test/IR/invalid.mlir @@ -598,7 +598,7 @@ func @elementsattr_non_tensor_type() -> () { func @elementsattr_non_ranked() -> () { ^bb0: - "foo"(){bar: dense, [4]>} : () -> () // expected-error {{shaped literal must be ranked and have static shape}} + "foo"(){bar: dense, [4]>} : () -> () // expected-error {{shaped literal must have static shape}} } // -----