From 8eb1deb682e3d1ec52d55d65a38e585a30cd4598 Mon Sep 17 00:00:00 2001 From: Tomasz Jankowski Date: Mon, 13 Jan 2025 18:33:23 +0100 Subject: [PATCH] [RTTI] Replace std::dynamic_(pointer)?_casts with ov::as_type_(ptr)? - CPU (#28411) ### Details: - Replaced `std::dynamic_cast` and `std::dynamic_pointed_cast` with `ov::as_type` or `ov::as_type_ptr` respectively in src/plugins (CPU, Template, Auto, Hetero) ### Tickets: - CVS-160243 --------- Signed-off-by: Tomasz Jankowski --- src/plugins/auto/src/plugin.cpp | 12 ++++---- src/plugins/hetero/src/subgraph_collector.cpp | 4 +-- .../plugin/aarch64/jit_eltwise_emitters.cpp | 6 ++-- .../snippets/aarch64/cpu_generator.cpp | 6 ++-- .../snippets/aarch64/jit_memory_emitters.cpp | 4 +-- .../emitters/snippets/x64/cpu_generator.cpp | 9 +++--- src/plugins/intel_cpu/src/graph.cpp | 4 +-- .../intel_cpu/src/nodes/adaptive_pooling.cpp | 4 +-- .../intel_cpu/src/nodes/batch_to_space.cpp | 2 +- src/plugins/intel_cpu/src/nodes/bin_conv.cpp | 4 +-- src/plugins/intel_cpu/src/nodes/bucketize.cpp | 4 +-- .../src/nodes/causal_mask_preprocess.cpp | 4 +-- src/plugins/intel_cpu/src/nodes/convert.cpp | 2 +- src/plugins/intel_cpu/src/nodes/cum_sum.cpp | 4 +-- src/plugins/intel_cpu/src/nodes/deconv.cpp | 8 ++--- src/plugins/intel_cpu/src/nodes/def_conv.cpp | 4 +-- ...erimental_detectron_priorgridgenerator.cpp | 5 ++-- ...rimental_detectron_roifeatureextractor.cpp | 5 ++-- .../nodes/experimental_detectron_topkrois.cpp | 4 +-- .../intel_cpu/src/nodes/fake_quantize.cpp | 18 +++++------ src/plugins/intel_cpu/src/nodes/gather.cpp | 2 +- src/plugins/intel_cpu/src/nodes/grn.cpp | 4 +-- .../intel_cpu/src/nodes/interaction.cpp | 4 +-- .../intel_cpu/src/nodes/interpolate.cpp | 23 +++++++------- src/plugins/intel_cpu/src/nodes/llm_mlp.cpp | 4 +-- .../intel_cpu/src/nodes/log_softmax.cpp | 4 +-- src/plugins/intel_cpu/src/nodes/matmul.cpp | 4 +-- .../intel_cpu/src/nodes/matrix_nms.cpp | 4 +-- src/plugins/intel_cpu/src/nodes/mha.cpp | 4 +-- .../intel_cpu/src/nodes/multiclass_nms.cpp | 2 +- src/plugins/intel_cpu/src/nodes/one_hot.cpp | 14 ++++----- src/plugins/intel_cpu/src/nodes/priorbox.cpp | 4 +-- .../src/nodes/priorbox_clustered.cpp | 4 +-- src/plugins/intel_cpu/src/nodes/proposal.cpp | 4 +-- .../intel_cpu/src/nodes/psroi_pooling.cpp | 8 ++--- src/plugins/intel_cpu/src/nodes/qkv_proj.cpp | 4 +-- src/plugins/intel_cpu/src/nodes/reduce.cpp | 30 +++++++++---------- .../intel_cpu/src/nodes/region_yolo.cpp | 4 +-- .../intel_cpu/src/nodes/reorg_yolo.cpp | 4 +-- src/plugins/intel_cpu/src/nodes/reshape.cpp | 11 ++++--- .../intel_cpu/src/nodes/reverse_sequence.cpp | 4 +-- src/plugins/intel_cpu/src/nodes/rms_norm.cpp | 4 +-- src/plugins/intel_cpu/src/nodes/rnn.cpp | 2 +- src/plugins/intel_cpu/src/nodes/roll.cpp | 2 +- src/plugins/intel_cpu/src/nodes/rope.cpp | 4 +-- .../intel_cpu/src/nodes/scaled_attn.cpp | 14 ++++----- src/plugins/intel_cpu/src/nodes/softmax.cpp | 2 +- .../intel_cpu/src/nodes/space_to_batch.cpp | 2 +- src/plugins/intel_cpu/src/nodes/topk.cpp | 6 ++-- .../shape_inference/custom/scaled_attn.cpp | 2 +- .../cpu_opset/arm/pass/convert_group_conv.cpp | 2 +- .../arm/pass/convert_reduce_multi_axis.cpp | 2 +- .../cpu_opset/arm/pass/mish_decomposition.cpp | 4 +-- .../common/pass/align_matmul_input_ranks.cpp | 2 +- .../pass/causal_mask_preprocess_fusion.cpp | 3 +- .../pass/convert_broadcast_to_tiles.cpp | 8 ++--- .../pass/convert_fq_rnn_to_quantized_rnn.cpp | 10 +++---- .../common/pass/convert_matmul_to_fc.cpp | 4 +-- .../common/pass/convert_tile_to_seq_tiles.cpp | 6 ++-- .../common/pass/convert_to_leaky_relu.cpp | 4 +-- .../common/pass/convert_to_power_static.cpp | 16 +++++----- .../common/pass/convert_to_swish_cpu.cpp | 4 +-- .../common/pass/decompose_integer_divide.cpp | 2 +- .../common/pass/decompose_rms_norm.cpp | 3 +- .../common/pass/stateful_sdpa_fusion.cpp | 6 ++-- .../cpu_opset/x64/pass/qkv_proj_fusion.cpp | 4 +-- .../x64/pass/snippets_mark_skipped.cpp | 4 +-- .../transformation_pipeline.cpp | 4 +-- .../src/utils/debug_capabilities.cpp | 6 ++-- .../classes/convolution.cpp | 2 +- .../embedding_bag_offsets.cpp | 2 +- .../embedding_bag_offsets_sum.cpp | 2 +- .../embedding_bag_packed.cpp | 2 +- .../embedding_bag_packed_sum.cpp | 2 +- .../embedding_segments_sum.cpp | 2 +- .../single_layer_tests/group_convolution.cpp | 2 +- .../custom/single_layer_tests/slice.cpp | 10 +++---- .../single_layer_tests/slice_scatter.cpp | 8 ++--- .../custom/single_layer_tests/topk.cpp | 6 ++-- .../functional/utils/fusing_test_utils.hpp | 6 ++-- .../x64/fake_quantize_tokenization_test.cpp | 6 ++-- .../template/backend/int_executable.cpp | 4 +-- .../backend/ops/string_tensor_pack.cpp | 2 +- .../backend/ops/string_tensor_unpack.cpp | 2 +- src/plugins/template/backend/ops/unique.cpp | 3 +- .../template/src/sync_infer_request.cpp | 2 +- 86 files changed, 217 insertions(+), 237 deletions(-) diff --git a/src/plugins/auto/src/plugin.cpp b/src/plugins/auto/src/plugin.cpp index 0b1e4da578faf1..2604bc41758419 100644 --- a/src/plugins/auto/src/plugin.cpp +++ b/src/plugins/auto/src/plugin.cpp @@ -33,10 +33,10 @@ namespace { return "INT8"; } for (auto & node : model->get_ordered_ops()) { - if (std::dynamic_pointer_cast(node) || - std::dynamic_pointer_cast(node) || - std::dynamic_pointer_cast(node) || - std::dynamic_pointer_cast(node)) { + if (ov::as_type_ptr(node) || + ov::as_type_ptr(node) || + ov::as_type_ptr(node) || + ov::as_type_ptr(node)) { auto layer_type = node->input(1).get_element_type().get_type_name(); if (layer_type == "f32") return "FP32"; @@ -827,8 +827,8 @@ std::vector Plugin::filter_device_by_model(const std::vector< std::vector stateful_node_names; for (auto& op : model->get_ops()) { - if (std::dynamic_pointer_cast(op) || - std::dynamic_pointer_cast(op)) { + if (ov::as_type_ptr(op) || + ov::as_type_ptr(op)) { stateful_node_names.push_back(op->get_friendly_name()); } } diff --git a/src/plugins/hetero/src/subgraph_collector.cpp b/src/plugins/hetero/src/subgraph_collector.cpp index 1af4cd64620230..c81dc38ee2604e 100644 --- a/src/plugins/hetero/src/subgraph_collector.cpp +++ b/src/plugins/hetero/src/subgraph_collector.cpp @@ -556,7 +556,7 @@ std::pair ov::het "supported by any plugin"); } if (dump_dot_files) { - if (auto multi_subgraph_op = std::dynamic_pointer_cast(node)) { + if (auto multi_subgraph_op = ov::as_type_ptr(node)) { for (size_t i = 0; i < multi_subgraph_op->get_internal_subgraphs_size(); ++i) { if (const auto& sub_graph = multi_subgraph_op->get_function(i)) { collect_affinities(sub_graph, debug_supported_ops.at(node->get_friendly_name())); @@ -589,7 +589,7 @@ std::pair ov::het subgraph_id = default_id; } map_id.emplace(node->get_friendly_name(), subgraph_id); - if (auto multi_subgraph_op = std::dynamic_pointer_cast(node)) { + if (auto multi_subgraph_op = ov::as_type_ptr(node)) { for (size_t i = 0; i < multi_subgraph_op->get_internal_subgraphs_size(); ++i) { if (const auto& sub_graph = multi_subgraph_op->get_function(i)) { collect_map_id(sub_graph, subgraph_id); diff --git a/src/plugins/intel_cpu/src/emitters/plugin/aarch64/jit_eltwise_emitters.cpp b/src/plugins/intel_cpu/src/emitters/plugin/aarch64/jit_eltwise_emitters.cpp index 765502241647bf..416b03ff4f0f6a 100644 --- a/src/plugins/intel_cpu/src/emitters/plugin/aarch64/jit_eltwise_emitters.cpp +++ b/src/plugins/intel_cpu/src/emitters/plugin/aarch64/jit_eltwise_emitters.cpp @@ -118,7 +118,7 @@ jit_clamp_emitter::jit_clamp_emitter(dnnl::impl::cpu::aarch64::jit_generator* ho dnnl::impl::cpu::aarch64::cpu_isa_t host_isa, const std::shared_ptr& node) : jit_emitter(host, host_isa, node, get_arithmetic_binary_exec_precision(node)) { - const auto clamp = std::dynamic_pointer_cast(node); + const auto clamp = ov::as_type_ptr(node); if (clamp == nullptr) { OV_CPU_JIT_EMITTER_THROW("Can't cast to ov::op::v0::Clamp"); } @@ -294,7 +294,7 @@ jit_elu_emitter::jit_elu_emitter(dnnl::impl::cpu::aarch64::jit_generator* host, dnnl::impl::cpu::aarch64::cpu_isa_t host_isa, const std::shared_ptr& node) : jit_emitter(host, host_isa, get_arithmetic_binary_exec_precision(node)) { - const auto elu = std::dynamic_pointer_cast(node); + const auto elu = ov::as_type_ptr(node); if (elu == nullptr) { OV_CPU_JIT_EMITTER_THROW("Can't cast to ov::op::v0::Clamp"); } @@ -2633,7 +2633,7 @@ jit_swish_emitter::jit_swish_emitter(dnnl::impl::cpu::aarch64::jit_generator* ho dnnl::impl::cpu::aarch64::cpu_isa_t host_isa, const std::shared_ptr& node) : jit_emitter(host, host_isa, node, get_arithmetic_binary_exec_precision(node)) { - const auto swish = std::dynamic_pointer_cast(node); + const auto swish = ov::as_type_ptr(node); if (swish == nullptr) { OV_CPU_JIT_EMITTER_THROW("Can't cast to SwishNode"); } diff --git a/src/plugins/intel_cpu/src/emitters/snippets/aarch64/cpu_generator.cpp b/src/plugins/intel_cpu/src/emitters/snippets/aarch64/cpu_generator.cpp index cdc768f5d4e1cc..9beae08cecb1eb 100644 --- a/src/plugins/intel_cpu/src/emitters/snippets/aarch64/cpu_generator.cpp +++ b/src/plugins/intel_cpu/src/emitters/snippets/aarch64/cpu_generator.cpp @@ -64,7 +64,7 @@ namespace ov { } \ }, \ [](const std::shared_ptr& n) -> std::set> { \ - const auto& gelu = std::dynamic_pointer_cast(n); \ + const auto& gelu = ov::as_type_ptr(n); \ if (gelu == nullptr) { \ OPENVINO_THROW("Can't cast to ov::op::v7::Gelu"); \ } \ @@ -97,7 +97,7 @@ namespace ov { } \ }, \ [](const std::shared_ptr& n) -> std::set> { \ - const auto& round = std::dynamic_pointer_cast(n); \ + const auto& round = ov::as_type_ptr(n); \ if (round == nullptr) { \ OPENVINO_THROW("Can't cast to ov::op::v5::Round"); \ } \ @@ -264,7 +264,7 @@ std::shared_ptr CPUGenerator::clone() const { ov::snippets::RegType CPUGenerator::get_specific_op_out_reg_type(const ov::Output& out) const { const auto op = out.get_node_shared_ptr(); - if (std::dynamic_pointer_cast(op) || std::dynamic_pointer_cast(op)) + if (ov::as_type_ptr(op) || ov::as_type_ptr(op)) return ov::snippets::RegType::vec; else return ov::snippets::RegType::undefined; diff --git a/src/plugins/intel_cpu/src/emitters/snippets/aarch64/jit_memory_emitters.cpp b/src/plugins/intel_cpu/src/emitters/snippets/aarch64/jit_memory_emitters.cpp index 9989f3431fb2a8..ee08476627e9f9 100644 --- a/src/plugins/intel_cpu/src/emitters/snippets/aarch64/jit_memory_emitters.cpp +++ b/src/plugins/intel_cpu/src/emitters/snippets/aarch64/jit_memory_emitters.cpp @@ -30,7 +30,7 @@ jit_load_memory_emitter::jit_load_memory_emitter(jit_generator* h, cpu_isa_t isa src_prc == dst_prc; OV_CPU_JIT_EMITTER_ASSERT(is_supported_precision, "Unsupported precision pair."); - const auto load = std::dynamic_pointer_cast(expr->get_node()); + const auto load = ov::as_type_ptr(expr->get_node()); OV_CPU_JIT_EMITTER_ASSERT(load != nullptr, "Expects Load expression"); count = load->get_count(); byte_offset = load->get_offset(); @@ -66,7 +66,7 @@ jit_load_broadcast_emitter::jit_load_broadcast_emitter(jit_generator* h, cpu_isa dst_prc.get_type_name()); OV_CPU_JIT_EMITTER_ASSERT(src_prc == ov::element::f32, "Only supports FP32 precision."); - const auto broadcast_load = std::dynamic_pointer_cast(expr->get_node()); + const auto broadcast_load = ov::as_type_ptr(expr->get_node()); OV_CPU_JIT_EMITTER_ASSERT(broadcast_load != nullptr, "Expects BroadcastLoad expression"); byte_offset = broadcast_load->get_offset(); in_out_type_ = emitter_in_out_map::gpr_to_vec; diff --git a/src/plugins/intel_cpu/src/emitters/snippets/x64/cpu_generator.cpp b/src/plugins/intel_cpu/src/emitters/snippets/x64/cpu_generator.cpp index 31daa32dfa144f..6bc05dbc43b41d 100644 --- a/src/plugins/intel_cpu/src/emitters/snippets/x64/cpu_generator.cpp +++ b/src/plugins/intel_cpu/src/emitters/snippets/x64/cpu_generator.cpp @@ -390,15 +390,14 @@ std::shared_ptr intel_cpu::CPUGenerator::clone() const { ov::snippets::RegType intel_cpu::CPUGenerator::get_specific_op_out_reg_type(const ov::Output& out) const { const auto op = out.get_node_shared_ptr(); - if (std::dynamic_pointer_cast(op) || + if (ov::as_type_ptr(op) || #ifdef SNIPPETS_LIBXSMM_TPP std::dynamic_pointer_cast(op) || - std::dynamic_pointer_cast(op) || + ov::as_type_ptr(op) || #endif - std::dynamic_pointer_cast(op)) + ov::as_type_ptr(op)) return ov::snippets::RegType::gpr; - else if (std::dynamic_pointer_cast(op) || - std::dynamic_pointer_cast(op)) + else if (ov::as_type_ptr(op) || ov::as_type_ptr(op)) return ov::snippets::RegType::vec; else return ov::snippets::RegType::undefined; diff --git a/src/plugins/intel_cpu/src/graph.cpp b/src/plugins/intel_cpu/src/graph.cpp index f01603187feb77..cd7944b7246ef9 100644 --- a/src/plugins/intel_cpu/src/graph.cpp +++ b/src/plugins/intel_cpu/src/graph.cpp @@ -131,7 +131,7 @@ void Graph::Replicate(const std::shared_ptr& model, auto createNode = [&](std::shared_ptr op) -> NodePtr { // special handling for Parameters and Results if (op->get_type_info() == op::v0::Parameter::get_type_info_static()) { - auto input_index = model->get_parameter_index(std::dynamic_pointer_cast(op)); + auto input_index = model->get_parameter_index(ov::as_type_ptr(op)); OPENVINO_ASSERT(input_index >= 0, "CPU plugin cannot find op: ", op->get_friendly_name(), @@ -150,7 +150,7 @@ void Graph::Replicate(const std::shared_ptr& model, } if (op->get_type_info() == op::v0::Result::get_type_info_static()) { - auto output_index = model->get_result_index(std::dynamic_pointer_cast(op)); + auto output_index = model->get_result_index(ov::as_type_ptr(op)); OPENVINO_ASSERT(output_index >= 0, "CPU plugin cannot find op: ", op->get_friendly_name(), diff --git a/src/plugins/intel_cpu/src/nodes/adaptive_pooling.cpp b/src/plugins/intel_cpu/src/nodes/adaptive_pooling.cpp index f0d2918130ebb7..12662400d8654a 100644 --- a/src/plugins/intel_cpu/src/nodes/adaptive_pooling.cpp +++ b/src/plugins/intel_cpu/src/nodes/adaptive_pooling.cpp @@ -30,13 +30,13 @@ bool AdaptivePooling::isSupportedOperation(const std::shared_ptr std::string& errorMessage) noexcept { try { if (one_of(op->get_type_info(), ov::op::v8::AdaptiveAvgPool::get_type_info_static())) { - auto adaPool = std::dynamic_pointer_cast(op); + auto adaPool = ov::as_type_ptr(op); if (!adaPool) { errorMessage = "Only opset8 AdaptiveAvgPooling operation is supported"; return false; } } else if (one_of(op->get_type_info(), ov::op::v8::AdaptiveMaxPool::get_type_info_static())) { - auto adaPool = std::dynamic_pointer_cast(op); + auto adaPool = ov::as_type_ptr(op); if (!adaPool) { errorMessage = "Only opset8 AdaptiveMaxPooling operation is supported"; return false; diff --git a/src/plugins/intel_cpu/src/nodes/batch_to_space.cpp b/src/plugins/intel_cpu/src/nodes/batch_to_space.cpp index d10f510bd41f0d..a621cf74e78668 100644 --- a/src/plugins/intel_cpu/src/nodes/batch_to_space.cpp +++ b/src/plugins/intel_cpu/src/nodes/batch_to_space.cpp @@ -19,7 +19,7 @@ namespace node { bool BatchToSpace::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { - const auto batchToSpace = std::dynamic_pointer_cast(op); + const auto batchToSpace = ov::as_type_ptr(op); if (!batchToSpace) { errorMessage = "Only opset2 BatchToSpace operation is supported"; return false; diff --git a/src/plugins/intel_cpu/src/nodes/bin_conv.cpp b/src/plugins/intel_cpu/src/nodes/bin_conv.cpp index f0d2728363abe8..881ea56ef76dc6 100644 --- a/src/plugins/intel_cpu/src/nodes/bin_conv.cpp +++ b/src/plugins/intel_cpu/src/nodes/bin_conv.cpp @@ -921,7 +921,7 @@ bool BinaryConvolution::isSupportedOperation(const std::shared_ptr(op); + const auto binConv = ov::as_type_ptr(op); if (!binConv) { errorMessage = "Only opset1 BinaryConvolution operation is supported"; return false; @@ -941,7 +941,7 @@ BinaryConvolution::BinaryConvolution(const std::shared_ptr& op, const std::string errorMessage; if (isSupportedOperation(op, errorMessage)) { errorPrefix = "BinaryConvolution node with name '" + getName() + "' "; - const auto binConv = std::dynamic_pointer_cast(op); + const auto binConv = ov::as_type_ptr(op); pad_value = binConv->get_pad_value(); for (size_t i = 0; i < binConv->get_strides().size(); i++) { diff --git a/src/plugins/intel_cpu/src/nodes/bucketize.cpp b/src/plugins/intel_cpu/src/nodes/bucketize.cpp index 8a0c2b8c6a3956..03c6924d9a8883 100644 --- a/src/plugins/intel_cpu/src/nodes/bucketize.cpp +++ b/src/plugins/intel_cpu/src/nodes/bucketize.cpp @@ -18,7 +18,7 @@ namespace node { bool Bucketize::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { - const auto bucketsize = std::dynamic_pointer_cast(op); + const auto bucketsize = ov::as_type_ptr(op); if (!bucketsize) { errorMessage = "Only opset3 Bucketize operation is supported"; return false; @@ -37,7 +37,7 @@ Bucketize::Bucketize(const std::shared_ptr& op, const GraphContext::CP } errorPrefix = "Bucketize layer with name '" + op->get_friendly_name() + "' "; - const auto bucketsize = std::dynamic_pointer_cast(op); + const auto bucketsize = ov::as_type_ptr(op); if (bucketsize == nullptr) OPENVINO_THROW("Operation with name '", op->get_friendly_name(), diff --git a/src/plugins/intel_cpu/src/nodes/causal_mask_preprocess.cpp b/src/plugins/intel_cpu/src/nodes/causal_mask_preprocess.cpp index fd015a372ed1db..1803dc5c10b45e 100644 --- a/src/plugins/intel_cpu/src/nodes/causal_mask_preprocess.cpp +++ b/src/plugins/intel_cpu/src/nodes/causal_mask_preprocess.cpp @@ -106,14 +106,14 @@ CausalMaskPreprocess::CausalMaskPreprocess(const std::shared_ptr& op, OPENVINO_THROW("CPU: " + errorMessage); } - const auto node = std::dynamic_pointer_cast(op); + const auto node = ov::as_type_ptr(op); m_config = node->get_config(); } bool CausalMaskPreprocess::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { - const auto node = std::dynamic_pointer_cast(op); + const auto node = ov::as_type_ptr(op); if (!node) { errorMessage = "Only CausalMaskPreprocessNode operation is supported"; return false; diff --git a/src/plugins/intel_cpu/src/nodes/convert.cpp b/src/plugins/intel_cpu/src/nodes/convert.cpp index 2b761d23824ced..7b050613739b2c 100644 --- a/src/plugins/intel_cpu/src/nodes/convert.cpp +++ b/src/plugins/intel_cpu/src/nodes/convert.cpp @@ -17,7 +17,7 @@ namespace node { bool Convert::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { - const auto convert = std::dynamic_pointer_cast(op); + const auto convert = ov::as_type_ptr(op); if (!convert) { errorMessage = "Only opset1 Convert operation is supported"; return false; diff --git a/src/plugins/intel_cpu/src/nodes/cum_sum.cpp b/src/plugins/intel_cpu/src/nodes/cum_sum.cpp index 7b5d7aa9c8dd27..72c5749b89b492 100644 --- a/src/plugins/intel_cpu/src/nodes/cum_sum.cpp +++ b/src/plugins/intel_cpu/src/nodes/cum_sum.cpp @@ -19,7 +19,7 @@ namespace node { bool CumSum::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { - const auto cumsum = std::dynamic_pointer_cast(op); + const auto cumsum = ov::as_type_ptr(op); if (!cumsum) { errorMessage = "Only opset3 CumSum operation is supported"; return false; @@ -49,7 +49,7 @@ CumSum::CumSum(const std::shared_ptr& op, const GraphContext::CPtr con OPENVINO_THROW(errorPrefix, " doesn't support 'data' input tensor with rank: ", numOfDims); } - const auto cumsum = std::dynamic_pointer_cast(op); + const auto cumsum = ov::as_type_ptr(op); if (cumsum == nullptr) OPENVINO_THROW("Operation with name '", op->get_friendly_name(), "' is not an instance of CumSum from opset3."); diff --git a/src/plugins/intel_cpu/src/nodes/deconv.cpp b/src/plugins/intel_cpu/src/nodes/deconv.cpp index 5e6787c0b6ed72..a911e00916c169 100644 --- a/src/plugins/intel_cpu/src/nodes/deconv.cpp +++ b/src/plugins/intel_cpu/src/nodes/deconv.cpp @@ -142,8 +142,8 @@ class DeconfolutionShapeInferFactory : public ShapeInferFactory { bool Deconvolution::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { - if (std::dynamic_pointer_cast(op) == nullptr && - std::dynamic_pointer_cast(op) == nullptr) { + if (ov::as_type_ptr(op) == nullptr && + ov::as_type_ptr(op) == nullptr) { errorMessage = "Only opset1 ConvolutionBackpropData and GroupConvolutionBackpropData operations are supported"; return false; @@ -173,7 +173,7 @@ Deconvolution::Deconvolution(const std::shared_ptr& op, const GraphCon const auto& weightDims = getWeightDims(); - if (auto convBackprop = std::dynamic_pointer_cast(op)) { + if (auto convBackprop = ov::as_type_ptr(op)) { algorithm = Algorithm::DeconvolutionCommon; IC = weightDims[0]; @@ -195,7 +195,7 @@ Deconvolution::Deconvolution(const std::shared_ptr& op, const GraphCon deconvAttrs.outputPadding = convBackprop->get_output_padding(); autoPad = one_of(convBackprop->get_auto_pad(), ov::op::PadType::SAME_LOWER, ov::op::PadType::SAME_UPPER); - } else if (auto groupConvBackprop = std::dynamic_pointer_cast(op)) { + } else if (auto groupConvBackprop = ov::as_type_ptr(op)) { algorithm = Algorithm::DeconvolutionGrouped; groupNum = weightDims[0]; diff --git a/src/plugins/intel_cpu/src/nodes/def_conv.cpp b/src/plugins/intel_cpu/src/nodes/def_conv.cpp index 14ba7374fd3570..6165e960837882 100644 --- a/src/plugins/intel_cpu/src/nodes/def_conv.cpp +++ b/src/plugins/intel_cpu/src/nodes/def_conv.cpp @@ -775,7 +775,7 @@ DeformableConvolution::DeformableConvolution(const std::shared_ptr& op OPENVINO_THROW_NOT_IMPLEMENTED(errorMessage); } errorPrefix = "Deformable convolution with name '" + op->get_friendly_name() + "'"; - auto defConvNodeBase = std::dynamic_pointer_cast(op); + auto defConvNodeBase = ov::as_type_ptr(op); if (defConvNodeBase == nullptr) OPENVINO_THROW(errorPrefix, " is not an instance of DeformableConvolutionBase."); @@ -796,7 +796,7 @@ DeformableConvolution::DeformableConvolution(const std::shared_ptr& op autoPadding = one_of(defConvNodeBase->get_auto_pad(), ov::op::PadType::SAME_UPPER, ov::op::PadType::SAME_LOWER); if (op->get_type_info() == ov::op::v8::DeformableConvolution::get_type_info_static()) { - auto defConvNode = std::dynamic_pointer_cast(op); + auto defConvNode = ov::as_type_ptr(op); if (defConvNode == nullptr) OPENVINO_THROW(errorPrefix, " is not an instance of DeformableConvolution from opset8."); defConvAttr.with_bilinear_pad = defConvNode->get_bilinear_interpolation_pad(); diff --git a/src/plugins/intel_cpu/src/nodes/experimental_detectron_priorgridgenerator.cpp b/src/plugins/intel_cpu/src/nodes/experimental_detectron_priorgridgenerator.cpp index 70a8f2893938db..e9c7b2e0e0a5a4 100644 --- a/src/plugins/intel_cpu/src/nodes/experimental_detectron_priorgridgenerator.cpp +++ b/src/plugins/intel_cpu/src/nodes/experimental_detectron_priorgridgenerator.cpp @@ -16,8 +16,7 @@ namespace node { bool ExperimentalDetectronPriorGridGenerator::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { - const auto priorGridGen = - std::dynamic_pointer_cast(op); + const auto priorGridGen = ov::as_type_ptr(op); if (!priorGridGen) { errorMessage = "Only opset6 ExperimentalDetectronPriorGridGenerator operation is supported"; return false; @@ -37,7 +36,7 @@ ExperimentalDetectronPriorGridGenerator::ExperimentalDetectronPriorGridGenerator } errorPrefix = "ExperimentalDetectronPriorGridGenerator layer with name '" + op->get_friendly_name() + "'"; - const auto priorGridGen = std::dynamic_pointer_cast(op); + const auto priorGridGen = ov::as_type_ptr(op); if (getOriginalInputsNumber() != 3 || getOriginalOutputsNumber() != 1) OPENVINO_THROW(errorPrefix, " has incorrect number of input/output edges!"); diff --git a/src/plugins/intel_cpu/src/nodes/experimental_detectron_roifeatureextractor.cpp b/src/plugins/intel_cpu/src/nodes/experimental_detectron_roifeatureextractor.cpp index 5bc3f13c15b6a9..7a5b8eae3bd688 100644 --- a/src/plugins/intel_cpu/src/nodes/experimental_detectron_roifeatureextractor.cpp +++ b/src/plugins/intel_cpu/src/nodes/experimental_detectron_roifeatureextractor.cpp @@ -271,7 +271,7 @@ bool ExperimentalDetectronROIFeatureExtractor::isSupportedOperation(const std::s std::string& errorMessage) noexcept { try { const auto roiFeatureExtractor = - std::dynamic_pointer_cast(op); + ov::as_type_ptr(op); if (!roiFeatureExtractor) { errorMessage = "Only opset6 ExperimentalDetectronROIFeatureExtractor operation is supported"; return false; @@ -290,8 +290,7 @@ ExperimentalDetectronROIFeatureExtractor::ExperimentalDetectronROIFeatureExtract OPENVINO_THROW_NOT_IMPLEMENTED(errorMessage); } - const auto roiFeatureExtractor = - std::dynamic_pointer_cast(op); + const auto roiFeatureExtractor = ov::as_type_ptr(op); const auto& attr = roiFeatureExtractor->get_attrs(); output_dim_ = attr.output_size; pyramid_scales_ = attr.pyramid_scales; diff --git a/src/plugins/intel_cpu/src/nodes/experimental_detectron_topkrois.cpp b/src/plugins/intel_cpu/src/nodes/experimental_detectron_topkrois.cpp index 7428c6b27eefcf..e6b385a1d28af7 100644 --- a/src/plugins/intel_cpu/src/nodes/experimental_detectron_topkrois.cpp +++ b/src/plugins/intel_cpu/src/nodes/experimental_detectron_topkrois.cpp @@ -19,7 +19,7 @@ namespace node { bool ExperimentalDetectronTopKROIs::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { - const auto topKROI = std::dynamic_pointer_cast(op); + const auto topKROI = ov::as_type_ptr(op); if (!topKROI) { errorMessage = "Only opset6 ExperimentalDetectronTopKROIs operation is supported"; return false; @@ -39,7 +39,7 @@ ExperimentalDetectronTopKROIs::ExperimentalDetectronTopKROIs(const std::shared_p } errorPrefix = "ExperimentalDetectronTopKROIs layer with name '" + op->get_friendly_name() + "'"; - const auto topKROI = std::dynamic_pointer_cast(op); + const auto topKROI = ov::as_type_ptr(op); if (topKROI == nullptr) OPENVINO_THROW("Operation with name '", op->get_friendly_name(), diff --git a/src/plugins/intel_cpu/src/nodes/fake_quantize.cpp b/src/plugins/intel_cpu/src/nodes/fake_quantize.cpp index 8cb29945c1a52a..431c6f133e15ae 100644 --- a/src/plugins/intel_cpu/src/nodes/fake_quantize.cpp +++ b/src/plugins/intel_cpu/src/nodes/fake_quantize.cpp @@ -961,7 +961,7 @@ struct jit_uni_quantization_kernel : public jit_uni_quantize_kernel, public jit_ #endif bool FakeQuantize::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { - const auto fq = std::dynamic_pointer_cast(op); + const auto fq = ov::as_type_ptr(op); if (!fq) { errorMessage = "Only opset1 FakeQuantize operation is supported"; return false; @@ -979,7 +979,7 @@ bool FakeQuantize::isSupportedOperation(const std::shared_ptr& o } } for (size_t i = 1; i < fq->get_input_size(); i++) { - if (!std::dynamic_pointer_cast(fq->get_input_node_shared_ptr(i))) { + if (!ov::as_type_ptr(fq->get_input_node_shared_ptr(i))) { errorMessage = "Has non const 'range' input on " + std::to_string(i) + " port"; return false; } @@ -1061,7 +1061,7 @@ FakeQuantize::FakeQuantize(const std::shared_ptr& op, const GraphConte std::string errorMessage; if (isSupportedOperation(op, errorMessage)) { algorithm = Algorithm::FQCommon; - const auto fq = std::dynamic_pointer_cast(op); + const auto fq = ov::as_type_ptr(op); errorPrefix = "FakeQuantize node with name '" + getName() + "' "; levels = fq->get_levels(); @@ -1129,20 +1129,16 @@ FakeQuantize::FakeQuantize(const std::shared_ptr& op, const GraphConte OPENVINO_THROW(errorPrefix, "has different quantization axis size on 'data' and 'range' inputs"); } - const auto inputLowNode = - std::dynamic_pointer_cast(fq->get_input_node_shared_ptr(1)); + const auto inputLowNode = ov::as_type_ptr(fq->get_input_node_shared_ptr(1)); auto inputLowData = inputLowNode->cast_vector(); - const auto inputHighNode = - std::dynamic_pointer_cast(fq->get_input_node_shared_ptr(2)); + const auto inputHighNode = ov::as_type_ptr(fq->get_input_node_shared_ptr(2)); auto inputHighData = inputHighNode->cast_vector(); - const auto outputLowNode = - std::dynamic_pointer_cast(fq->get_input_node_shared_ptr(3)); + const auto outputLowNode = ov::as_type_ptr(fq->get_input_node_shared_ptr(3)); auto outputLowData = outputLowNode->cast_vector(); - const auto outputHighNode = - std::dynamic_pointer_cast(fq->get_input_node_shared_ptr(4)); + const auto outputHighNode = ov::as_type_ptr(fq->get_input_node_shared_ptr(4)); auto outputHighData = outputHighNode->cast_vector(); binarization = levels == 2; diff --git a/src/plugins/intel_cpu/src/nodes/gather.cpp b/src/plugins/intel_cpu/src/nodes/gather.cpp index a1f3e4abb9b11c..337d425465e564 100644 --- a/src/plugins/intel_cpu/src/nodes/gather.cpp +++ b/src/plugins/intel_cpu/src/nodes/gather.cpp @@ -32,7 +32,7 @@ namespace node { bool Gather::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { - const auto gather_compression = std::dynamic_pointer_cast(op); + const auto gather_compression = ov::as_type_ptr(op); if (gather_compression) { return true; } diff --git a/src/plugins/intel_cpu/src/nodes/grn.cpp b/src/plugins/intel_cpu/src/nodes/grn.cpp index 64eee935622f8a..d1275a153b4f2d 100644 --- a/src/plugins/intel_cpu/src/nodes/grn.cpp +++ b/src/plugins/intel_cpu/src/nodes/grn.cpp @@ -15,7 +15,7 @@ namespace node { bool GRN::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { - const auto grn = std::dynamic_pointer_cast(op); + const auto grn = ov::as_type_ptr(op); if (!grn) { errorMessage = "Only opset1 GRN operation is supported"; return false; @@ -34,7 +34,7 @@ GRN::GRN(const std::shared_ptr& op, const GraphContext::CPtr context) } errorPrefix = "GRN layer with name '" + op->get_friendly_name() + "'"; - const auto grn = std::dynamic_pointer_cast(op); + const auto grn = ov::as_type_ptr(op); if (grn == nullptr) OPENVINO_THROW("Operation with name '", op->get_friendly_name(), "' is not an instance of GRN from opset1."); diff --git a/src/plugins/intel_cpu/src/nodes/interaction.cpp b/src/plugins/intel_cpu/src/nodes/interaction.cpp index cc9cced899c344..55d5055ff45614 100644 --- a/src/plugins/intel_cpu/src/nodes/interaction.cpp +++ b/src/plugins/intel_cpu/src/nodes/interaction.cpp @@ -188,7 +188,7 @@ Interaction::Interaction(const std::shared_ptr& op, const GraphContext OPENVINO_THROW_NOT_IMPLEMENTED(errorMessage); } errorPrefix = "Interaction node with name '" + getName() + "'"; - const auto interaction = std::dynamic_pointer_cast(op); + const auto interaction = ov::as_type_ptr(op); const std::vector& scales = interaction->get_output_scales(); if (!scales.empty()) { fqScales = scales; @@ -367,7 +367,7 @@ bool Interaction::isExecutable() const { bool Interaction::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { - const auto interaction = std::dynamic_pointer_cast(op); + const auto interaction = ov::as_type_ptr(op); if (!interaction) { errorMessage = "Only Interaction operation is supported"; return false; diff --git a/src/plugins/intel_cpu/src/nodes/interpolate.cpp b/src/plugins/intel_cpu/src/nodes/interpolate.cpp index a420873396bc1d..b2c27b26914614 100644 --- a/src/plugins/intel_cpu/src/nodes/interpolate.cpp +++ b/src/plugins/intel_cpu/src/nodes/interpolate.cpp @@ -1734,7 +1734,7 @@ using ngInterpShapeCalcMode = ov::op::v4::Interpolate::ShapeCalcMode; bool Interpolate::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { - if (const auto interp = std::dynamic_pointer_cast(op)) { + if (const auto interp = ov::as_type_ptr(op)) { const auto& interpAttr = interp->get_attrs(); const auto& interpMode = interpAttr.mode; if (!one_of(interpMode, @@ -1797,12 +1797,12 @@ bool Interpolate::isSupportedOperation(const std::shared_ptr& op return false; } - if (interp->get_input_size() > 3 && std::dynamic_pointer_cast( - interp->get_input_node_shared_ptr(AXES_ID)) == nullptr) { + if (interp->get_input_size() > 3 && + ov::as_type_ptr(interp->get_input_node_shared_ptr(AXES_ID)) == nullptr) { errorMessage = "Only const 'axes' input is supported in Interpolate-4"; return false; } - } else if (const auto interp = std::dynamic_pointer_cast(op)) { + } else if (const auto interp = ov::as_type_ptr(op)) { const auto& interpAttr = interp->get_attrs(); const auto& interpMode = interpAttr.mode; if (!one_of(interpMode, ngInterpMode::BILINEAR_PILLOW, ngInterpMode::BICUBIC_PILLOW)) { @@ -1826,7 +1826,7 @@ bool Interpolate::isSupportedOperation(const std::shared_ptr& op errorMessage = "Only const 'scales_or_sizes' input is supported for static shapes in Interpolate-11"; return false; } - if (interp->get_input_size() > 2 && std::dynamic_pointer_cast( + if (interp->get_input_size() > 2 && ov::as_type_ptr( interp->get_input_node_shared_ptr(AXES_ID_V11)) == nullptr) { errorMessage = "Only const 'axes' input is supported in Interpolate-11"; return false; @@ -1878,7 +1878,7 @@ Interpolate::Interpolate(const std::shared_ptr& op, const GraphContext if (isSupportedOperation(op, errorMessage)) { errorPrefix = "Interpolate node with name '" + getName() + "'"; dataRank = getInputShapeAtPort(DATA_ID).getRank(); - if (const auto interp = std::dynamic_pointer_cast(op)) { + if (const auto interp = ov::as_type_ptr(op)) { is_version11 = false; const auto numInputs = inputShapes.size(); if (numInputs != 3 && numInputs != 4) @@ -1967,14 +1967,14 @@ Interpolate::Interpolate(const std::shared_ptr& op, const GraphContext } const auto scalesNode = - std::dynamic_pointer_cast(interp->get_input_node_shared_ptr(SCALES_ID)); + ov::as_type_ptr(interp->get_input_node_shared_ptr(SCALES_ID)); if (scalesNode) { scales = scalesNode->cast_vector(); isScaleConstant = true; } if (isAxesSpecified) { - axes = std::dynamic_pointer_cast(interp->get_input_node_shared_ptr(AXES_ID)) + axes = ov::as_type_ptr(interp->get_input_node_shared_ptr(AXES_ID)) ->cast_vector(); } else { axes.resize(dataRank); @@ -1982,7 +1982,7 @@ Interpolate::Interpolate(const std::shared_ptr& op, const GraphContext axes[i] = i; } } - } else if (const auto interp = std::dynamic_pointer_cast(op)) { + } else if (const auto interp = ov::as_type_ptr(op)) { is_version11 = true; const auto numInputs = inputShapes.size(); if (numInputs != 2 && numInputs != 3) @@ -2009,7 +2009,7 @@ Interpolate::Interpolate(const std::shared_ptr& op, const GraphContext const auto& interpShapeCalcMode = interpAttr.shape_calculation_mode; if (interpShapeCalcMode == ngInterpShapeCalcMode::SCALES) { interpAttrs.shapeCalcMode = InterpolateShapeCalcMode::scales; - const auto scalesNode = std::dynamic_pointer_cast( + const auto scalesNode = ov::as_type_ptr( interp->get_input_node_shared_ptr(SIZE_OR_SCALE_ID_V11)); if (scalesNode) { scales = scalesNode->cast_vector(); @@ -2038,8 +2038,7 @@ Interpolate::Interpolate(const std::shared_ptr& op, const GraphContext } if (isAxesSpecified) { - axes = std::dynamic_pointer_cast( - interp->get_input_node_shared_ptr(AXES_ID_V11)) + axes = ov::as_type_ptr(interp->get_input_node_shared_ptr(AXES_ID_V11)) ->cast_vector(); if (dataRank == 4 && axes.size() == 2 && axes[0] == 1 && axes[1] == 2 && mayiuse(cpu::x64::sse41)) { NCHWAsNHWC = true; diff --git a/src/plugins/intel_cpu/src/nodes/llm_mlp.cpp b/src/plugins/intel_cpu/src/nodes/llm_mlp.cpp index afb5f1e38c72fd..81acbb7a7787e7 100644 --- a/src/plugins/intel_cpu/src/nodes/llm_mlp.cpp +++ b/src/plugins/intel_cpu/src/nodes/llm_mlp.cpp @@ -503,7 +503,7 @@ LLMMLP::LLMMLP(const std::shared_ptr& op, const GraphContext::CPtr con if (!isSupportedOperation(op, errorMessage, config.fcDynamicQuantizationGroupSize)) { OPENVINO_THROW("CPU: " + errorMessage); } - const auto node_mlp = std::dynamic_pointer_cast(op); + const auto node_mlp = ov::as_type_ptr(op); m_mlp_config = node_mlp->get_config(); } @@ -599,7 +599,7 @@ bool LLMMLP::isSupportedOperation(const std::shared_ptr& op, uint64_t fcDynamicQuantizationGroupSize) noexcept { #if defined(OPENVINO_ARCH_X86_64) try { - const auto node_mlp = std::dynamic_pointer_cast(op); + const auto node_mlp = ov::as_type_ptr(op); if (node_mlp) { auto down_proj_w_pshape = op->input_value(1).get_partial_shape(); if (!down_proj_w_pshape.is_static()) { diff --git a/src/plugins/intel_cpu/src/nodes/log_softmax.cpp b/src/plugins/intel_cpu/src/nodes/log_softmax.cpp index d8347ca73e20dc..57c84b7c822df0 100644 --- a/src/plugins/intel_cpu/src/nodes/log_softmax.cpp +++ b/src/plugins/intel_cpu/src/nodes/log_softmax.cpp @@ -15,7 +15,7 @@ namespace node { bool LogSoftmax::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { - const auto logSoftMax = std::dynamic_pointer_cast(op); + const auto logSoftMax = ov::as_type_ptr(op); if (!logSoftMax) { errorMessage = "Only opset5 LogSoftmax operation is supported"; return false; @@ -34,7 +34,7 @@ LogSoftmax::LogSoftmax(const std::shared_ptr& op, const GraphContext:: } errorPrefix = "LogSoftmax layer with name '" + op->get_friendly_name() + "'"; - const auto logSoftMax = std::dynamic_pointer_cast(op); + const auto logSoftMax = ov::as_type_ptr(op); if (logSoftMax == nullptr) OPENVINO_THROW("Operation with name '", op->get_friendly_name(), diff --git a/src/plugins/intel_cpu/src/nodes/matmul.cpp b/src/plugins/intel_cpu/src/nodes/matmul.cpp index ee363dfa887747..b0853737040d14 100644 --- a/src/plugins/intel_cpu/src/nodes/matmul.cpp +++ b/src/plugins/intel_cpu/src/nodes/matmul.cpp @@ -86,7 +86,7 @@ bool MatMul::canBeExecutedInInt8() const { bool MatMul::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { - const auto matMul = std::dynamic_pointer_cast(op); + const auto matMul = ov::as_type_ptr(op); if (!matMul) { errorMessage = "Only opset1 MatMul operation is supported"; return false; @@ -121,7 +121,7 @@ MatMul::MatMul(const std::shared_ptr& op, const GraphContext::CPtr con if (!isSupportedOperation(op, errorMessage)) OPENVINO_THROW_NOT_IMPLEMENTED(errorMessage); - const auto matMul = std::dynamic_pointer_cast(op); + const auto matMul = ov::as_type_ptr(op); if (!matMul) { OPENVINO_THROW_NOT_IMPLEMENTED("Operation with name ", diff --git a/src/plugins/intel_cpu/src/nodes/matrix_nms.cpp b/src/plugins/intel_cpu/src/nodes/matrix_nms.cpp index a3fedc7f3099d7..302f1574c4e677 100644 --- a/src/plugins/intel_cpu/src/nodes/matrix_nms.cpp +++ b/src/plugins/intel_cpu/src/nodes/matrix_nms.cpp @@ -25,7 +25,7 @@ using ngNmseDcayFunction = ov::op::v8::MatrixNms::DecayFunction; bool MatrixNms::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { - const auto nms = std::dynamic_pointer_cast(op); + const auto nms = ov::as_type_ptr(op); if (!nms) { errorMessage = "Only MatrixNms operation is supported"; return false; @@ -65,7 +65,7 @@ MatrixNms::MatrixNms(const std::shared_ptr& op, const GraphContext::CP if (getOriginalOutputsNumber() != 3) OPENVINO_THROW(m_errorPrefix, "has incorrect number of output edges: ", getOriginalOutputsNumber()); - const auto matrix_nms = std::dynamic_pointer_cast(op); + const auto matrix_nms = ov::as_type_ptr(op); auto& attrs = matrix_nms->get_attrs(); if (attrs.sort_result_type == ov::op::v8::MatrixNms::SortResultType::CLASSID) diff --git a/src/plugins/intel_cpu/src/nodes/mha.cpp b/src/plugins/intel_cpu/src/nodes/mha.cpp index 6aeab7ad93dbd6..a78629f8c0f1cc 100644 --- a/src/plugins/intel_cpu/src/nodes/mha.cpp +++ b/src/plugins/intel_cpu/src/nodes/mha.cpp @@ -728,7 +728,7 @@ struct jit_convert_transpose_kernel : public jit_uni_convert_transpose_kernel, p bool MHA::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { - const auto mha = std::dynamic_pointer_cast(op); + const auto mha = ov::as_type_ptr(op); if (!mha) { errorMessage = "Only MHA from CPU internal opset is supported"; return false; @@ -808,7 +808,7 @@ MHA::MHA(const std::shared_ptr& op, const GraphContext::CPtr context) OPENVINO_THROW_NOT_IMPLEMENTED(errorMessage); } - const auto mha = std::dynamic_pointer_cast(op); + const auto mha = ov::as_type_ptr(op); mulScales = mha->get_mul_scales(); isMulFirst = mha->get_is_mul_first(); fqScales0 = mha->get_fq_scales0(); diff --git a/src/plugins/intel_cpu/src/nodes/multiclass_nms.cpp b/src/plugins/intel_cpu/src/nodes/multiclass_nms.cpp index cbe7e29e9b955c..510dcc8678ab8a 100644 --- a/src/plugins/intel_cpu/src/nodes/multiclass_nms.cpp +++ b/src/plugins/intel_cpu/src/nodes/multiclass_nms.cpp @@ -59,7 +59,7 @@ MultiClassNms::MultiClassNms(const std::shared_ptr& op, const GraphCon if (getOriginalOutputsNumber() != 3) OPENVINO_THROW(m_errorPrefix, "has incorrect number of output edges: ", getOriginalOutputsNumber()); - auto nmsBase = std::dynamic_pointer_cast(op); + auto nmsBase = ov::as_type_ptr(op); if (nmsBase == nullptr) OPENVINO_THROW(m_errorPrefix, " is not an instance of MulticlassNmsBase."); auto& atrri = nmsBase->get_attrs(); diff --git a/src/plugins/intel_cpu/src/nodes/one_hot.cpp b/src/plugins/intel_cpu/src/nodes/one_hot.cpp index de43cb00b69d9f..cfeed26f3ab65b 100644 --- a/src/plugins/intel_cpu/src/nodes/one_hot.cpp +++ b/src/plugins/intel_cpu/src/nodes/one_hot.cpp @@ -21,18 +21,17 @@ namespace node { bool OneHot::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { - const auto oneHot = std::dynamic_pointer_cast(op); + const auto oneHot = ov::as_type_ptr(op); if (!oneHot) { errorMessage = "Only opset1 OneHot operation is supported"; return false; } - if (std::dynamic_pointer_cast(oneHot->get_input_node_shared_ptr(ON_VALUE_ID)) == - nullptr) { + if (ov::as_type_ptr(oneHot->get_input_node_shared_ptr(ON_VALUE_ID)) == nullptr) { errorMessage = "Only const 'on_value' input is supported"; return false; } - if (std::dynamic_pointer_cast( - oneHot->get_input_node_shared_ptr(OFF_VALUEAXES_ID)) == nullptr) { + if (ov::as_type_ptr(oneHot->get_input_node_shared_ptr(OFF_VALUEAXES_ID)) == + nullptr) { errorMessage = "Only const 'off_value' input is supported"; return false; } @@ -50,9 +49,8 @@ OneHot::OneHot(const std::shared_ptr& op, const GraphContext::CPtr con } errorPrefix = "OneHot layer with name '" + op->get_friendly_name() + "'"; - const auto oneHot = std::dynamic_pointer_cast(op); - const auto depthNode = - std::dynamic_pointer_cast(oneHot->get_input_node_shared_ptr(DEPTH_ID)); + const auto oneHot = ov::as_type_ptr(op); + const auto depthNode = ov::as_type_ptr(oneHot->get_input_node_shared_ptr(DEPTH_ID)); if (depthNode) { depth = depthNode->cast_vector()[0]; } diff --git a/src/plugins/intel_cpu/src/nodes/priorbox.cpp b/src/plugins/intel_cpu/src/nodes/priorbox.cpp index 402864a9340a45..9f892f733c7375 100644 --- a/src/plugins/intel_cpu/src/nodes/priorbox.cpp +++ b/src/plugins/intel_cpu/src/nodes/priorbox.cpp @@ -32,7 +32,7 @@ float clip_less(float x, float threshold) { bool PriorBox::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { - const auto priorBox = std::dynamic_pointer_cast(op); + const auto priorBox = ov::as_type_ptr(op); if (!priorBox) { errorMessage = "Only opset1 PriorBox operation is supported"; return false; @@ -50,7 +50,7 @@ PriorBox::PriorBox(const std::shared_ptr& op, const GraphContext::CPtr OPENVINO_THROW_NOT_IMPLEMENTED(errorMessage); } - const auto priorBox = std::dynamic_pointer_cast(op); + const auto priorBox = ov::as_type_ptr(op); const ov::opset1::PriorBox::Attributes& attrs = priorBox->get_attrs(); offset = attrs.offset; step = attrs.step; diff --git a/src/plugins/intel_cpu/src/nodes/priorbox_clustered.cpp b/src/plugins/intel_cpu/src/nodes/priorbox_clustered.cpp index 54c281e43ecaf5..fb21f1e8c6b5ab 100644 --- a/src/plugins/intel_cpu/src/nodes/priorbox_clustered.cpp +++ b/src/plugins/intel_cpu/src/nodes/priorbox_clustered.cpp @@ -20,7 +20,7 @@ namespace node { bool PriorBoxClustered::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { - const auto priorBox = std::dynamic_pointer_cast(op); + const auto priorBox = ov::as_type_ptr(op); if (!priorBox) { errorMessage = "Only opset1 PriorBoxClustered operation is supported"; return false; @@ -38,7 +38,7 @@ PriorBoxClustered::PriorBoxClustered(const std::shared_ptr& op, const OPENVINO_THROW_NOT_IMPLEMENTED(errorMessage); } - const auto priorBox = std::dynamic_pointer_cast(op); + const auto priorBox = ov::as_type_ptr(op); const ov::opset1::PriorBoxClustered::Attributes& attrs = priorBox->get_attrs(); widths = attrs.widths; diff --git a/src/plugins/intel_cpu/src/nodes/proposal.cpp b/src/plugins/intel_cpu/src/nodes/proposal.cpp index b250faf3c96a72..722a997f9a429c 100644 --- a/src/plugins/intel_cpu/src/nodes/proposal.cpp +++ b/src/plugins/intel_cpu/src/nodes/proposal.cpp @@ -81,7 +81,7 @@ bool Proposal::isSupportedOperation(const std::shared_ptr& op, s errorMessage = "Node is not an instance of the Proposal from the operations set v0 or v4."; return false; } - auto proposalOp = std::dynamic_pointer_cast(op); + auto proposalOp = ov::as_type_ptr(op); if (proposalOp->get_attrs().framework != "tensorflow" && !proposalOp->get_attrs().framework.empty()) { errorMessage = "Unsupported framework attribute: " + proposalOp->get_attrs().framework; return false; @@ -99,7 +99,7 @@ Proposal::Proposal(const std::shared_ptr& op, const GraphContext::CPtr OPENVINO_THROW_NOT_IMPLEMENTED(errorMessage); } - auto proposalOp = std::dynamic_pointer_cast(op); + auto proposalOp = ov::as_type_ptr(op); auto proposalAttrs = proposalOp->get_attrs(); conf.feat_stride_ = proposalAttrs.feat_stride; diff --git a/src/plugins/intel_cpu/src/nodes/psroi_pooling.cpp b/src/plugins/intel_cpu/src/nodes/psroi_pooling.cpp index c42389443c5d2a..1b42d0f0cbc2b0 100644 --- a/src/plugins/intel_cpu/src/nodes/psroi_pooling.cpp +++ b/src/plugins/intel_cpu/src/nodes/psroi_pooling.cpp @@ -32,8 +32,8 @@ bool PSROIPooling::isSupportedOperation(const std::shared_ptr& o errorMessage = "Doesn't support op with dynamic shapes"; return false; } - const auto psroi = std::dynamic_pointer_cast(op); - const auto defPsroi = std::dynamic_pointer_cast(op); + const auto psroi = ov::as_type_ptr(op); + const auto defPsroi = ov::as_type_ptr(op); if (!psroi && !defPsroi) { errorMessage = "Only opset1 PSROIPooling and DeformablePSROIPooling operations are supported"; return false; @@ -68,8 +68,8 @@ PSROIPooling::PSROIPooling(const std::shared_ptr& op, const GraphConte errorPrefix = std::string(op->get_type_name()) + " node with name '" + op->get_friendly_name() + "'"; - const auto psroi = std::dynamic_pointer_cast(op); - const auto defPsroi = std::dynamic_pointer_cast(op); + const auto psroi = ov::as_type_ptr(op); + const auto defPsroi = ov::as_type_ptr(op); noTrans = op->get_input_size() == 2; if (op->get_input_shape(0).size() != 4) diff --git a/src/plugins/intel_cpu/src/nodes/qkv_proj.cpp b/src/plugins/intel_cpu/src/nodes/qkv_proj.cpp index 60187445d628d5..73cc613e86a802 100644 --- a/src/plugins/intel_cpu/src/nodes/qkv_proj.cpp +++ b/src/plugins/intel_cpu/src/nodes/qkv_proj.cpp @@ -346,7 +346,7 @@ QKVProjection::QKVProjection(const std::shared_ptr& op, const GraphCon if (!isSupportedOperation(op, errorMessage, concurrency, config.fcDynamicQuantizationGroupSize)) { OPENVINO_THROW("CPU: " + errorMessage); } - const auto node = std::dynamic_pointer_cast(op); + const auto node = ov::as_type_ptr(op); m_config = node->get_config(); } @@ -424,7 +424,7 @@ bool QKVProjection::isSupportedOperation(const std::shared_ptr& uint64_t fcDynamicQuantizationGroupSize) noexcept { #if defined(OPENVINO_ARCH_X86_64) try { - const auto node_qkv = std::dynamic_pointer_cast(op); + const auto node_qkv = ov::as_type_ptr(op); if (node_qkv) { if (concurrency > 0) { if (concurrency < 3) { diff --git a/src/plugins/intel_cpu/src/nodes/reduce.cpp b/src/plugins/intel_cpu/src/nodes/reduce.cpp index 7d710d33f41f93..a8165b0226b262 100644 --- a/src/plugins/intel_cpu/src/nodes/reduce.cpp +++ b/src/plugins/intel_cpu/src/nodes/reduce.cpp @@ -1923,23 +1923,23 @@ Reduce::getInitializers() { bool Reduce::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { - if (std::dynamic_pointer_cast(op) == nullptr && - std::dynamic_pointer_cast(op) == nullptr) { + if (ov::as_type_ptr(op) == nullptr && + ov::as_type_ptr(op) == nullptr) { errorMessage = "Reduce node with name " + op->get_friendly_name() + " is not derived from ArithmeticReductionKeepDims or LogicalReductionKeepDims"; return false; } - if (const auto reduce = std::dynamic_pointer_cast(op)) { - auto reduceConst = std::dynamic_pointer_cast( - reduce->get_input_node_shared_ptr(REDUCE_INDEXES)); + if (const auto reduce = ov::as_type_ptr(op)) { + auto reduceConst = + ov::as_type_ptr(reduce->get_input_node_shared_ptr(REDUCE_INDEXES)); if (!reduceConst) { errorMessage = "Second tensor is not constant"; return false; } } - if (const auto reduce = std::dynamic_pointer_cast(op)) { - auto reduceConst = std::dynamic_pointer_cast( - reduce->get_input_node_shared_ptr(REDUCE_INDEXES)); + if (const auto reduce = ov::as_type_ptr(op)) { + auto reduceConst = + ov::as_type_ptr(reduce->get_input_node_shared_ptr(REDUCE_INDEXES)); if (!reduceConst) { errorMessage = "Second tensor is not constant"; return false; @@ -1949,7 +1949,7 @@ bool Reduce::isSupportedOperation(const std::shared_ptr& op, std errorMessage = "Doesn't support Reduce algorithm: " + std::string(op->get_type_info().name); return false; } - if (std::dynamic_pointer_cast(op->get_input_node_shared_ptr(REDUCE_INDEXES)) == nullptr) { + if (ov::as_type_ptr(op->get_input_node_shared_ptr(REDUCE_INDEXES)) == nullptr) { errorMessage = "Only const 'reduce_indexes' input is supported"; return false; } @@ -1965,17 +1965,17 @@ Reduce::Reduce(const std::shared_ptr& op, const GraphContext::CPtr con if (isSupportedOperation(op, errorMessage)) { errorPrefix = "Reduce node with name '" + getName() + "'"; getInitializers().at(op->get_type_info())(op, *this); - if (const auto reduce = std::dynamic_pointer_cast(op)) { + if (const auto reduce = ov::as_type_ptr(op)) { keep_dims = reduce->get_keep_dims(); - auto reduceConst = std::dynamic_pointer_cast( - reduce->get_input_node_shared_ptr(REDUCE_INDEXES)); + auto reduceConst = + ov::as_type_ptr(reduce->get_input_node_shared_ptr(REDUCE_INDEXES)); if (!reduceConst) OPENVINO_THROW(errorPrefix, " second tensor is not constant!"); raw_axes = reduceConst->cast_vector(); - } else if (const auto reduce = std::dynamic_pointer_cast(op)) { + } else if (const auto reduce = ov::as_type_ptr(op)) { keep_dims = reduce->get_keep_dims(); - auto reduceConst = std::dynamic_pointer_cast( - reduce->get_input_node_shared_ptr(REDUCE_INDEXES)); + auto reduceConst = + ov::as_type_ptr(reduce->get_input_node_shared_ptr(REDUCE_INDEXES)); if (!reduceConst) OPENVINO_THROW(errorPrefix, " second tensor is not constant!"); raw_axes = reduceConst->cast_vector(); diff --git a/src/plugins/intel_cpu/src/nodes/region_yolo.cpp b/src/plugins/intel_cpu/src/nodes/region_yolo.cpp index 13d9ae01341aea..43c281c669ada0 100644 --- a/src/plugins/intel_cpu/src/nodes/region_yolo.cpp +++ b/src/plugins/intel_cpu/src/nodes/region_yolo.cpp @@ -243,7 +243,7 @@ struct jit_uni_logistic_kernel_f32 : public jit_uni_logistic_kernel, public jit_ bool RegionYolo::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { - const auto regionYolo = std::dynamic_pointer_cast(op); + const auto regionYolo = ov::as_type_ptr(op); if (!regionYolo) { errorMessage = "Only opset1 RegionYolo operation is supported"; return false; @@ -269,7 +269,7 @@ RegionYolo::RegionYolo(const std::shared_ptr& op, const GraphContext:: if (op->get_input_size() != 1 || op->get_output_size() != 1) OPENVINO_THROW(errorPrefix, " has incorrect number of input/output edges!"); - const auto regionYolo = std::dynamic_pointer_cast(op); + const auto regionYolo = ov::as_type_ptr(op); classes = regionYolo->get_num_classes(); coords = regionYolo->get_num_coords(); num = regionYolo->get_num_regions(); diff --git a/src/plugins/intel_cpu/src/nodes/reorg_yolo.cpp b/src/plugins/intel_cpu/src/nodes/reorg_yolo.cpp index 7e4f7c218cafd8..63b4e2985ff12c 100644 --- a/src/plugins/intel_cpu/src/nodes/reorg_yolo.cpp +++ b/src/plugins/intel_cpu/src/nodes/reorg_yolo.cpp @@ -15,7 +15,7 @@ namespace node { bool ReorgYolo::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { - const auto reorgYolo = std::dynamic_pointer_cast(op); + const auto reorgYolo = ov::as_type_ptr(op); if (!reorgYolo) { errorMessage = "Only opset2 ReorgYolo operation is supported"; return false; @@ -37,7 +37,7 @@ ReorgYolo::ReorgYolo(const std::shared_ptr& op, const GraphContext::CP if (getOriginalInputsNumber() != 1 || getOriginalOutputsNumber() != 1) OPENVINO_THROW(errorPrefix, " has incorrect number of input/output edges!"); - const auto reorgYolo = std::dynamic_pointer_cast(op); + const auto reorgYolo = ov::as_type_ptr(op); const auto strides = reorgYolo->get_strides(); if (strides.empty()) OPENVINO_THROW(errorPrefix, " has empty strides"); diff --git a/src/plugins/intel_cpu/src/nodes/reshape.cpp b/src/plugins/intel_cpu/src/nodes/reshape.cpp index 754c0e0050974c..6189a888153d9f 100644 --- a/src/plugins/intel_cpu/src/nodes/reshape.cpp +++ b/src/plugins/intel_cpu/src/nodes/reshape.cpp @@ -19,9 +19,8 @@ namespace node { bool Reshape::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { - if (!std::dynamic_pointer_cast(op) && - !std::dynamic_pointer_cast(op) && - !std::dynamic_pointer_cast(op)) { + if (!ov::as_type_ptr(op) && !ov::as_type_ptr(op) && + !ov::as_type_ptr(op)) { errorMessage = "Only opset1 Reshape, Squeeze, Unsqueeze operations are supported"; return false; } @@ -47,13 +46,13 @@ Reshape::Reshape(const std::shared_ptr& op, const GraphContext::CPtr c } }; - if (std::dynamic_pointer_cast(op)) { + if (ov::as_type_ptr(op)) { checkSecondInput(op, "Reshape"); - } else if (std::dynamic_pointer_cast(op)) { + } else if (ov::as_type_ptr(op)) { if (op->get_input_size() == 1) OPENVINO_THROW("CPU plug-in doesn't support Squeeze node with inputs num equal 1"); checkSecondInput(op, "Squeeze"); - } else if (std::dynamic_pointer_cast(op)) { + } else if (ov::as_type_ptr(op)) { checkSecondInput(op, "Unsqueeze"); } else { OPENVINO_THROW("Unsupported operation type via reshape node"); diff --git a/src/plugins/intel_cpu/src/nodes/reverse_sequence.cpp b/src/plugins/intel_cpu/src/nodes/reverse_sequence.cpp index 3c47550f7d8526..41f7c88f69d0c1 100644 --- a/src/plugins/intel_cpu/src/nodes/reverse_sequence.cpp +++ b/src/plugins/intel_cpu/src/nodes/reverse_sequence.cpp @@ -17,7 +17,7 @@ namespace node { bool ReverseSequence::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { - const auto revSeq = std::dynamic_pointer_cast(op); + const auto revSeq = ov::as_type_ptr(op); if (!revSeq) { errorMessage = "Only opset1 ReverseSequence operation is supported"; return false; @@ -36,7 +36,7 @@ ReverseSequence::ReverseSequence(const std::shared_ptr& op, const Grap } errorPrefix = "ReverseSequence layer with name '" + op->get_friendly_name() + "'"; - const auto revSeq = std::dynamic_pointer_cast(op); + const auto revSeq = ov::as_type_ptr(op); if (revSeq == nullptr) OPENVINO_THROW("Operation with name '", op->get_friendly_name(), diff --git a/src/plugins/intel_cpu/src/nodes/rms_norm.cpp b/src/plugins/intel_cpu/src/nodes/rms_norm.cpp index f494ad605c776e..b2eda6cf8dad6f 100644 --- a/src/plugins/intel_cpu/src/nodes/rms_norm.cpp +++ b/src/plugins/intel_cpu/src/nodes/rms_norm.cpp @@ -123,7 +123,7 @@ RMSNorm::RMSNorm(const std::shared_ptr& op, const GraphContext::CPtr c if (!isSupportedOperation(op, errorMessage)) { OPENVINO_THROW("CPU: " + errorMessage); } - const auto rms = std::dynamic_pointer_cast(op); + const auto rms = ov::as_type_ptr(op); m_eps = static_cast(rms->get_epsilon()); } @@ -185,7 +185,7 @@ void RMSNorm::execute(dnnl::stream strm) { bool RMSNorm::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { - const auto rms = std::dynamic_pointer_cast(op); + const auto rms = ov::as_type_ptr(op); if (rms) { if (!dnnl::impl::cpu::x64::mayiuse(dnnl::impl::cpu::x64::avx2)) { errorMessage = "RMSNorm needs avx2+."; diff --git a/src/plugins/intel_cpu/src/nodes/rnn.cpp b/src/plugins/intel_cpu/src/nodes/rnn.cpp index a35f82e0e4ab27..7f831ab02c66e3 100644 --- a/src/plugins/intel_cpu/src/nodes/rnn.cpp +++ b/src/plugins/intel_cpu/src/nodes/rnn.cpp @@ -480,7 +480,7 @@ RNN::RNN(const std::shared_ptr& op, const GraphContext::CPtr context) coIdx = 2; } - auto rnnCellBase = std::dynamic_pointer_cast(op); + auto rnnCellBase = ov::as_type_ptr(op); if (!rnnCellBase) THROW_CPU_NODE_ERR("does not have original layer for RNNCell."); diff --git a/src/plugins/intel_cpu/src/nodes/roll.cpp b/src/plugins/intel_cpu/src/nodes/roll.cpp index 4216d5f3f7ee42..2547b945bb56c3 100644 --- a/src/plugins/intel_cpu/src/nodes/roll.cpp +++ b/src/plugins/intel_cpu/src/nodes/roll.cpp @@ -23,7 +23,7 @@ namespace node { bool Roll::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { - const auto interp = std::dynamic_pointer_cast(op); + const auto interp = ov::as_type_ptr(op); if (!interp) { errorMessage = "Only opset7 Roll operation is supported"; return false; diff --git a/src/plugins/intel_cpu/src/nodes/rope.cpp b/src/plugins/intel_cpu/src/nodes/rope.cpp index ae01b04749c72d..90a9ab9d6f945f 100644 --- a/src/plugins/intel_cpu/src/nodes/rope.cpp +++ b/src/plugins/intel_cpu/src/nodes/rope.cpp @@ -28,7 +28,7 @@ RoPE::RoPE(const std::shared_ptr& op, const GraphContext::CPtr context OPENVINO_THROW("CPU: " + errorMessage); } - const auto node = std::dynamic_pointer_cast(op); + const auto node = ov::as_type_ptr(op); m_config = node->get_config(); } @@ -457,7 +457,7 @@ void RoPE::execute(dnnl::stream strm) { bool RoPE::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { - const auto node = std::dynamic_pointer_cast(op); + const auto node = ov::as_type_ptr(op); if (!node) { errorMessage = "Only RoPE operation is supported"; return false; diff --git a/src/plugins/intel_cpu/src/nodes/scaled_attn.cpp b/src/plugins/intel_cpu/src/nodes/scaled_attn.cpp index 4f69e6f3183e10..6b4308c6b807d4 100644 --- a/src/plugins/intel_cpu/src/nodes/scaled_attn.cpp +++ b/src/plugins/intel_cpu/src/nodes/scaled_attn.cpp @@ -1082,11 +1082,11 @@ ScaledDotProductAttention::ScaledDotProductAttention(const std::shared_ptr(op)) { + if (const auto node = ov::as_type_ptr(op)) { m_config.config.is_causal = node->get_causal(); - } else if (const auto node = std::dynamic_pointer_cast(op)) { + } else if (const auto node = ov::as_type_ptr(op)) { m_config.config = node->get_config(); - } else if (const auto node = std::dynamic_pointer_cast(op)) { + } else if (const auto node = ov::as_type_ptr(op)) { m_config.config = node->get_config(); } } @@ -1247,9 +1247,9 @@ void ScaledDotProductAttention::execute(dnnl::stream strm) { bool ScaledDotProductAttention::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { - auto sdpaWithTransposeReshapeOp = std::dynamic_pointer_cast(op); - if (!std::dynamic_pointer_cast(op) && - !std::dynamic_pointer_cast(op) && !sdpaWithTransposeReshapeOp) { + auto sdpaWithTransposeReshapeOp = ov::as_type_ptr(op); + if (!ov::as_type_ptr(op) && + !ov::as_type_ptr(op) && !sdpaWithTransposeReshapeOp) { errorMessage = "Only ScaledDotProductAttention, ScaledDotProductAttentionWithKVCache or " "SDPAWithTransposeReshape operation are supported"; return false; @@ -1270,7 +1270,7 @@ bool ScaledDotProductAttention::isSupportedOperation(const std::shared_ptr(op->get_input_size()); - const auto node = std::dynamic_pointer_cast(op); + const auto node = ov::as_type_ptr(op); if (node) { if (node->get_config().fuse_concat) { orgSDPAInput -= 3; diff --git a/src/plugins/intel_cpu/src/nodes/softmax.cpp b/src/plugins/intel_cpu/src/nodes/softmax.cpp index 982b41f40b2103..2d3b0a98fee9a9 100644 --- a/src/plugins/intel_cpu/src/nodes/softmax.cpp +++ b/src/plugins/intel_cpu/src/nodes/softmax.cpp @@ -58,7 +58,7 @@ bool SoftmaxKey::operator==(const SoftmaxKey& rhs) const { bool SoftMax::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { - if (!std::dynamic_pointer_cast(op)) { + if (!ov::as_type_ptr(op)) { errorMessage = "Only opset1 Softmax operation is supported"; return false; } diff --git a/src/plugins/intel_cpu/src/nodes/space_to_batch.cpp b/src/plugins/intel_cpu/src/nodes/space_to_batch.cpp index 5a882b4611d860..c2d28fa6eba5f9 100644 --- a/src/plugins/intel_cpu/src/nodes/space_to_batch.cpp +++ b/src/plugins/intel_cpu/src/nodes/space_to_batch.cpp @@ -14,7 +14,7 @@ namespace node { bool SpaceToBatch::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { - const auto spaceToBatch = std::dynamic_pointer_cast(op); + const auto spaceToBatch = ov::as_type_ptr(op); if (!spaceToBatch) { errorMessage = "Only opset2 SpaceToBatch operation is supported"; return false; diff --git a/src/plugins/intel_cpu/src/nodes/topk.cpp b/src/plugins/intel_cpu/src/nodes/topk.cpp index 9f85675bcb8407..673011c2c746c7 100644 --- a/src/plugins/intel_cpu/src/nodes/topk.cpp +++ b/src/plugins/intel_cpu/src/nodes/topk.cpp @@ -1863,8 +1863,7 @@ bool TopK::isSupportedOperation(const std::shared_ptr& op, std:: auto topKOp = ov::as_type_ptr(op); if (!isDynamicNgraphNode(op)) { - auto topKConst = - std::dynamic_pointer_cast(topKOp->get_input_node_shared_ptr(TOPK_K)); + auto topKConst = ov::as_type_ptr(topKOp->get_input_node_shared_ptr(TOPK_K)); if (!topKConst) { errorMessage = "Second tensor is not constant in static shape mode"; return false; @@ -1902,8 +1901,7 @@ TopK::TopK(const std::shared_ptr& op, const GraphContext::CPtr context auto in_dims_size = in_dims.size(); if (!isDynamicNgraphNode(op)) { - auto topKConst = - std::dynamic_pointer_cast(topKOp->get_input_node_shared_ptr(TOPK_K)); + auto topKConst = ov::as_type_ptr(topKOp->get_input_node_shared_ptr(TOPK_K)); if (!topKConst) { OPENVINO_THROW(errorPrefix, "gets non-constant second tensor in static shape mode!"); } diff --git a/src/plugins/intel_cpu/src/shape_inference/custom/scaled_attn.cpp b/src/plugins/intel_cpu/src/shape_inference/custom/scaled_attn.cpp index f7a25eb3cbbf7a..69153901c40ce2 100644 --- a/src/plugins/intel_cpu/src/shape_inference/custom/scaled_attn.cpp +++ b/src/plugins/intel_cpu/src/shape_inference/custom/scaled_attn.cpp @@ -71,7 +71,7 @@ class SDPAShapeInfer : public ShapeInferEmptyPads { }; ShapeInferPtr SDPAShapeInferFactory::makeShapeInfer() const { - if (auto sdpa = std::dynamic_pointer_cast(m_op)) { + if (auto sdpa = ov::as_type_ptr(m_op)) { const auto& config = sdpa->get_config(); if (config.output_BLHxS == false) return std::make_shared(config); diff --git a/src/plugins/intel_cpu/src/transformations/cpu_opset/arm/pass/convert_group_conv.cpp b/src/plugins/intel_cpu/src/transformations/cpu_opset/arm/pass/convert_group_conv.cpp index f63981078616d5..ca8f3bd6e9a309 100644 --- a/src/plugins/intel_cpu/src/transformations/cpu_opset/arm/pass/convert_group_conv.cpp +++ b/src/plugins/intel_cpu/src/transformations/cpu_opset/arm/pass/convert_group_conv.cpp @@ -14,7 +14,7 @@ ov::intel_cpu::ConvertGroupConvolution::ConvertGroupConvolution() { ov::matcher_pass_callback callback = [](ov::pass::pattern::Matcher& m) { enum Inputs { Data, Weights }; - auto gconv = std::dynamic_pointer_cast(m.get_match_root()); + auto gconv = ov::as_type_ptr(m.get_match_root()); if (!gconv) { return false; } diff --git a/src/plugins/intel_cpu/src/transformations/cpu_opset/arm/pass/convert_reduce_multi_axis.cpp b/src/plugins/intel_cpu/src/transformations/cpu_opset/arm/pass/convert_reduce_multi_axis.cpp index 287aad96b14c08..d2d451c3e12e7f 100644 --- a/src/plugins/intel_cpu/src/transformations/cpu_opset/arm/pass/convert_reduce_multi_axis.cpp +++ b/src/plugins/intel_cpu/src/transformations/cpu_opset/arm/pass/convert_reduce_multi_axis.cpp @@ -18,7 +18,7 @@ ov::matcher_pass_callback ov::intel_cpu::ConvertReduceMultiAxisBase::convert_red const auto& input0 = reduce->input_value(0); const auto& input1 = reduce->input_value(1); const auto& data_shape0 = input0.get_partial_shape(); - auto reduction_axes = std::dynamic_pointer_cast(input1.get_node_shared_ptr()); + auto reduction_axes = ov::as_type_ptr(input1.get_node_shared_ptr()); if (!reduction_axes) { return false; } diff --git a/src/plugins/intel_cpu/src/transformations/cpu_opset/arm/pass/mish_decomposition.cpp b/src/plugins/intel_cpu/src/transformations/cpu_opset/arm/pass/mish_decomposition.cpp index 338bb1820fa7f4..6b424af85215a9 100644 --- a/src/plugins/intel_cpu/src/transformations/cpu_opset/arm/pass/mish_decomposition.cpp +++ b/src/plugins/intel_cpu/src/transformations/cpu_opset/arm/pass/mish_decomposition.cpp @@ -10,7 +10,7 @@ ov::intel_cpu::MishDecomposition::MishDecomposition() { auto mish = ov::pass::pattern::wrap_type(); ov::matcher_pass_callback callback = [](ov::pass::pattern::Matcher& m) { - auto mish = std::dynamic_pointer_cast(m.get_match_root()); + auto mish = ov::as_type_ptr(m.get_match_root()); if (!mish) { return false; } @@ -31,4 +31,4 @@ ov::intel_cpu::MishDecomposition::MishDecomposition() { auto m = std::make_shared(mish, "MishDecomposition"); register_matcher(m, callback); -} \ No newline at end of file +} diff --git a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/align_matmul_input_ranks.cpp b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/align_matmul_input_ranks.cpp index e292ac5f5049c7..9f125d802dffba 100644 --- a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/align_matmul_input_ranks.cpp +++ b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/align_matmul_input_ranks.cpp @@ -22,7 +22,7 @@ ov::intel_cpu::AlignMatMulInputRanks::AlignMatMulInputRanks() { auto matmulPattern = ov::pass::pattern::wrap_type(twoInputs); ov::matcher_pass_callback callback = [this](ov::pass::pattern::Matcher& m) { - auto matmul = std::dynamic_pointer_cast(m.get_match_root()); + auto matmul = ov::as_type_ptr(m.get_match_root()); if (!matmul || transformation_callback(matmul)) return false; diff --git a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/causal_mask_preprocess_fusion.cpp b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/causal_mask_preprocess_fusion.cpp index 5f3058429a8497..551ddf95ba18d1 100644 --- a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/causal_mask_preprocess_fusion.cpp +++ b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/causal_mask_preprocess_fusion.cpp @@ -207,8 +207,7 @@ CausalMaskPreprocess::CausalMaskPreprocess() { ov::intel_cpu::CausalMaskPreprocessNode::Config config; config.type = "CausalMaskPreprocess"; - auto triu = - std::dynamic_pointer_cast(pattern_map.find(const_triu)->second.get_node_shared_ptr()); + auto triu = ov::as_type_ptr(pattern_map.find(const_triu)->second.get_node_shared_ptr()); auto triu_shape = triu->get_output_shape(0); if (triu_shape.size() != 4) diff --git a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/convert_broadcast_to_tiles.cpp b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/convert_broadcast_to_tiles.cpp index 8f3c3cc511ebe0..0582be3bbf735e 100644 --- a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/convert_broadcast_to_tiles.cpp +++ b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/convert_broadcast_to_tiles.cpp @@ -14,7 +14,7 @@ ov::intel_cpu::ConvertBroadcastToTiles::ConvertBroadcastToTiles() { auto broadcast = ov::pass::pattern::wrap_type(); ov::matcher_pass_callback callback = [this](ov::pass::pattern::Matcher& m) { - auto broadcast = std::dynamic_pointer_cast(m.get_match_root()); + auto broadcast = ov::as_type_ptr(m.get_match_root()); if (!broadcast) { return false; } @@ -24,10 +24,8 @@ ov::intel_cpu::ConvertBroadcastToTiles::ConvertBroadcastToTiles() { return false; } - auto shape_node = - std::dynamic_pointer_cast(broadcast->input_value(1).get_node_shared_ptr()); - auto axes_node = - std::dynamic_pointer_cast(broadcast->input_value(2).get_node_shared_ptr()); + auto shape_node = ov::as_type_ptr(broadcast->input_value(1).get_node_shared_ptr()); + auto axes_node = ov::as_type_ptr(broadcast->input_value(2).get_node_shared_ptr()); if (!shape_node || !axes_node) return false; diff --git a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/convert_fq_rnn_to_quantized_rnn.cpp b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/convert_fq_rnn_to_quantized_rnn.cpp index c93826092c4939..3ef8145cb424c0 100644 --- a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/convert_fq_rnn_to_quantized_rnn.cpp +++ b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/convert_fq_rnn_to_quantized_rnn.cpp @@ -170,10 +170,9 @@ ov::intel_cpu::ConvertFqRnnToQuantizedRnn::ConvertFqRnnToQuantizedRnn() { const auto& input_scale_output = pattern_map.at(input_scale_X); const auto& weights_scale_output = pattern_map.at(weights_scale_W); // extract constant values - const auto input_scale_constant = - std::dynamic_pointer_cast(input_scale_output.get_node_shared_ptr()); + const auto input_scale_constant = ov::as_type_ptr(input_scale_output.get_node_shared_ptr()); const auto weights_scale_constant = - std::dynamic_pointer_cast(weights_scale_output.get_node_shared_ptr()); + ov::as_type_ptr(weights_scale_output.get_node_shared_ptr()); if (!input_scale_constant || !weights_scale_constant) return false; @@ -201,7 +200,7 @@ ov::intel_cpu::ConvertFqRnnToQuantizedRnn::ConvertFqRnnToQuantizedRnn() { if (input_shift_it != pattern_map.end()) { const auto input_shift_constant = - std::dynamic_pointer_cast(input_shift_it->second.get_node_shared_ptr()); + ov::as_type_ptr(input_shift_it->second.get_node_shared_ptr()); const float* input_shift_ptr = input_shift_constant->get_data_ptr(); runtime_info["inputShift"] = *input_shift_ptr; } @@ -225,8 +224,7 @@ ov::intel_cpu::ConvertFqRnnToQuantizedRnn::ConvertFqRnnToQuantizedRnn() { std::shared_ptr multiply_input = new_convert; // dequantize with subtract if (subtract_it != pattern_map.end()) { - const auto subtract = - std::dynamic_pointer_cast(subtract_it->second.get_node_shared_ptr()); + const auto subtract = ov::as_type_ptr(subtract_it->second.get_node_shared_ptr()); multiply_input = subtract->clone_with_new_inputs({multiply_input, subtract->input_value(1)}); } diff --git a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/convert_matmul_to_fc.cpp b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/convert_matmul_to_fc.cpp index e23cc4af867b65..bf9fb16f8dab7c 100644 --- a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/convert_matmul_to_fc.cpp +++ b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/convert_matmul_to_fc.cpp @@ -27,7 +27,7 @@ ov::intel_cpu::ConvertMatMulToFC::ConvertMatMulToFC() { ov::matcher_pass_callback callback = [OV_CAPTURE_CPY_AND_THIS](ov::pass::pattern::Matcher& m) { const auto& pattern_map = m.get_pattern_value_map(); - auto matmul = std::dynamic_pointer_cast(pattern_map.at(matmul_m).get_node_shared_ptr()); + auto matmul = ov::as_type_ptr(pattern_map.at(matmul_m).get_node_shared_ptr()); if (!matmul || transformation_callback(matmul)) { return false; } @@ -37,7 +37,7 @@ ov::intel_cpu::ConvertMatMulToFC::ConvertMatMulToFC() { auto fc_input_a = pattern_map.at(activations_m); auto fc_input_b = pattern_map.at(weights_m); bool is_convert = false; - if (auto convert_node = std::dynamic_pointer_cast(fc_input_b.get_node_shared_ptr())) { + if (auto convert_node = ov::as_type_ptr(fc_input_b.get_node_shared_ptr())) { if (is_decompression(convert_node)) { is_convert = true; fc_input_b = convert_node->get_input_node_shared_ptr(0); diff --git a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/convert_tile_to_seq_tiles.cpp b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/convert_tile_to_seq_tiles.cpp index 783f15e0689419..ced4e2bcd07043 100644 --- a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/convert_tile_to_seq_tiles.cpp +++ b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/convert_tile_to_seq_tiles.cpp @@ -19,12 +19,12 @@ ov::intel_cpu::ConvertTileToSeqTiles::ConvertTileToSeqTiles() { ov::pass::pattern::wrap_type()}); ov::matcher_pass_callback callback = [](ov::pass::pattern::Matcher& m) { - auto tile = std::dynamic_pointer_cast(m.get_match_root()); + auto tile = ov::as_type_ptr(m.get_match_root()); if (!tile) { return false; } - auto tiles_node = std::dynamic_pointer_cast(tile->input_value(1).get_node_shared_ptr()); + auto tiles_node = ov::as_type_ptr(tile->input_value(1).get_node_shared_ptr()); if (!tiles_node) return false; @@ -48,7 +48,7 @@ ov::intel_cpu::ConvertTileToSeqTiles::ConvertTileToSeqTiles() { if (num_of_tile_dims == 0) { auto outputs = tile->get_output_target_inputs(0); for (const auto& out : outputs) { - if (std::dynamic_pointer_cast(out.get_node()->shared_from_this())) { + if (ov::as_type_ptr(out.get_node()->shared_from_this())) { return false; } } diff --git a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/convert_to_leaky_relu.cpp b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/convert_to_leaky_relu.cpp index c4e1bc79cfdc8a..703880ca2df356 100644 --- a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/convert_to_leaky_relu.cpp +++ b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/convert_to_leaky_relu.cpp @@ -17,11 +17,11 @@ ov::intel_cpu::ConvertToLeakyRelu::ConvertToLeakyRelu() { auto prelu = ov::pass::pattern::wrap_type({input, slope_constant}); ov::matcher_pass_callback callback = [](ov::pass::pattern::Matcher& m) { - auto prelu = std::dynamic_pointer_cast(m.get_match_root()); + auto prelu = ov::as_type_ptr(m.get_match_root()); if (!prelu) { return false; } - auto slopeNode = std::dynamic_pointer_cast(prelu->get_input_node_shared_ptr(1)); + auto slopeNode = ov::as_type_ptr(prelu->get_input_node_shared_ptr(1)); if (slopeNode != nullptr && ov::shape_size(slopeNode->get_shape()) == 1) { const float slope = slopeNode->cast_vector()[0]; const auto leakyRelu = std::make_shared(prelu->input(0).get_source_output(), diff --git a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/convert_to_power_static.cpp b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/convert_to_power_static.cpp index 74819b4153a0ab..83002c53c4a56d 100644 --- a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/convert_to_power_static.cpp +++ b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/convert_to_power_static.cpp @@ -20,8 +20,8 @@ namespace { int getConstPort(const std::shared_ptr& node) { - const auto const1 = std::dynamic_pointer_cast(node->get_input_node_shared_ptr(0)); - const auto const2 = std::dynamic_pointer_cast(node->get_input_node_shared_ptr(1)); + const auto const1 = ov::as_type_ptr(node->get_input_node_shared_ptr(0)); + const auto const2 = ov::as_type_ptr(node->get_input_node_shared_ptr(1)); int constPort = -1; if (const2) { constPort = 1; @@ -63,7 +63,7 @@ bool isConvertableToPowerStatic(const std::shared_ptr& node) auto input_rank = node->get_input_partial_shape(0).rank(); if (input_rank.is_dynamic()) return false; - auto const_node = std::dynamic_pointer_cast(node->get_input_node_shared_ptr(1)); + auto const_node = ov::as_type_ptr(node->get_input_node_shared_ptr(1)); return const_node && input_rank.get_length() >= static_cast(const_node->get_shape().size()) && ov::shape_size(const_node->get_shape()) == 1; @@ -74,7 +74,7 @@ std::shared_ptr convert(const std::shared_ptr& node) { const int constPort = getConstPort(node); const int nonConstPort = 1 - constPort; std::shared_ptr powerNode = - std::dynamic_pointer_cast(node->get_input_node_shared_ptr(constPort)); + ov::as_type_ptr(node->get_input_node_shared_ptr(constPort)); const float value = powerNode->cast_vector()[0]; if (std::is_same::value) { return std::make_shared(node->input(nonConstPort).get_source_output(), @@ -134,19 +134,19 @@ ov::intel_cpu::ConvertToPowerStatic::ConvertToPowerStatic() { auto node = m.get_match_root(); std::shared_ptr toReplace = node; - if (auto power = std::dynamic_pointer_cast(node)) { + if (auto power = ov::as_type_ptr(node)) { if (!isConvertableToPowerStatic(power)) return false; toReplace = convert(power); - } else if (auto add = std::dynamic_pointer_cast(node)) { + } else if (auto add = ov::as_type_ptr(node)) { if (!isConvertableToPowerStatic(add)) return false; toReplace = convert(add); - } else if (auto sub = std::dynamic_pointer_cast(node)) { + } else if (auto sub = ov::as_type_ptr(node)) { if (!isConvertableToPowerStatic(sub)) return false; toReplace = convert(sub); - } else if (auto mult = std::dynamic_pointer_cast(node)) { + } else if (auto mult = ov::as_type_ptr(node)) { if (!isConvertableToPowerStatic(mult)) return false; toReplace = convert(mult); diff --git a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/convert_to_swish_cpu.cpp b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/convert_to_swish_cpu.cpp index 00943581b873f7..4426b9df927666 100644 --- a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/convert_to_swish_cpu.cpp +++ b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/convert_to_swish_cpu.cpp @@ -15,13 +15,13 @@ ov::intel_cpu::ConvertToSwishCPU::ConvertToSwishCPU() { auto swish = ov::pass::pattern::wrap_type(); ov::matcher_pass_callback callback = [](ov::pass::pattern::Matcher& m) { - auto swish = std::dynamic_pointer_cast(m.get_match_root()); + auto swish = ov::as_type_ptr(m.get_match_root()); if (!swish) { return false; } float beta_value = 1.0; if (swish->input_values().size() == 2) { - auto beta = std::dynamic_pointer_cast(swish->get_input_node_shared_ptr(1)); + auto beta = ov::as_type_ptr(swish->get_input_node_shared_ptr(1)); if (!beta || ov::shape_size(swish->get_input_shape(1)) != 1) { return false; diff --git a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/decompose_integer_divide.cpp b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/decompose_integer_divide.cpp index 6e4eef050449df..feb6aa9eb09da8 100644 --- a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/decompose_integer_divide.cpp +++ b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/decompose_integer_divide.cpp @@ -13,7 +13,7 @@ DecomposeIntegerDivide::DecomposeIntegerDivide() { register_matcher(std::make_shared(ov::pass::pattern::wrap_type(), "DecomposeIntegerDivide"), [](ov::pass::pattern::Matcher& m) { - auto divide = std::dynamic_pointer_cast(m.get_match_root()); + auto divide = ov::as_type_ptr(m.get_match_root()); if (!divide) { return false; } diff --git a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/decompose_rms_norm.cpp b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/decompose_rms_norm.cpp index c952b28285d89d..eafddb759fdb3c 100644 --- a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/decompose_rms_norm.cpp +++ b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/decompose_rms_norm.cpp @@ -19,8 +19,7 @@ DecomposeRMSNorm::DecomposeRMSNorm() { matcher_pass_callback callback = [OV_CAPTURE_CPY_AND_THIS](ov::pass::pattern::Matcher& m) { auto& pattern_to_output = m.get_pattern_value_map(); - auto node = - std::dynamic_pointer_cast(pattern_to_output.at(pattern_node).get_node_shared_ptr()); + auto node = ov::as_type_ptr(pattern_to_output.at(pattern_node).get_node_shared_ptr()); if (node == nullptr || transformation_callback(node)) { return false; diff --git a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/stateful_sdpa_fusion.cpp b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/stateful_sdpa_fusion.cpp index 0a287a9692593b..291ef98f1a88c6 100644 --- a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/stateful_sdpa_fusion.cpp +++ b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/stateful_sdpa_fusion.cpp @@ -68,7 +68,7 @@ StatefulSDPAFusion::StatefulSDPAFusion() { auto unsqueeze_kv = makePattern({kv, any_input()}); auto check_one = [](Output output) -> bool { - auto node = std::dynamic_pointer_cast(output.get_node_shared_ptr()); + auto node = ov::as_type_ptr(output.get_node_shared_ptr()); const auto& bcst_arg = node->cast_vector(); return std::all_of(bcst_arg.begin(), bcst_arg.end(), [](float i) { return i == 1.0f; @@ -128,14 +128,14 @@ StatefulSDPAFusion::StatefulSDPAFusion() { auto present_to = out.get_target_inputs(); for (auto& to : present_to) { auto to_node = to.get_node(); - if (auto convert = dynamic_cast(to_node)) { + if (auto convert = ov::as_type(to_node)) { auto cvt_targets = convert->get_output_target_inputs(0); if (cvt_targets.size() == 1) { to_node = cvt_targets.begin()->get_node(); cvt = convert; } } - assign = dynamic_cast(to_node); + assign = ov::as_type(to_node); if (assign) return true; } diff --git a/src/plugins/intel_cpu/src/transformations/cpu_opset/x64/pass/qkv_proj_fusion.cpp b/src/plugins/intel_cpu/src/transformations/cpu_opset/x64/pass/qkv_proj_fusion.cpp index 59924aa220510d..91aadfc97ec3c2 100644 --- a/src/plugins/intel_cpu/src/transformations/cpu_opset/x64/pass/qkv_proj_fusion.cpp +++ b/src/plugins/intel_cpu/src/transformations/cpu_opset/x64/pass/qkv_proj_fusion.cpp @@ -72,7 +72,7 @@ ov::intel_cpu::QKVProjFusion::QKVProjFusion() { size_t hidden_size = 0; std::vector proj_size; for (auto& child : children) { - auto mm = dynamic_cast(child.get_node()); + auto mm = ov::as_type(child.get_node()); if (!mm) { // maybe a ShapeOf continue; @@ -279,4 +279,4 @@ ov::intel_cpu::QKVProjFusion2::QKVProjFusion2() { auto m = std::make_shared(result, matcher_name); this->register_matcher(m, callback); -} \ No newline at end of file +} diff --git a/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/snippets_mark_skipped.cpp b/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/snippets_mark_skipped.cpp index 6edefb47053e48..d410995f09e8c7 100644 --- a/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/snippets_mark_skipped.cpp +++ b/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/snippets_mark_skipped.cpp @@ -486,11 +486,11 @@ bool SnippetsMarkSkipped::run_on_model(const std::shared_ptr& m) { SetNodeFusingType(node, NodeFusingType::FusedWithBinaryConvolution); channelAxis = DEFAULT_AXIS; } else if (isSuitableReduceParent(node)) { - const auto reduce = std::dynamic_pointer_cast(node); + const auto reduce = ov::as_type_ptr(node); channelAxis = getChannelAxis(reduce->get_reduction_axes(), reduce->get_keep_dims()); SetNodeFusingType(node, NodeFusingType::FusedWithReduce); } else if (isSuitableMiscParent(node)) { - if (const auto reduce = std::dynamic_pointer_cast(node)) { + if (const auto reduce = ov::as_type_ptr(node)) { channelAxis = getChannelAxis(reduce->get_reduction_axes(), reduce->get_keep_dims()); } else { channelAxis = DEFAULT_AXIS; diff --git a/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp b/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp index dfa0315cbf1852..da61917a146db0 100644 --- a/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp +++ b/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp @@ -526,7 +526,7 @@ void Transformations::PreLpt(const std::vector& defaultPrecis CPU_SET_CALLBACK_COMMON( manager, [](const_node_ptr& node) -> bool { - const auto maxpool = std::dynamic_pointer_cast(node); + const auto maxpool = ov::as_type_ptr(node); return !maxpool || maxpool->get_rounding_type() == ov::op::RoundingType::CEIL_TORCH; }, ov::pass::ConvertMaxPool14ToMaxPool8); @@ -534,7 +534,7 @@ void Transformations::PreLpt(const std::vector& defaultPrecis CPU_SET_CALLBACK_COMMON( manager, [](const_node_ptr& node) -> bool { - const auto avgpool = std::dynamic_pointer_cast(node); + const auto avgpool = ov::as_type_ptr(node); return !avgpool || avgpool->get_rounding_type() == ov::op::RoundingType::CEIL_TORCH; }, ov::pass::ConvertAvgPool14ToAvgPool1); diff --git a/src/plugins/intel_cpu/src/utils/debug_capabilities.cpp b/src/plugins/intel_cpu/src/utils/debug_capabilities.cpp index 5ecadab2e5932d..2a85edb7701ee5 100644 --- a/src/plugins/intel_cpu/src/utils/debug_capabilities.cpp +++ b/src/plugins/intel_cpu/src/utils/debug_capabilities.cpp @@ -512,7 +512,7 @@ std::ostream& operator<<(std::ostream& os, const PrintableModel& model) { sep = ","; } - if (auto constop = std::dynamic_pointer_cast(op)) { + if (auto constop = ov::as_type_ptr(op)) { if (constop->get_element_type() == element::Type_t::f32) { os << printable(constop->get_vector()); } else if (constop->get_element_type() == element::Type_t::i8) { @@ -538,7 +538,7 @@ std::ostream& operator<<(std::ostream& os, const PrintableModel& model) { os << std::endl; // recursively output subgraphs - if (auto msubgraph = std::dynamic_pointer_cast(op)) { + if (auto msubgraph = ov::as_type_ptr(op)) { auto cnt = msubgraph->get_internal_subgraphs_size(); for (size_t i = 0; i < cnt; i++) { os << "\t\t MultiSubGraphOp " << tag << msubgraph->get_friendly_name() << "[" << i << "]" << std::endl; @@ -549,7 +549,7 @@ std::ostream& operator<<(std::ostream& os, const PrintableModel& model) { os << prefix << "}\n"; os << prefix << "fp16_compress disabled Ngraph nodes:\n"; for (const auto& op : f.get_ordered_ops()) { - if (ov::fp16_compression_is_disabled(op) && !std::dynamic_pointer_cast(op)) + if (ov::fp16_compression_is_disabled(op) && !ov::as_type_ptr(op)) os << "\t" << tag << op->get_friendly_name() << "\n"; } return os; diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/convolution.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/convolution.cpp index 207e522c32f823..b3c958a2c88a68 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/convolution.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/convolution.cpp @@ -123,7 +123,7 @@ std::shared_ptr ConvolutionLayerCPUTest::modifyGraph(const ov::element } std::vector secondParameterShapes; - if (auto parameter = dynamic_cast(opToShapeInfer->get_input_node_ptr(0))) { + if (auto parameter = ov::as_type(opToShapeInfer->get_input_node_ptr(0))) { parameter->set_partial_shape(targetShapes.front()); parameter->validate_and_infer_types(); } diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/embedding_bag_offsets.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/embedding_bag_offsets.cpp index 7a5099e945d63d..8b555afe99b44a 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/embedding_bag_offsets.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/embedding_bag_offsets.cpp @@ -79,7 +79,7 @@ class EmbeddingBagOffsetsLayerCPUTest : public testing::WithParamInterface(inType, inputShapes.first); ov::ParameterVector params = {emb_table_node}; - auto embBag = std::dynamic_pointer_cast( + auto embBag = ov::as_type_ptr( ov::test::utils::make_embedding_bag_offsets(inType, indPrecision, emb_table_node, diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/embedding_bag_offsets_sum.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/embedding_bag_offsets_sum.cpp index 463bc9396f58e8..700ff364d6b4fa 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/embedding_bag_offsets_sum.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/embedding_bag_offsets_sum.cpp @@ -74,7 +74,7 @@ class EmbeddingBagOffsetsSumLayerCPUTest : public testing::WithParamInterface(inType, inputShapes.first); ov::ParameterVector params = {emb_table_node}; - auto embBag = std::dynamic_pointer_cast( + auto embBag = ov::as_type_ptr( ov::test::utils::make_embedding_bag_offsets_sum(inType, indPrecision, emb_table_node, diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/embedding_bag_packed.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/embedding_bag_packed.cpp index 33ffc6208f7494..574359b919fa74 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/embedding_bag_packed.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/embedding_bag_packed.cpp @@ -73,7 +73,7 @@ class EmbeddingBagPackedLayerCPUTest : public testing::WithParamInterface(inType, inputShapes.first); ov::ParameterVector params = {emb_table_node}; - auto embBag = std::dynamic_pointer_cast( + auto embBag = ov::as_type_ptr( ov::test::utils::make_embedding_bag_packed(inType, indPrecision, emb_table_node, diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/embedding_bag_packed_sum.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/embedding_bag_packed_sum.cpp index 365aa8d964843e..0db8586b3dc098 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/embedding_bag_packed_sum.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/embedding_bag_packed_sum.cpp @@ -67,7 +67,7 @@ class EmbeddingBagPackedSumLayerCPUTest : public testing::WithParamInterface(inType, inputShapes.first); ov::ParameterVector params = {emb_table_node}; - auto embBag = std::dynamic_pointer_cast( + auto embBag = ov::as_type_ptr( ov::test::utils::make_embedding_bag_packed_sum(inType, indPrecision, emb_table_node, indices, withWeights)); ov::ResultVector results{std::make_shared(embBag)}; function = std::make_shared(results, params, "embeddingBagPackedSum"); diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/embedding_segments_sum.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/embedding_segments_sum.cpp index 53b3b48b8fd279..f46bc3956029f0 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/embedding_segments_sum.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/embedding_segments_sum.cpp @@ -77,7 +77,7 @@ class EmbeddingSegmentsSumLayerCPUTest : public testing::WithParamInterface(inType, inputShapes.first); ov::ParameterVector params = {emb_table_node}; - auto embBag = std::dynamic_pointer_cast( + auto embBag = ov::as_type_ptr( ov::test::utils::make_embedding_segments_sum(inType, indPrecision, emb_table_node, diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/group_convolution.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/group_convolution.cpp index 1d3ad65c8ca6bd..64dcf20542c09d 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/group_convolution.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/group_convolution.cpp @@ -142,7 +142,7 @@ class GroupConvolutionLayerCPUTest : public testing::WithParamInterface secondParameterShapes; - if (auto parameter = dynamic_cast(opToShapeInfer->get_input_node_ptr(0))) { + if (auto parameter = ov::as_type(opToShapeInfer->get_input_node_ptr(0))) { parameter->set_partial_shape(targetShapes.front()); parameter->validate_and_infer_types(); } diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/slice.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/slice.cpp index ed8cc30b91efcb..9d6f247fb50350 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/slice.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/slice.cpp @@ -121,14 +121,14 @@ class Slice8LayerCPUTest : public testing::WithParamInterface(ov::element::i64, ov::Shape{sliceParams.step.size()}); - params.push_back(std::dynamic_pointer_cast(startNode)); - params.push_back(std::dynamic_pointer_cast(stopdNode)); - params.push_back(std::dynamic_pointer_cast(stepNode)); + params.push_back(ov::as_type_ptr(startNode)); + params.push_back(ov::as_type_ptr(stopdNode)); + params.push_back(ov::as_type_ptr(stepNode)); if (!sliceParams.axes.empty()) { // With axes parameter auto axesNode = std::make_shared(ov::element::i64, ov::Shape{sliceParams.axes.size()}); - params.push_back(std::dynamic_pointer_cast(axesNode)); + params.push_back(ov::as_type_ptr(axesNode)); sliceNode = std::make_shared(params[0], startNode, stopdNode, stepNode, axesNode); } else { // without axes parameter @@ -588,4 +588,4 @@ INSTANTIATE_TEST_SUITE_P(smoke_Slice8LayerDescriptorCPUTest, ::testing::ValuesIn(filterCPUSpecificParams({cpuParams_nChw8c}))), Slice8LayerDescriptorCPUTest::getTestCaseName); -} // namespace \ No newline at end of file +} // namespace diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/slice_scatter.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/slice_scatter.cpp index 7ad793e4ecd1d3..04676aa1b3462b 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/slice_scatter.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/slice_scatter.cpp @@ -123,14 +123,14 @@ class SliceScatterLayerCPUTest : public testing::WithParamInterface(ov::element::i64, ov::Shape{sliceParams.step.size()}); - params.push_back(std::dynamic_pointer_cast(startNode)); - params.push_back(std::dynamic_pointer_cast(stopdNode)); - params.push_back(std::dynamic_pointer_cast(stepNode)); + params.push_back(ov::as_type_ptr(startNode)); + params.push_back(ov::as_type_ptr(stopdNode)); + params.push_back(ov::as_type_ptr(stepNode)); if (!sliceParams.axes.empty()) { // With axes parameter auto axesNode = std::make_shared(ov::element::i64, ov::Shape{sliceParams.axes.size()}); - params.push_back(std::dynamic_pointer_cast(axesNode)); + params.push_back(ov::as_type_ptr(axesNode)); sliceNode = std::make_shared(params[0], params[1], startNode, diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/topk.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/topk.cpp index 443b75d79a27ca..9fdf819001e634 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/topk.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/topk.cpp @@ -120,12 +120,12 @@ class TopKLayerCPUTest : public testing::WithParamInterface topk; if (staticShape) { auto k = std::make_shared(ElementType::i64, ov::Shape{}, &keepK); - topk = std::dynamic_pointer_cast( + topk = ov::as_type_ptr( std::make_shared(params[0], k, axis, mode, sort, ElementType::i32, stable)); } else { auto k = std::make_shared(ElementType::i64, inputDynamicShapes[1]); params.push_back(k); - topk = std::dynamic_pointer_cast( + topk = ov::as_type_ptr( std::make_shared(params[0], k, axis, mode, sort, ElementType::i32, stable)); } @@ -409,4 +409,4 @@ INSTANTIATE_TEST_SUITE_P( ::testing::ValuesIn(additionalConfig)), TopKLayerCPUTest::getTestCaseName); -} // namespace \ No newline at end of file +} // namespace diff --git a/src/plugins/intel_cpu/tests/functional/utils/fusing_test_utils.hpp b/src/plugins/intel_cpu/tests/functional/utils/fusing_test_utils.hpp index 2923e8ab9b6ddc..2641d8b00d83a8 100644 --- a/src/plugins/intel_cpu/tests/functional/utils/fusing_test_utils.hpp +++ b/src/plugins/intel_cpu/tests/functional/utils/fusing_test_utils.hpp @@ -113,11 +113,11 @@ static int getChannelAxis(const ov::AxisSet &axes, bool keep_dims) { } static int getFusingAxis(const std::shared_ptr& node) { - if (std::dynamic_pointer_cast(node)) { + if (ov::as_type_ptr(node)) { return node->get_output_partial_shape(0).size() - 1; // last dimension - } else if (const auto reduce = std::dynamic_pointer_cast(node)) { + } else if (const auto reduce = ov::as_type_ptr(node)) { return getChannelAxis(reduce->get_reduction_axes(), reduce->get_keep_dims()); - } else if (const auto reduce = std::dynamic_pointer_cast(node)) { + } else if (const auto reduce = ov::as_type_ptr(node)) { return getChannelAxis(reduce->get_reduction_axes(), reduce->get_keep_dims()); } else { return 1; // second dimension diff --git a/src/plugins/intel_cpu/tests/unit/snippets_transformations/x64/fake_quantize_tokenization_test.cpp b/src/plugins/intel_cpu/tests/unit/snippets_transformations/x64/fake_quantize_tokenization_test.cpp index 82abe426d9ab72..999e48db61b1c8 100644 --- a/src/plugins/intel_cpu/tests/unit/snippets_transformations/x64/fake_quantize_tokenization_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/snippets_transformations/x64/fake_quantize_tokenization_test.cpp @@ -33,10 +33,10 @@ class FakeQuantizeTokenizationTest : public TransformationTestsF { TransformationTestsF::TearDown(); auto subgraph = FunctionHelper::getSubgraph(model); - auto body = subgraph == nullptr ? nullptr : std::dynamic_pointer_cast(subgraph)->body_ptr(); + auto body = subgraph == nullptr ? nullptr : ov::as_type_ptr(subgraph)->body_ptr(); auto subgraph_ref = FunctionHelper::getSubgraph(model_ref); - auto body_ref = subgraph_ref == nullptr ? nullptr : std::dynamic_pointer_cast(subgraph_ref)->body_ptr(); + auto body_ref = subgraph_ref == nullptr ? nullptr : ov::as_type_ptr(subgraph_ref)->body_ptr(); if ((body != nullptr) && (body_ref != nullptr)) { auto res = comparator.compare(body, body_ref); @@ -106,4 +106,4 @@ TEST_F(FakeQuantizeTokenizationTest, smoke_Snippets_ConvolutionWithFakeQuantize) } // namespace snippets } // namespace test -} // namespace ov \ No newline at end of file +} // namespace ov diff --git a/src/plugins/template/backend/int_executable.cpp b/src/plugins/template/backend/int_executable.cpp index befc70438c1204..55ecf6b37baecc 100644 --- a/src/plugins/template/backend/int_executable.cpp +++ b/src/plugins/template/backend/int_executable.cpp @@ -56,7 +56,7 @@ void ov::runtime::interpreter::INTExecutable::cancel() { void collect_variables(const ov::NodeVector& nodes, ov::op::util::VariableContext& variable_context) { for (const auto& op : nodes) { - if (auto multi_subgraph_op = std::dynamic_pointer_cast(op)) { + if (auto multi_subgraph_op = ov::as_type_ptr(op)) { for (const auto& sub_graph : multi_subgraph_op->get_functions()) { collect_variables(sub_graph->get_ordered_ops(), variable_context); } @@ -118,7 +118,7 @@ bool ov::runtime::interpreter::INTExecutable::call(std::vector& outp // for each ordered op in the graph for (const auto& op : m_nodes) { CHECK_TERMINATE() - if (std::dynamic_pointer_cast(op)) { + if (ov::as_type_ptr(op)) { continue; } // get op inputs from map diff --git a/src/plugins/template/backend/ops/string_tensor_pack.cpp b/src/plugins/template/backend/ops/string_tensor_pack.cpp index 019efb1a0c541f..0e20d46c92b22a 100644 --- a/src/plugins/template/backend/ops/string_tensor_pack.cpp +++ b/src/plugins/template/backend/ops/string_tensor_pack.cpp @@ -11,7 +11,7 @@ template <> bool evaluate_node(std::shared_ptr node, ov::TensorVector& outputs, const ov::TensorVector& inputs) { - auto string_tensor_pack = std::dynamic_pointer_cast(node); + auto string_tensor_pack = ov::as_type_ptr(node); OPENVINO_ASSERT(string_tensor_pack, "Node passed to StringTensorPack evaluate function is invalid."); ov::Shape output_shape; output_shape = ov::op::v15::shape_infer(string_tensor_pack.get(), diff --git a/src/plugins/template/backend/ops/string_tensor_unpack.cpp b/src/plugins/template/backend/ops/string_tensor_unpack.cpp index 06d80d049a1643..dd9131a7790a76 100644 --- a/src/plugins/template/backend/ops/string_tensor_unpack.cpp +++ b/src/plugins/template/backend/ops/string_tensor_unpack.cpp @@ -12,7 +12,7 @@ bool evaluate_node(std::shared_ptr no ov::TensorVector& outputs, const ov::TensorVector& inputs) { if (node->get_input_element_type(0) == ov::element::string) { - auto string_tensor_unpack = std::dynamic_pointer_cast(node); + auto string_tensor_unpack = ov::as_type_ptr(node); OPENVINO_ASSERT(string_tensor_unpack, "Node passed to StringTensorUnpack evaluate function is invalid."); std::vector output_shapes; output_shapes = ov::op::v15::shape_infer(string_tensor_unpack.get(), diff --git a/src/plugins/template/backend/ops/unique.cpp b/src/plugins/template/backend/ops/unique.cpp index d868d82b9b82d5..7f31b0a89e1b32 100644 --- a/src/plugins/template/backend/ops/unique.cpp +++ b/src/plugins/template/backend/ops/unique.cpp @@ -13,8 +13,7 @@ void execute_unique(ov::TensorVector& outputs, const auto maybe_extract_axis = [&op]() { std::unique_ptr axis; if (op->get_input_size() == 2 && ov::op::util::is_constant(op->input_value(1).get_node())) { - const auto axis_constant = - std::dynamic_pointer_cast(op->input_value(1).get_node_shared_ptr()); + const auto axis_constant = ov::as_type_ptr(op->input_value(1).get_node_shared_ptr()); const auto axis_vec = axis_constant->cast_vector(); axis = std::unique_ptr(new int64_t{axis_vec.at(0)}); } diff --git a/src/plugins/template/src/sync_infer_request.cpp b/src/plugins/template/src/sync_infer_request.cpp index ac36fd2e18729f..938a79c9c6a2cd 100644 --- a/src/plugins/template/src/sync_infer_request.cpp +++ b/src/plugins/template/src/sync_infer_request.cpp @@ -44,7 +44,7 @@ void collect_variables(const std::shared_ptr& ov_model, ov::op::util::VariableContext& variable_context, std::vector>& list_of_variables) { for (const auto& op : ov_model->get_ordered_ops()) { - if (auto multi_subgraph_op = std::dynamic_pointer_cast(op)) { + if (auto multi_subgraph_op = ov::as_type_ptr(op)) { for (const auto& sub_graph : multi_subgraph_op->get_functions()) { collect_variables(sub_graph, variable_context, list_of_variables); }