From db9772cdeb536568105de0af6bda2cabea27a3fa Mon Sep 17 00:00:00 2001 From: Marius Brehler Date: Fri, 19 Apr 2024 15:58:15 +0000 Subject: [PATCH] Replace member calls with free function calls Switches member calls to `isa/dyn_cast/cast` to free function calls since calling member variants is deprecated, see https://mlir.llvm.org/deprecation/. --- .../StablehloRegionOpsToEmitC.cpp | 2 +- lib/Conversion/TensorToEmitC/TensorToEmitC.cpp | 2 +- lib/Conversion/TosaToEmitC/TosaToEmitC.cpp | 16 ++++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/Conversion/StablehloToEmitC/StablehloRegionOpsToEmitC.cpp b/lib/Conversion/StablehloToEmitC/StablehloRegionOpsToEmitC.cpp index 55185b2b..f07901ef 100644 --- a/lib/Conversion/StablehloToEmitC/StablehloRegionOpsToEmitC.cpp +++ b/lib/Conversion/StablehloToEmitC/StablehloRegionOpsToEmitC.cpp @@ -191,7 +191,7 @@ struct ConvertStablehloRegionOpsToEmitCPass SmallVector arguments = indexSequence(operands.size(), ctx); - size_t dim = op.getResult(0).getType().cast().getRank(); + size_t dim = cast(op.getResult(0).getType()).getRank(); arguments.push_back(builder.getI64TensorAttr(op.getWindowDimensions())); arguments.push_back(builder.getI64TensorAttr( op.getWindowStrides().value_or(SmallVector(dim, 1)))); diff --git a/lib/Conversion/TensorToEmitC/TensorToEmitC.cpp b/lib/Conversion/TensorToEmitC/TensorToEmitC.cpp index fec2b3a7..fdb54e7e 100644 --- a/lib/Conversion/TensorToEmitC/TensorToEmitC.cpp +++ b/lib/Conversion/TensorToEmitC/TensorToEmitC.cpp @@ -40,7 +40,7 @@ class ExtractOpConversion : public OpConversionPattern { StringAttr callee = rewriter.getStringAttr("emitc::tensor::extract"); Type elementType = indexCastOp.getType(); - if (auto tensorType = elementType.dyn_cast()) { + if (auto tensorType = dyn_cast(elementType)) { elementType = tensorType.getElementType(); } diff --git a/lib/Conversion/TosaToEmitC/TosaToEmitC.cpp b/lib/Conversion/TosaToEmitC/TosaToEmitC.cpp index a5fc5e0d..8cd30a4c 100644 --- a/lib/Conversion/TosaToEmitC/TosaToEmitC.cpp +++ b/lib/Conversion/TosaToEmitC/TosaToEmitC.cpp @@ -261,14 +261,14 @@ class ClampOpConversion : public OpConversionPattern { // the min/max attribute type match the operand's element type and it's bit // width. auto elementType = - adaptor.getInput().getType().cast().getElementType(); - if (elementType.isa()) { + cast(adaptor.getInput().getType()).getElementType(); + if (isa(elementType)) { // Change the {min,max}_int type to the element type of the operand. auto minInt = clampOp.getMinInt(); auto maxInt = clampOp.getMaxInt(); arguments.push_back(IntegerAttr::get(elementType, minInt)); arguments.push_back(IntegerAttr::get(elementType, maxInt)); - } else if (elementType.isa()) { + } else if (isa(elementType)) { // Change the {min,max}_fp type to the element type of the operand. auto minFp = clampOp.getMinFpAttr().getValueAsDouble(); auto maxFp = clampOp.getMaxFpAttr().getValueAsDouble(); @@ -412,8 +412,8 @@ createBroadcastOpIfNeeded(SrcOp &srcOp, Adaptor adaptor, StringAttr broadcastCallee = rewriter.getStringAttr(broadcastFuncName); Value output = srcOp.getResult(); - auto opOutputShape = output.getType().cast().getShape(); - auto opOutputRank = output.getType().cast().getRank(); + auto opOutputShape = cast(output.getType()).getShape(); + auto opOutputRank = cast(output.getType()).getRank(); SmallVector broadcastedOperands; for (auto operand : adaptor.getOperands()) { @@ -652,7 +652,7 @@ class ReduceOpConversion : public OpConversionPattern { // not keep reduced dimensions. Value output = reduceOp.getResult(); RankedTensorType reducedOutputType = - output.getType().cast(); + cast(output.getType()); SmallVector newReducedOutputShape; @@ -678,7 +678,7 @@ class ReduceOpConversion : public OpConversionPattern { // Create tosa.reshape op. SmallVector newShapeAttr_; - for (auto dim : output.getType().cast().getShape()) { + for (auto dim : cast(output.getType()).getShape()) { newShapeAttr_.push_back(dim); }; @@ -782,7 +782,7 @@ class TileOpConversion : public OpConversionPattern { ConversionPatternRewriter &rewriter) const override { StringAttr callee = rewriter.getStringAttr("emitc::tosa::tile"); auto inputShape = - adaptor.getInput1().getType().cast().getShape(); + cast(adaptor.getInput1().getType()).getShape(); for (int64_t i = 0, e = inputShape.size(); i < e; i++) { if (inputShape[i] > std::numeric_limits::max()) { return tileOp.emitError("tosa.tile with dimensions larger than the "