From c45c53bbae2801123776983dbd36a751284fa097 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Sun, 13 Feb 2022 16:57:48 +0100 Subject: [PATCH] [Shape] Simplify getShapeVec a bit. NFCI. --- mlir/lib/Dialect/Shape/IR/Shape.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/mlir/lib/Dialect/Shape/IR/Shape.cpp b/mlir/lib/Dialect/Shape/IR/Shape.cpp index 89a9766..5c851f5 100644 --- a/mlir/lib/Dialect/Shape/IR/Shape.cpp +++ b/mlir/lib/Dialect/Shape/IR/Shape.cpp @@ -47,19 +47,15 @@ bool shape::isExtentTensorType(Type type) { LogicalResult shape::getShapeVec(Value input, SmallVectorImpl &shapeValues) { if (auto inputOp = input.getDefiningOp()) { - auto type = inputOp.getArg().getType().dyn_cast(); + auto type = inputOp.getArg().getType().cast(); if (!type.hasRank()) return failure(); - shapeValues = llvm::to_vector<6>(type.getShape()); + llvm::append_range(shapeValues, type.getShape()); return success(); } - if (auto inputOp = input.getDefiningOp()) { - shapeValues = llvm::to_vector<6>(inputOp.getShape().getValues()); - return success(); - } - if (auto inputOp = input.getDefiningOp()) { - shapeValues = llvm::to_vector<6>( - inputOp.getValue().cast().getValues()); + DenseIntElementsAttr attr; + if (matchPattern(input, m_Constant(&attr))) { + llvm::append_range(shapeValues, attr.getValues()); return success(); } return failure(); -- 2.7.4