From 15075d5a2262af82012909076a5a7d4556af1879 Mon Sep 17 00:00:00 2001 From: Geoffrey Martin-Noble Date: Fri, 24 May 2019 17:46:58 -0700 Subject: [PATCH] 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 --- mlir/lib/IR/Operation.cpp | 2 +- mlir/lib/Parser/Parser.cpp | 7 +++---- mlir/test/IR/invalid.mlir | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) 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}} } // ----- -- 2.7.4