Skip to content

Commit fecf139

Browse files
[Tensor] Migrate away from PointerUnion::{is,get} (NFC) (llvm#120679)
Note that PointerUnion::{is,get} have been soft deprecated in PointerUnion.h: // FIXME: Replace the uses of is(), get() and dyn_cast() with // isa<T>, cast<T> and the llvm::dyn_cast<T> I'm not touching PointerUnion::dyn_cast for now because it's a bit complicated; we could blindly migrate it to dyn_cast_if_present, but we should probably use dyn_cast when the operand is known to be non-null.
1 parent 3e13acf commit fecf139

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

mlir/lib/Dialect/Tensor/IR/TensorOps.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ static llvm::SmallBitVector getDroppedDims(ArrayRef<int64_t> reducedShape,
142142
size_t idx = mixedSizes.size() - size.index() - 1;
143143
// Rank-reduced dims must have a static unit dimension.
144144
bool isStaticUnitSize =
145-
size.value().is<Attribute>() &&
146-
llvm::cast<IntegerAttr>(size.value().get<Attribute>()).getInt() == 1;
145+
isa<Attribute>(size.value()) &&
146+
llvm::cast<IntegerAttr>(cast<Attribute>(size.value())).getInt() == 1;
147147

148148
if (shapePos < 0) {
149149
// There are no more dims in the reduced shape. All remaining sizes must

mlir/lib/Dialect/Tensor/Transforms/BufferizableOpInterfaceImpl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -761,8 +761,8 @@ struct PadOpInterface
761761
RankedTensorType srcType = padOp.getSourceType();
762762

763763
auto toValue = [&](OpFoldResult ofr) {
764-
if (ofr.is<Value>())
765-
return ofr.get<Value>();
764+
if (auto value = dyn_cast<Value>(ofr))
765+
return value;
766766
return rewriter
767767
.create<arith::ConstantIndexOp>(loc, *getConstantIntValue(ofr))
768768
.getResult();

mlir/lib/Dialect/Tensor/Transforms/IndependenceTransforms.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ using namespace mlir::tensor;
2121
static FailureOr<OpFoldResult> makeIndependent(OpBuilder &b, Location loc,
2222
OpFoldResult ofr,
2323
ValueRange independencies) {
24-
if (ofr.is<Attribute>())
24+
if (isa<Attribute>(ofr))
2525
return ofr;
26-
Value value = ofr.get<Value>();
26+
Value value = cast<Value>(ofr);
2727
AffineMap boundMap;
2828
ValueDimList mapOperands;
2929
if (failed(ValueBoundsConstraintSet::computeIndependentBound(
@@ -80,14 +80,14 @@ FailureOr<Value> tensor::buildIndependentOp(OpBuilder &b, tensor::PadOp padOp,
8080
for (int64_t i = 0, e = padOp.getResultType().getRank(); i < e; ++i) {
8181
// offset = ub(low_padding) - low_padding
8282
OpFoldResult prevLow = padOp.getMixedLowPad()[i];
83-
if (prevLow.is<Attribute>()) {
83+
if (isa<Attribute>(prevLow)) {
8484
offsets.push_back(b.getIndexAttr(0));
8585
} else {
8686
offsets.push_back(
8787
b.create<affine::AffineApplyOp>(
8888
loc, b.getAffineDimExpr(0) - b.getAffineDimExpr(1),
89-
std::initializer_list<Value>{newMixedLow[i].get<Value>(),
90-
prevLow.get<Value>()})
89+
std::initializer_list<Value>{cast<Value>(newMixedLow[i]),
90+
cast<Value>(prevLow)})
9191
.getResult());
9292
}
9393
// size = reified result size

0 commit comments

Comments
 (0)