[Mlir-commits] [mlir] 9cae928 - [mlir][NFC] Add static ShapedType::isDynamicShape utility
Diego Caballero
llvmlistbot at llvm.org
Fri Nov 18 10:23:02 PST 2022
Author: Diego Caballero
Date: 2022-11-18T18:06:49Z
New Revision: 9cae928f83b4c03b7e1a24e9971786b20e9c4528
URL: https://github.com/llvm/llvm-project/commit/9cae928f83b4c03b7e1a24e9971786b20e9c4528
DIFF: https://github.com/llvm/llvm-project/commit/9cae928f83b4c03b7e1a24e9971786b20e9c4528.diff
LOG: [mlir][NFC] Add static ShapedType::isDynamicShape utility
This utility is useful when we need to know if shape is dynamic and
we don't have a Type itself.
Reviewed By: ftynse
Differential Revision: https://reviews.llvm.org/D138267
Added:
Modified:
mlir/include/mlir/IR/BuiltinTypeInterfaces.td
Removed:
################################################################################
diff --git a/mlir/include/mlir/IR/BuiltinTypeInterfaces.td b/mlir/include/mlir/IR/BuiltinTypeInterfaces.td
index 670b9da6e244..6ecc067cd3c6 100644
--- a/mlir/include/mlir/IR/BuiltinTypeInterfaces.td
+++ b/mlir/include/mlir/IR/BuiltinTypeInterfaces.td
@@ -96,6 +96,10 @@ def ShapedTypeInterface : TypeInterface<"ShapedType"> {
static constexpr bool isDynamic(int64_t dSize) {
return dSize == kDynamicSize;
}
+ /// Whether the given shape has any size that indicates a dynamic dimension.
+ static bool isDynamicShape(ArrayRef<int64_t> dSizes) {
+ return any_of(dSizes, [](int64_t dSize) { return isDynamic(dSize); });
+ }
static constexpr bool isDynamicStrideOrOffset(int64_t dStrideOrOffset) {
return dStrideOrOffset == kDynamicStrideOrOffset;
}
@@ -156,7 +160,7 @@ def ShapedTypeInterface : TypeInterface<"ShapedType"> {
/// all dimensions have known size (>= 0).
bool hasStaticShape() const {
return $_type.hasRank() &&
- llvm::none_of($_type.getShape(), ::mlir::ShapedType::isDynamic);
+ !::mlir::ShapedType::isDynamicShape($_type.getShape());
}
/// Returns if this type has a static shape and the shape is equal to
More information about the Mlir-commits
mailing list