diff options
| author | Benjamin Kramer <benny.kra@googlemail.com> | 2022-02-13 16:57:48 +0100 |
|---|---|---|
| committer | Benjamin Kramer <benny.kra@googlemail.com> | 2022-02-13 16:58:16 +0100 |
| commit | c45c53bbae2801123776983dbd36a751284fa097 (patch) | |
| tree | c1682e8f4e648e5649ad7030209aa6a20c4a2afd | |
| parent | 634da7a1c61ee8c173e90a841eb1f4ea03caa20b (diff) | |
[Shape] Simplify getShapeVec a bit. NFCI.
| -rw-r--r-- | mlir/lib/Dialect/Shape/IR/Shape.cpp | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/mlir/lib/Dialect/Shape/IR/Shape.cpp b/mlir/lib/Dialect/Shape/IR/Shape.cpp index 89a976686492..5c851f579ef8 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<int64_t> &shapeValues) { if (auto inputOp = input.getDefiningOp<ShapeOfOp>()) { - auto type = inputOp.getArg().getType().dyn_cast<ShapedType>(); + auto type = inputOp.getArg().getType().cast<ShapedType>(); 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<ConstShapeOp>()) { - shapeValues = llvm::to_vector<6>(inputOp.getShape().getValues<int64_t>()); - return success(); - } - if (auto inputOp = input.getDefiningOp<arith::ConstantOp>()) { - shapeValues = llvm::to_vector<6>( - inputOp.getValue().cast<DenseIntElementsAttr>().getValues<int64_t>()); + DenseIntElementsAttr attr; + if (matchPattern(input, m_Constant(&attr))) { + llvm::append_range(shapeValues, attr.getValues<int64_t>()); return success(); } return failure(); |
