[Mlir-commits] [mlir] c45c53b - [Shape] Simplify getShapeVec a bit. NFCI.
Benjamin Kramer
llvmlistbot at llvm.org
Sun Feb 13 08:01:53 PST 2022
Author: Benjamin Kramer
Date: 2022-02-13T16:58:16+01:00
New Revision: c45c53bbae2801123776983dbd36a751284fa097
URL: https://github.com/llvm/llvm-project/commit/c45c53bbae2801123776983dbd36a751284fa097
DIFF: https://github.com/llvm/llvm-project/commit/c45c53bbae2801123776983dbd36a751284fa097.diff
LOG: [Shape] Simplify getShapeVec a bit. NFCI.
Added:
Modified:
mlir/lib/Dialect/Shape/IR/Shape.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/Shape/IR/Shape.cpp b/mlir/lib/Dialect/Shape/IR/Shape.cpp
index 89a976686492c..5c851f579ef85 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();
More information about the Mlir-commits
mailing list