diff --git a/circle-mlir/circle-mlir/lib/dialect/src/CircleDialect.cpp b/circle-mlir/circle-mlir/lib/dialect/src/CircleDialect.cpp index e960ca3868a..9d3a34bd83a 100644 --- a/circle-mlir/circle-mlir/lib/dialect/src/CircleDialect.cpp +++ b/circle-mlir/circle-mlir/lib/dialect/src/CircleDialect.cpp @@ -73,7 +73,7 @@ ParseResult parseOneResultSameOperandTypeOp(OpAsmParser &parser, OperationState parser.parseOptionalAttrDict(result.attributes) || parser.parseColon() || parser.parseType(type)) return failure(); - auto fnType = type.dyn_cast(); + auto fnType = mlir::dyn_cast(type); if (!fnType) { parser.emitError(loc, "expected function type"); @@ -134,7 +134,7 @@ bool VerifyOperandsHaveSameShapesOrBroadcastableShape(Operation *op, ArrayRefgetOperand(index).getType().dyn_cast(); + ShapedType shaped_type = mlir::dyn_cast(op->getOperand(index).getType()); if (!shaped_type || !shaped_type.hasRank()) { // Marks that we have an unknown rank input. @@ -212,8 +212,8 @@ bool EqualsZero(Value value) return false; } - Type element_type = value.getType().cast().getElementType(); - if (element_type.isa()) + Type element_type = mlir::cast(value.getType()).getElementType(); + if (mlir::isa(element_type)) { return constant.getSplatValue().isZero(); } @@ -315,7 +315,7 @@ bool ExtractConstantValues(mlir::Value &input, std::vector &values) void CIRDialect::printType(Type type, DialectAsmPrinter &os) const { - if (type.isa()) + if (mlir::isa(type)) { os << "control"; return; @@ -357,7 +357,7 @@ namespace // Returns true if it is a shaped type of f32 elements. inline bool IsF32ShapedType(Type t) { - if (auto shaped_type = t.dyn_cast_or_null()) + if (auto shaped_type = mlir::dyn_cast_or_null(t)) { return shaped_type.getElementType().isF32(); } @@ -367,7 +367,7 @@ inline bool IsF32ShapedType(Type t) // Returns true if it is a shaped type of i64 elements. inline bool IsI64ShapedType(Type t) { - if (auto shaped_type = t.dyn_cast_or_null()) + if (auto shaped_type = mlir::dyn_cast_or_null(t)) { return shaped_type.getElementType().isInteger(64); } @@ -391,11 +391,11 @@ namespace bool InputOutputHasSameShape(mlir::Type input_type, mlir::Type output_type) { - auto input_shaped_type = input_type.dyn_cast_or_null(); + auto input_shaped_type = mlir::dyn_cast_or_null(input_type); if (!input_shaped_type || !input_shaped_type.hasStaticShape()) return false; - auto output_shaped_type = output_type.dyn_cast_or_null(); + auto output_shaped_type = mlir::dyn_cast_or_null(output_type); if (!output_shaped_type || !output_shaped_type.hasStaticShape()) return false; @@ -500,13 +500,13 @@ Operation *CIRDialect::materializeConstant(OpBuilder &builder, Attribute value, { // If this is a constant bytes attribute or the result type doesn't match the // attribute type, then generate a tfl.pseudo_const. - if (value.isa() || - (value.isa() && value.cast().getType() != type)) - return builder.create(loc, type, value.cast()); + if (mlir::isa(value) || + (mlir::isa(value) && mlir::cast(value).getType() != type)) + return builder.create(loc, type, mlir::cast(value)); if (ConstOp::isBuildableWith(value, type)) - return builder.create(loc, type, value.cast()); + return builder.create(loc, type, mlir::cast(value)); if (NoValueOp::isBuildableWith(value, type)) - return builder.create(loc, type, value.cast()); + return builder.create(loc, type, mlir::cast(value)); return nullptr; } diff --git a/circle-mlir/circle-mlir/lib/dialect/src/ConstFold.inc.cpp b/circle-mlir/circle-mlir/lib/dialect/src/ConstFold.inc.cpp index 722d8934133..cc63d9c9a53 100644 --- a/circle-mlir/circle-mlir/lib/dialect/src/ConstFold.inc.cpp +++ b/circle-mlir/circle-mlir/lib/dialect/src/ConstFold.inc.cpp @@ -150,7 +150,7 @@ Attribute ConstFoldBinaryOp(Type result_type, Attribute operand1, Attribute oper operand2.dyn_cast_or_null()) { return ConstFoldBinaryOpDenseDense( - result_type, operand1.cast(), operand2.cast(), + result_type, mlir::cast(operand1), mlir::cast(operand2), calculate); } @@ -169,13 +169,13 @@ Attribute ConstFoldBinaryOp(Type result_type, ArrayRef operands, { // Note: All types are wrapped in tensor types in Circle. E.g., f32 is // represented as tensor. So we are only handling tensor types here. - auto type = result_type.dyn_cast(); + auto type = mlir::dyn_cast(result_type); if (!type) return {}; auto elemType = type.getElementType(); - if (elemType.isa()) + if (mlir::isa(elemType)) return ConstFoldBinaryOp(result_type, operands[0], operands[1], float_calculate); if (elemType.isSignlessInteger()) @@ -191,12 +191,12 @@ Attribute ConstFoldUnaryOp(Type result_type, Attribute operand, llvm::function_ref calculate) { assert(IsF32ShapedType(result_type)); - auto result_shape_type = result_type.cast(); + auto result_shape_type = mlir::cast(result_type); if (!result_shape_type.hasStaticShape()) return {}; - if (auto dense_elements = operand.dyn_cast_or_null()) + if (auto dense_elements = mlir::dyn_cast_or_null(operand)) { SmallVector new_values; const int num_elements = result_shape_type.getNumElements(); diff --git a/circle-mlir/circle-mlir/lib/dialect/src/NameUtils.cpp b/circle-mlir/circle-mlir/lib/dialect/src/NameUtils.cpp index 0d1a54fc259..f6150ae1b06 100644 --- a/circle-mlir/circle-mlir/lib/dialect/src/NameUtils.cpp +++ b/circle-mlir/circle-mlir/lib/dialect/src/NameUtils.cpp @@ -40,7 +40,7 @@ std::string GetNameFromLoc(Location loc) { Location curr_loc = locs.pop_back_val(); - if (auto name_loc = curr_loc.dyn_cast()) + if (auto name_loc = mlir::dyn_cast(curr_loc)) { // Add name in NameLoc. For NameLoc we also account for names due to ops // in functions where the op's name is first. @@ -54,13 +54,13 @@ std::string GetNameFromLoc(Location loc) } continue; } - else if (auto call_loc = curr_loc.dyn_cast()) + else if (auto call_loc = mlir::dyn_cast(curr_loc)) { // Use location of the Callee to generate the name. locs.push_back(call_loc.getCallee()); continue; } - else if (auto fused_loc = curr_loc.dyn_cast()) + else if (auto fused_loc = mlir::dyn_cast(curr_loc)) { // Push all locations in FusedLoc in reverse order, so locations are // visited based on order in FusedLoc. diff --git a/circle-mlir/circle-mlir/lib/dialect/src/ops/CastOp.h b/circle-mlir/circle-mlir/lib/dialect/src/ops/CastOp.h index 2e334c748f8..a6fa37bffb8 100644 --- a/circle-mlir/circle-mlir/lib/dialect/src/ops/CastOp.h +++ b/circle-mlir/circle-mlir/lib/dialect/src/ops/CastOp.h @@ -41,15 +41,15 @@ OpFoldResult CastOp::fold(FoldAdaptor adaptor) } // For now, only supports cast for the integer/float input type. - auto elements_attr = operands[0].dyn_cast_or_null(); + auto elements_attr = mlir::dyn_cast_or_null(operands[0]); if (!elements_attr) { return nullptr; } - auto result_element_type = getType().cast().getElementType(); - auto operand_element_type = getInput().getType().cast().getElementType(); - auto operand_int_type = operand_element_type.dyn_cast(); + auto result_element_type = mlir::cast(getType()).getElementType(); + auto operand_element_type = mlir::cast(getInput().getType()).getElementType(); + auto operand_int_type = mlir::dyn_cast(operand_element_type); if (!result_element_type || !operand_element_type) { return nullptr; @@ -57,7 +57,7 @@ OpFoldResult CastOp::fold(FoldAdaptor adaptor) if (mlir::isa(result_element_type)) { - auto result_int_type = result_element_type.dyn_cast(); + auto result_int_type = mlir::dyn_cast(result_element_type); const int output_bitwidth = result_int_type.getWidth(); // check for INT64 <--> INT32 if (operand_int_type) @@ -97,7 +97,7 @@ OpFoldResult CastOp::fold(FoldAdaptor adaptor) else if (mlir::isa(result_element_type)) { // Refer to https://llvm.org/doxygen/classllvm_1_1APFloat.html - auto result_float_type = result_element_type.dyn_cast(); + auto result_float_type = mlir::dyn_cast(result_element_type); // To get the correct semantics of floating point from the type of this CastOp const llvm::fltSemantics &semantics = result_float_type.getFloatSemantics(); auto cast = [&](const llvm::APInt &value) { diff --git a/circle-mlir/circle-mlir/lib/dialect/src/ops/ConcatenationOp.h b/circle-mlir/circle-mlir/lib/dialect/src/ops/ConcatenationOp.h index 4892dfb1b85..939d28c969b 100644 --- a/circle-mlir/circle-mlir/lib/dialect/src/ops/ConcatenationOp.h +++ b/circle-mlir/circle-mlir/lib/dialect/src/ops/ConcatenationOp.h @@ -150,7 +150,7 @@ bool IsConcatenationOpConstFoldable(ConcatenationOp op, ArrayRef oper return false; return llvm::all_of( - operands, [](Attribute operand) { return operand && operand.isa(); }); + operands, [](Attribute operand) { return operand && mlir::isa(operand); }); } DenseElementsAttr ConstFoldConcatenateOpDense(ArrayRef operands, diff --git a/circle-mlir/circle-mlir/lib/dialect/src/ops/ConstOp.h b/circle-mlir/circle-mlir/lib/dialect/src/ops/ConstOp.h index 498b4398138..8c21327a51b 100644 --- a/circle-mlir/circle-mlir/lib/dialect/src/ops/ConstOp.h +++ b/circle-mlir/circle-mlir/lib/dialect/src/ops/ConstOp.h @@ -83,10 +83,10 @@ bool ConstOp::isBuildableWith(Attribute value, Type type) if (!typedAttr || typedAttr.getType() != type) return false; // Integer values must be signless. - if (type.isa() && !type.cast().isSignless()) + if (mlir::isa(type) && !mlir::cast(type).isSignless()) return false; // Integer, float, and element attributes are buildable. - return value.isa(); + return mlir::isa(value); } } // namespace Circle diff --git a/circle-mlir/circle-mlir/lib/dialect/src/ops/FullyConnectedOp.h b/circle-mlir/circle-mlir/lib/dialect/src/ops/FullyConnectedOp.h index 9017e541959..16e9d83b698 100644 --- a/circle-mlir/circle-mlir/lib/dialect/src/ops/FullyConnectedOp.h +++ b/circle-mlir/circle-mlir/lib/dialect/src/ops/FullyConnectedOp.h @@ -96,7 +96,7 @@ LogicalResult FullyConnectedOp::fold(FoldAdaptor adaptor, SmallVectorImpl()); + const bool has_bias = !(!getBias() || mlir::isa(getBias().getType())); // Get the tensors. DenseElementsAttr input_tensor, weights_tensor, bias_tensor; diff --git a/circle-mlir/circle-mlir/lib/dialect/src/ops/NoValueOp.h b/circle-mlir/circle-mlir/lib/dialect/src/ops/NoValueOp.h index 5e6c459a775..4280428a1bb 100644 --- a/circle-mlir/circle-mlir/lib/dialect/src/ops/NoValueOp.h +++ b/circle-mlir/circle-mlir/lib/dialect/src/ops/NoValueOp.h @@ -35,7 +35,7 @@ OpFoldResult NoValueOp::fold(FoldAdaptor adaptor) { return getValueAttr(); } bool NoValueOp::isBuildableWith(Attribute value, Type type) { - return value.isa() && type.isa(); + return mlir::isa(value) && mlir::isa(type); } } // namespace Circle diff --git a/circle-mlir/circle-mlir/lib/export/src/CircleExport.cpp b/circle-mlir/circle-mlir/lib/export/src/CircleExport.cpp index 7f2fef02d1c..77e0075d918 100644 --- a/circle-mlir/circle-mlir/lib/export/src/CircleExport.cpp +++ b/circle-mlir/circle-mlir/lib/export/src/CircleExport.cpp @@ -83,7 +83,7 @@ static circle::TensorType GetCircleType(mlir::Type type, bool is_signed = true) { return circle::TensorType_FLOAT64; } - else if (auto itype = type.dyn_cast()) + else if (auto itype = mlir::dyn_cast(type)) { switch (itype.getWidth()) { @@ -313,7 +313,7 @@ std::optional> Translator::BuildBuffer(mlir::Value { // arith::ConstantOp have ElementAttr at this point due to validation of the // Circle module. - attr = cst.getValue().cast(); + attr = mlir::cast(cst.getValue()); } else if (auto cst = llvm::dyn_cast(inst)) { @@ -325,7 +325,7 @@ std::optional> Translator::BuildBuffer(mlir::Value return empty_buffer_; } - auto type = value.getType().cast(); + auto type = mlir::cast(value.getType()); circle::TensorType circle_element_type = GetCircleType(type.getElementType()); BYTES data; @@ -383,7 +383,7 @@ std::optional> Translator::BuildTensor( mlir::Value value, const std::string &name, unsigned buffer_idx, const std::optional> &quant_parameters) { - auto type = value.getType().cast(); + auto type = mlir::cast(value.getType()); // Circle requires tensor shape only for the inputs and constants. // However, we output all known shapes for better round-tripping @@ -413,8 +413,9 @@ std::optional> Translator::BuildTensor( // Const op can have a result of dynamic shaped type (e.g. due to constant // folding), but we can still derive the shape of a constant tensor for // its attribute type. - auto tensor_attr = inst->getAttr("value").cast(); - llvm::ArrayRef shape_ref = tensor_attr.getType().cast().getShape(); + auto tensor_attr = mlir::cast(inst->getAttr("value")); + llvm::ArrayRef shape_ref = + mlir::cast(tensor_attr.getType()).getShape(); if (mlir::failed(check_shape(shape_ref))) return std::nullopt; @@ -495,7 +496,7 @@ BufferOffset Translator::BuildCustomOperator(Operation *inst, const std::vector &results) { const std::string attrs = - op.getCustomOption().cast().getValue().str(); + mlir::cast(op.getCustomOption()).getValue().str(); std::vector custom_option_vector(attrs.size()); memcpy(custom_option_vector.data(), attrs.data(), attrs.size()); auto opcode_index = GetOpcodeIndex(op.getCustomCode().str(), circle::BuiltinOperator_CUSTOM); @@ -616,7 +617,7 @@ void Translator::InitializeNamesFromAttribute(mlir::func::FuncOp fn, bool *has_i assert(inputNames.size() == fn.getArguments().size()); for (const auto &it : llvm::enumerate(fn.getArguments())) { - auto strattr = inputNames[it.index()].cast(); + auto strattr = mlir::cast(inputNames[it.index()]); name_mapper_.InitOpName(it.value(), strattr); } *has_input_attr = true; @@ -628,7 +629,7 @@ void Translator::InitializeNamesFromAttribute(mlir::func::FuncOp fn, bool *has_i assert(outputNames.size() == term->getOperands().size()); for (const auto &it : llvm::enumerate(term->getOperands())) { - auto strattr = outputNames[it.index()].cast(); + auto strattr = mlir::cast(outputNames[it.index()]); name_mapper_.InitOpName(it.value(), strattr); } *has_input_attr = true; @@ -651,7 +652,7 @@ Translator::BuildSubGraph(const std::string &name, mlir::Region *region, const i auto build_tensor_and_buffer = [&](mlir::Value value, const int subgraph_index, const std::string &tensor_name) { // NoneType represents optional and may be skipped here. - if (value.getType().isa()) + if (mlir::isa(value.getType())) { return true; } @@ -754,7 +755,7 @@ Translator::BuildSubGraph(const std::string &name, mlir::Region *region, const i operands.reserve(real_inst->getNumOperands()); for (auto operand : real_inst->getOperands()) { - if (operand.getType().isa()) + if (mlir::isa(operand.getType())) operands.push_back(kCircleOptionalTensor); else operands.push_back(tensor_index_map.lookup(operand)); diff --git a/circle-mlir/circle-mlir/lib/export/src/OpOrArgNameMapper.cpp b/circle-mlir/circle-mlir/lib/export/src/OpOrArgNameMapper.cpp index e33471b2105..f187232acdc 100644 --- a/circle-mlir/circle-mlir/lib/export/src/OpOrArgNameMapper.cpp +++ b/circle-mlir/circle-mlir/lib/export/src/OpOrArgNameMapper.cpp @@ -120,7 +120,7 @@ bool OpOrArgNameMapper::IsUnique(llvm::StringRef name) { return true; } std::string OpOrArgLocNameMapper::GetName(OpOrVal op_or_val) { - if (auto *op = op_or_val.dyn_cast()) + if (auto *op = mlir::dyn_cast(op_or_val)) { // NOTE stop for debug version to find out if there is any Op for this case assert(false); @@ -131,14 +131,14 @@ std::string OpOrArgLocNameMapper::GetName(OpOrVal op_or_val) // generated using the op type. return std::string(op->getName().getStringRef()); } - auto val = op_or_val.dyn_cast(); + auto val = mlir::dyn_cast(op_or_val); auto name_from_loc = mlir::GetNameFromLoc(val.getLoc()); if (!name_from_loc.empty()) return name_from_loc; // If the location is none of the expected types, then simply use name // generated using the op type. Follow TF convention and append the result // index unless 0. - if (auto result = val.dyn_cast()) + if (auto result = mlir::dyn_cast(val)) { auto name_str = result.getOwner()->getName().getStringRef().str(); auto value_op = val.getDefiningOp(); @@ -154,7 +154,7 @@ std::string OpOrArgLocNameMapper::GetName(OpOrVal op_or_val) return std::string(name_str); } // Use the ASM syntax for BlockArgument - if (auto arg = val.dyn_cast()) + if (auto arg = mlir::dyn_cast(val)) { return "arg" + std::to_string(arg.getArgNumber()); } diff --git a/circle-mlir/circle-mlir/lib/import/src/CircleImport.cpp b/circle-mlir/circle-mlir/lib/import/src/CircleImport.cpp index b40af2fa5e1..9e6de149733 100644 --- a/circle-mlir/circle-mlir/lib/import/src/CircleImport.cpp +++ b/circle-mlir/circle-mlir/lib/import/src/CircleImport.cpp @@ -273,11 +273,11 @@ std::optional ConvertIntBuffer(mlir::RankedTensorType shaped { mlir::Type elem_type = shaped_type.getElementType(); unsigned bit_width; - if (auto itype = elem_type.dyn_cast()) + if (auto itype = mlir::dyn_cast(elem_type)) { bit_width = itype.getWidth(); } - else if (auto qtype = elem_type.dyn_cast()) + else if (auto qtype = mlir::dyn_cast(elem_type)) { llvm::errs() << "NYI ConvertIntBuffer QuantizedType\n"; return {}; @@ -353,7 +353,7 @@ std::optional BuildConstOp(const circle::TensorT &tensor, /*is_constant=*/true, /*is_intermediate=*/false, /*get_storage=*/true)); - auto shaped_type = type.dyn_cast(); + auto shaped_type = mlir::dyn_cast(type); if (!shaped_type) { llvm::errs() << "Constant doesn't have a shape\n"; @@ -369,11 +369,11 @@ std::optional BuildConstOp(const circle::TensorT &tensor, } auto elem_type = shaped_type.getElementType(); - if (auto float_type = elem_type.dyn_cast()) + if (auto float_type = mlir::dyn_cast(elem_type)) { ASSIGN_OR_RETURN(value, ConvertFloatBuffer(shaped_type, buffer)); } - else if (elem_type.isa()) + else if (mlir::isa(elem_type)) { ASSIGN_OR_RETURN(value, ConvertIntBuffer(shaped_type, buffer)); } @@ -487,7 +487,7 @@ ConvertOp(const circle::OperatorT &op, const std::vector &vals_map, mlir::DenseIntElementsAttr shape_attr; if (matchPattern(op_state.operands[1], m_Constant(&shape_attr))) { - auto shape_ty = op_state.operands[1].getType().dyn_cast(); + auto shape_ty = mlir::dyn_cast(op_state.operands[1].getType()); if (shape_ty != nullptr && shape_ty.hasRank() && shape_ty.getRank() > 1) { llvm::SmallVector shape; diff --git a/circle-mlir/circle-mlir/lib/pass/src/opt/ConvertDivErfToMulErf.h b/circle-mlir/circle-mlir/lib/pass/src/opt/ConvertDivErfToMulErf.h index 67c3192b713..4da4fb5ec34 100644 --- a/circle-mlir/circle-mlir/lib/pass/src/opt/ConvertDivErfToMulErf.h +++ b/circle-mlir/circle-mlir/lib/pass/src/opt/ConvertDivErfToMulErf.h @@ -49,7 +49,7 @@ struct ConvertDivErfToMulErf : public OpRewritePattern return mlir::failure(); auto const_op = cast(is_const); - auto const_type = const_op.getType().cast(); + auto const_type = mlir::cast(const_op.getType()); if (not const_type.getElementType().isF32()) return mlir::failure(); diff --git a/circle-mlir/circle-mlir/lib/pass/src/opt/ConvertMirrorPadPad32.h b/circle-mlir/circle-mlir/lib/pass/src/opt/ConvertMirrorPadPad32.h index dccf83e5298..d91727c8580 100644 --- a/circle-mlir/circle-mlir/lib/pass/src/opt/ConvertMirrorPadPad32.h +++ b/circle-mlir/circle-mlir/lib/pass/src/opt/ConvertMirrorPadPad32.h @@ -41,7 +41,7 @@ struct ConvertMirrorPadPad32 : public OpRewritePattern return mlir::failure(); auto const_op = cast(is_const); - auto const_type = const_op.getType().cast(); + auto const_type = mlir::cast(const_op.getType()); if (const_type.getElementType().isInteger(32)) return mlir::failure(); assert(const_type.getElementType().isInteger(64)); @@ -52,7 +52,7 @@ struct ConvertMirrorPadPad32 : public OpRewritePattern return mlir::failure(); auto opLoc = const_op->getLoc(); - auto stype = const_op.getType().dyn_cast_or_null(); + auto stype = mlir::dyn_cast_or_null(const_op.getType()); auto si32stype = RankedTensorType::get(stype.getShape(), rewriter.getI32Type()); auto intattr = DenseIntElementsAttr::get(si32stype, values); mlir::Value shape32 = rewriter.create(opLoc, intattr); diff --git a/circle-mlir/circle-mlir/lib/pass/src/opt/ConvertReshapeShape32.h b/circle-mlir/circle-mlir/lib/pass/src/opt/ConvertReshapeShape32.h index f9adf1060a8..52fd5165443 100644 --- a/circle-mlir/circle-mlir/lib/pass/src/opt/ConvertReshapeShape32.h +++ b/circle-mlir/circle-mlir/lib/pass/src/opt/ConvertReshapeShape32.h @@ -41,7 +41,7 @@ struct ConvertReshapeShape32 : public OpRewritePattern return mlir::failure(); auto const_op = cast(is_const); - auto const_type = const_op.getType().cast(); + auto const_type = mlir::cast(const_op.getType()); if (const_type.getElementType().isInteger(32)) return mlir::failure(); assert(const_type.getElementType().isInteger(64)); @@ -52,7 +52,8 @@ struct ConvertReshapeShape32 : public OpRewritePattern return mlir::failure(); mlir::Location opLoc = const_op->getLoc(); - mlir::RankedTensorType stype = const_op.getType().dyn_cast_or_null(); + mlir::RankedTensorType stype = + mlir::dyn_cast_or_null(const_op.getType()); mlir::Type i32 = rewriter.getI32Type(); mlir::RankedTensorType si32stype = RankedTensorType::get(stype.getShape(), i32); mlir::Value shape32 = diff --git a/circle-mlir/circle-mlir/lib/pass/src/opt/ConvertResizeNearestSize32.h b/circle-mlir/circle-mlir/lib/pass/src/opt/ConvertResizeNearestSize32.h index 2c991f0211c..1ee40cff644 100644 --- a/circle-mlir/circle-mlir/lib/pass/src/opt/ConvertResizeNearestSize32.h +++ b/circle-mlir/circle-mlir/lib/pass/src/opt/ConvertResizeNearestSize32.h @@ -44,7 +44,7 @@ struct ConvertResizeNearestSize32 : public OpRewritePattern(is_const); - auto const_type = const_op.getType().cast(); + auto const_type = mlir::cast(const_op.getType()); mlir::Value resize_size = const_op; // ExtractConstantValues requries mlir::Value std::vector values; if (!ExtractConstantValues(resize_size, values)) diff --git a/circle-mlir/circle-mlir/lib/pass/src/opt/ConvertSqrtDivToRsqrt.h b/circle-mlir/circle-mlir/lib/pass/src/opt/ConvertSqrtDivToRsqrt.h index d9388298678..7c17b468484 100644 --- a/circle-mlir/circle-mlir/lib/pass/src/opt/ConvertSqrtDivToRsqrt.h +++ b/circle-mlir/circle-mlir/lib/pass/src/opt/ConvertSqrtDivToRsqrt.h @@ -43,7 +43,7 @@ struct ConvertSqrtDivToRsqrt : public OpRewritePattern return mlir::failure(); auto const_op = cast(is_const); - auto const_type = const_op.getType().cast(); + auto const_type = mlir::cast(const_op.getType()); if (not const_type.getElementType().isF32()) return mlir::failure(); diff --git a/circle-mlir/circle-mlir/lib/pass/src/opt/FuseFullyConnectedAdd.h b/circle-mlir/circle-mlir/lib/pass/src/opt/FuseFullyConnectedAdd.h index b56dc273248..e4c0cfedb7a 100644 --- a/circle-mlir/circle-mlir/lib/pass/src/opt/FuseFullyConnectedAdd.h +++ b/circle-mlir/circle-mlir/lib/pass/src/opt/FuseFullyConnectedAdd.h @@ -54,7 +54,7 @@ struct FuseFullyConnectedAdd : public OpRewritePattern // NOTE we can add existing bias values with values from ADD op // TODO implement when fc_bias is valid constant auto fc_bias = fc_op.getBias(); - if (!fc_bias.getType().isa()) + if (!mlir::isa(fc_bias.getType())) return mlir::failure(); // skip if FC activation is NOT none if (fc_op.getFusedActivationFunction() != ACT_NONE) @@ -62,7 +62,7 @@ struct FuseFullyConnectedAdd : public OpRewritePattern // check constant is scalar or 1D bool is_const_scalar = false; - auto const_type = const_op.getType().cast(); + auto const_type = mlir::cast(const_op.getType()); if (const_type.getRank() == 0) is_const_scalar = true; else if (const_type.getRank() != 1) @@ -98,7 +98,7 @@ struct FuseFullyConnectedAdd : public OpRewritePattern if (!ExtractConstantValues(cop, bias_values)) return mlir::failure(); - auto fc_type = (*fc_op.getOutput().begin()).getType().cast(); + auto fc_type = mlir::cast((*fc_op.getOutput().begin()).getType()); auto fc_shape = fc_type.getShape(); auto fc_rank = fc_type.getRank(); int64_t num_ele = fc_shape[fc_rank - 1]; diff --git a/circle-mlir/circle-mlir/lib/utils/src/ConvertType.cpp b/circle-mlir/circle-mlir/lib/utils/src/ConvertType.cpp index e5ffee0af07..bad86db469f 100644 --- a/circle-mlir/circle-mlir/lib/utils/src/ConvertType.cpp +++ b/circle-mlir/circle-mlir/lib/utils/src/ConvertType.cpp @@ -50,7 +50,7 @@ circle::TensorType ConvertTypeToTensorType(mlir::Type type) return circle::TensorType_STRING; } */ - else if (auto complex_type = type.dyn_cast()) + else if (auto complex_type = mlir::dyn_cast(type)) { if (complex_type.getElementType().isF32()) { @@ -62,7 +62,7 @@ circle::TensorType ConvertTypeToTensorType(mlir::Type type) } throw std::runtime_error("invalid complex Type in conversion"); } - else if (auto itype = type.dyn_cast()) + else if (auto itype = mlir::dyn_cast(type)) { switch (itype.getWidth()) { diff --git a/circle-mlir/circle-mlir/lib/utils/src/FlatbufferOperator.cpp b/circle-mlir/circle-mlir/lib/utils/src/FlatbufferOperator.cpp index 1325ef2a89d..5cc738b620e 100644 --- a/circle-mlir/circle-mlir/lib/utils/src/FlatbufferOperator.cpp +++ b/circle-mlir/circle-mlir/lib/utils/src/FlatbufferOperator.cpp @@ -110,7 +110,7 @@ ConvertI64ArrayAttrForOptionWriter(mlir::ArrayAttr attrArray, intVec.reserve(attrArray.getValue().size()); for (auto attr : attrArray.getValue()) { - intVec.push_back(attr.cast().getInt()); + intVec.push_back(mlir::cast(attr).getInt()); } return builder->CreateVector(intVec); }