[Mlir-commits] [mlir] 537137e - mlir/linalg: use std::optional
Kazu Hirata
llvmlistbot at llvm.org
Sun Nov 27 13:32:33 PST 2022
Author: Ramkumar Ramachandra
Date: 2022-11-27T13:32:20-08:00
New Revision: 537137ece1dd0c155e893f551bf50c00d2e0ab9b
URL: https://github.com/llvm/llvm-project/commit/537137ece1dd0c155e893f551bf50c00d2e0ab9b
DIFF: https://github.com/llvm/llvm-project/commit/537137ece1dd0c155e893f551bf50c00d2e0ab9b.diff
LOG: mlir/linalg: use std::optional
This is part of an effort to migrate from llvm::Optional to std::optional:
See also: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
Signed-off-by: Ramkumar Ramachandra <r at artagnon.com>
Added:
Modified:
mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp
mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp b/mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp
index 7b9b7358bb459..d6ddfffefa919 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp
@@ -242,7 +242,7 @@ struct UnitExtentReplacementInfo {
/// - modified index map that can be used to access the replaced result/operand
/// - the reassociation that converts from the original tensor type to the
/// modified tensor type.
-static llvm::Optional<UnitExtentReplacementInfo>
+static std::optional<UnitExtentReplacementInfo>
replaceUnitExtents(GenericOp genericOp, OpOperand *opOperand,
MLIRContext *context) {
AffineMap indexingMap = genericOp.getMatchingIndexingMap(opOperand);
diff --git a/mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp b/mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp
index 1676500d8109c..79d3e5524dc4e 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp
@@ -57,14 +57,14 @@ struct HoistableRead {
/// Return true if op1 and op2 are the same constant or the same SSA value.
static bool isEqualOffsetSizeOrStride(OpFoldResult op1, OpFoldResult op2) {
- auto getConstantIntValue = [](OpFoldResult ofr) -> llvm::Optional<int64_t> {
+ auto getConstantIntValue = [](OpFoldResult ofr) -> std::optional<int64_t> {
Attribute attr = ofr.dyn_cast<Attribute>();
// Note: isa+cast-like pattern allows writing the condition below as 1 line.
if (!attr && ofr.get<Value>().getDefiningOp<arith::ConstantOp>())
attr = ofr.get<Value>().getDefiningOp<arith::ConstantOp>().getValue();
if (auto intAttr = attr.dyn_cast_or_null<IntegerAttr>())
return intAttr.getValue().getSExtValue();
- return llvm::None;
+ return std::nullopt;
};
auto cst1 = getConstantIntValue(op1), cst2 = getConstantIntValue(op2);
if (cst1 && cst2 && *cst1 == *cst2)
More information about the Mlir-commits
mailing list