@@ -83,7 +83,7 @@ static circle::TensorType GetCircleType(mlir::Type type, bool is_signed = true)
8383 {
8484 return circle::TensorType_FLOAT64;
8585 }
86- else if (auto itype = type. dyn_cast <mlir::IntegerType>())
86+ else if (auto itype = mlir:: dyn_cast<mlir::IntegerType>(type ))
8787 {
8888 switch (itype.getWidth ())
8989 {
@@ -313,7 +313,7 @@ std::optional<BufferOffset<circle::Buffer>> Translator::BuildBuffer(mlir::Value
313313 {
314314 // arith::ConstantOp have ElementAttr at this point due to validation of the
315315 // Circle module.
316- attr = cst. getValue (). cast <mlir::ElementsAttr>();
316+ attr = mlir:: cast<mlir::ElementsAttr>(cst. getValue () );
317317 }
318318 else if (auto cst = llvm::dyn_cast<mlir::Circle::ConstOp>(inst))
319319 {
@@ -325,7 +325,7 @@ std::optional<BufferOffset<circle::Buffer>> Translator::BuildBuffer(mlir::Value
325325 return empty_buffer_;
326326 }
327327
328- auto type = value. getType (). cast <mlir::TensorType>();
328+ auto type = mlir:: cast<mlir::TensorType>(value. getType () );
329329 circle::TensorType circle_element_type = GetCircleType (type.getElementType ());
330330
331331 BYTES data;
@@ -383,7 +383,7 @@ std::optional<BufferOffset<circle::Tensor>> Translator::BuildTensor(
383383 mlir::Value value, const std::string &name, unsigned buffer_idx,
384384 const std::optional<BufferOffset<circle::QuantizationParameters>> &quant_parameters)
385385{
386- auto type = value. getType (). cast <mlir::TensorType>();
386+ auto type = mlir:: cast<mlir::TensorType>(value. getType () );
387387
388388 // Circle requires tensor shape only for the inputs and constants.
389389 // However, we output all known shapes for better round-tripping
@@ -413,8 +413,9 @@ std::optional<BufferOffset<circle::Tensor>> Translator::BuildTensor(
413413 // Const op can have a result of dynamic shaped type (e.g. due to constant
414414 // folding), but we can still derive the shape of a constant tensor for
415415 // its attribute type.
416- auto tensor_attr = inst->getAttr (" value" ).cast <mlir::TypedAttr>();
417- llvm::ArrayRef<int64_t > shape_ref = tensor_attr.getType ().cast <mlir::TensorType>().getShape ();
416+ auto tensor_attr = mlir::cast<mlir::TypedAttr>(inst->getAttr (" value" ));
417+ llvm::ArrayRef<int64_t > shape_ref =
418+ mlir::cast<mlir::TensorType>(tensor_attr.getType ()).getShape ();
418419 if (mlir::failed (check_shape (shape_ref)))
419420 return std::nullopt ;
420421
@@ -495,7 +496,7 @@ BufferOffset<circle::Operator> Translator::BuildCustomOperator(Operation *inst,
495496 const std::vector<int32_t > &results)
496497{
497498 const std::string attrs =
498- op. getCustomOption (). cast <mlir::Circle::ConstBytesAttr>().getValue ().str ();
499+ mlir:: cast<mlir::Circle::ConstBytesAttr>(op. getCustomOption () ).getValue ().str ();
499500 std::vector<uint8_t > custom_option_vector (attrs.size ());
500501 memcpy (custom_option_vector.data (), attrs.data (), attrs.size ());
501502 auto opcode_index = GetOpcodeIndex (op.getCustomCode ().str (), circle::BuiltinOperator_CUSTOM);
@@ -616,7 +617,7 @@ void Translator::InitializeNamesFromAttribute(mlir::func::FuncOp fn, bool *has_i
616617 assert (inputNames.size () == fn.getArguments ().size ());
617618 for (const auto &it : llvm::enumerate (fn.getArguments ()))
618619 {
619- auto strattr = inputNames[it. index ()]. cast <mlir::StringAttr>();
620+ auto strattr = mlir:: cast<mlir::StringAttr>(inputNames[it. index ()] );
620621 name_mapper_.InitOpName (it.value (), strattr);
621622 }
622623 *has_input_attr = true ;
@@ -628,7 +629,7 @@ void Translator::InitializeNamesFromAttribute(mlir::func::FuncOp fn, bool *has_i
628629 assert (outputNames.size () == term->getOperands ().size ());
629630 for (const auto &it : llvm::enumerate (term->getOperands ()))
630631 {
631- auto strattr = outputNames[it. index ()]. cast <mlir::StringAttr>();
632+ auto strattr = mlir:: cast<mlir::StringAttr>(outputNames[it. index ()] );
632633 name_mapper_.InitOpName (it.value (), strattr);
633634 }
634635 *has_input_attr = true ;
@@ -651,7 +652,7 @@ Translator::BuildSubGraph(const std::string &name, mlir::Region *region, const i
651652 auto build_tensor_and_buffer = [&](mlir::Value value, const int subgraph_index,
652653 const std::string &tensor_name) {
653654 // NoneType represents optional and may be skipped here.
654- if (value. getType (). isa <mlir::NoneType>())
655+ if (mlir:: isa<mlir::NoneType>(value. getType () ))
655656 {
656657 return true ;
657658 }
@@ -754,7 +755,7 @@ Translator::BuildSubGraph(const std::string &name, mlir::Region *region, const i
754755 operands.reserve (real_inst->getNumOperands ());
755756 for (auto operand : real_inst->getOperands ())
756757 {
757- if (operand. getType (). isa <mlir::NoneType>())
758+ if (mlir:: isa<mlir::NoneType>(operand. getType () ))
758759 operands.push_back (kCircleOptionalTensor );
759760 else
760761 operands.push_back (tensor_index_map.lookup (operand));
0 commit comments