[Mlir-commits] [mlir] [mlir][Math] Fix 0-rank support for PolynomialApproximation (PR #114826)
Benjamin Maxwell
llvmlistbot at llvm.org
Mon Nov 4 09:47:46 PST 2024
================
@@ -43,20 +43,18 @@ using namespace mlir::vector;
struct VectorShape {
ArrayRef<int64_t> sizes;
ArrayRef<bool> scalableFlags;
-
- bool empty() const { return sizes.empty(); }
};
// Returns vector shape if the type is a vector. Returns an empty shape if it is
// not a vector.
-static VectorShape vectorShape(Type type) {
+static std::optional<VectorShape> vectorShape(Type type) {
auto vectorType = dyn_cast<VectorType>(type);
- return vectorType
- ? VectorShape{vectorType.getShape(), vectorType.getScalableDims()}
- : VectorShape{};
+ return vectorType ? std::optional(VectorShape{vectorType.getShape(),
+ vectorType.getScalableDims()})
+ : std::nullopt;
----------------
MacDue wrote:
nit: I think this is simpler without the ternary now.
```suggestion
if (vectorType)
return VectorShape{vectorType.getShape(), vectorType.getScalableDims()};
return std::nullopt;
```
https://github.com/llvm/llvm-project/pull/114826
More information about the Mlir-commits
mailing list