diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/data.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/data.hpp index 8a9a35b1e92fe9..a77a1246297d8e 100644 --- a/src/plugins/intel_gpu/include/intel_gpu/primitives/data.hpp +++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/data.hpp @@ -163,7 +163,7 @@ struct weightless_cache_manager { return ov::op::util::is_constant(node); }); OPENVINO_ASSERT(it != ops.end()); - mem_obj->transformed_constant = std::dynamic_pointer_cast(*it); + mem_obj->transformed_constant = ov::as_type_ptr(*it); OPENVINO_ASSERT(mem_obj->transformed_constant->get_element_type() == curr_dtype); } }; diff --git a/src/plugins/intel_gpu/src/plugin/ops/batch_to_space.cpp b/src/plugins/intel_gpu/src/plugin/ops/batch_to_space.cpp index 1527d8940d742b..656f92c4056344 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/batch_to_space.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/batch_to_space.cpp @@ -26,7 +26,7 @@ static void CreateBatchToSpaceOp(ProgramBuilder& p, const std::shared_ptr(op->get_input_node_shared_ptr(i)); + auto inConst = ov::as_type_ptr(op->get_input_node_shared_ptr(i)); bool is_const_input = (inConst != nullptr); OPENVINO_ASSERT((i == 1) || (i >= 2 && non_constant_input != is_const_input), @@ -45,7 +45,7 @@ static void CreateBatchToSpaceOp(ProgramBuilder& p, const std::shared_ptr(op->get_input_node_shared_ptr(i)); + auto inConst = ov::as_type_ptr(op->get_input_node_shared_ptr(i)); std::vector sizes = inConst->cast_vector(); int32_t default_size = i == 1 ? 1 : 0; diff --git a/src/plugins/intel_gpu/src/plugin/ops/broadcast.cpp b/src/plugins/intel_gpu/src/plugin/ops/broadcast.cpp index 4fda62fcb6d519..6c7fde15ef7c7f 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/broadcast.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/broadcast.cpp @@ -61,9 +61,9 @@ static void CreateCommonBroadcastOp(ProgramBuilder& p, const std::shared_ptr(op)) { + if (auto broadcast_v3 = ov::as_type_ptr(op)) { mode = broadcast_v3->get_broadcast_spec(); - } else if (auto broadcast_v1 = std::dynamic_pointer_cast(op)) { + } else if (auto broadcast_v1 = ov::as_type_ptr(op)) { switch (broadcast_v1->get_broadcast_spec().m_type) { case ov::op::AutoBroadcastType::NONE: mode = ov::op::BroadcastType::NONE; break; case ov::op::AutoBroadcastType::NUMPY: mode = ov::op::BroadcastType::NUMPY; break; @@ -98,7 +98,7 @@ static void CreateCommonBroadcastOp(ProgramBuilder& p, const std::shared_ptr& op) { validate_inputs_count(op, {2, 3}); if (op->get_broadcast_spec().m_type == ov::op::AutoBroadcastType::NONE && op->get_input_size() == 3) { - auto axis_mapping_node = std::dynamic_pointer_cast(op->get_input_node_shared_ptr(2)); + auto axis_mapping_node = ov::as_type_ptr(op->get_input_node_shared_ptr(2)); OPENVINO_ASSERT(axis_mapping_node != nullptr, "[GPU] Unsupported parameter nodes type in ", op->get_friendly_name(), " (", op->get_type_name(), ")"); auto axis_mapping = axis_mapping_node->get_axis_set_val(); @@ -113,7 +113,7 @@ static void CreateBroadcastOp(ProgramBuilder& p, const std::shared_ptrget_input_size() == 3) { - auto axis_mapping_node = std::dynamic_pointer_cast(op->get_input_node_shared_ptr(2)); + auto axis_mapping_node = ov::as_type_ptr(op->get_input_node_shared_ptr(2)); OPENVINO_ASSERT(axis_mapping_node != nullptr, "[GPU] Unsupported parameter nodes type in ", op->get_friendly_name(), " (", op->get_type_name(), ")"); axis_mapping = axis_mapping_node->get_axis_set_val(); diff --git a/src/plugins/intel_gpu/src/plugin/ops/constant.cpp b/src/plugins/intel_gpu/src/plugin/ops/constant.cpp index a947bdf585125b..defabd18c1af93 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/constant.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/constant.cpp @@ -124,7 +124,7 @@ static void create_data(ProgramBuilder& p, const ov::Shape& const_shape, const s } static bool is_btiwise(Node* node) { - return dynamic_cast(node) != nullptr; + return ov::as_type(node) != nullptr; } static void CreateConstantOp(ProgramBuilder& p, const std::shared_ptr& op) { @@ -185,7 +185,7 @@ static void CreateConstantOp(ProgramBuilder& p, const std::shared_ptr(outOp)) { + if (auto castedOp = ov::as_type(outOp)) { if (castedOp->get_axis() == 0) { consts[op].needsBatchInterpretation = constDims.size() == 1; } diff --git a/src/plugins/intel_gpu/src/plugin/ops/convolution.cpp b/src/plugins/intel_gpu/src/plugin/ops/convolution.cpp index e0d51f28227679..72148f02ab0c62 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/convolution.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/convolution.cpp @@ -163,7 +163,7 @@ static void CreateConvolutionBackpropDataOp(ProgramBuilder& p, const std::shared output_padding, weights_have_group_dim); if (op->get_input_size() == 3) { - auto output_shape_constant = std::dynamic_pointer_cast(op->get_input_node_shared_ptr(2)); + auto output_shape_constant = ov::as_type_ptr(op->get_input_node_shared_ptr(2)); if (output_shape_constant) { auto output_shape = output_shape_constant->cast_vector(); ov::Shape shape(output_shape.begin(), output_shape.end()); @@ -253,7 +253,7 @@ static void CreateGroupConvolutionBackpropDataOp(ProgramBuilder& p, const std::s output_padding, weights_have_group_dim); if (op->get_input_size() == 3) { - auto output_shape_constant = std::dynamic_pointer_cast(op->get_input_node_shared_ptr(2)); + auto output_shape_constant = ov::as_type_ptr(op->get_input_node_shared_ptr(2)); if (output_shape_constant) { auto output_shape = output_shape_constant->cast_vector(); ov::Shape shape(output_shape.begin(), output_shape.end()); diff --git a/src/plugins/intel_gpu/src/plugin/ops/ctc_greedy_decoder.cpp b/src/plugins/intel_gpu/src/plugin/ops/ctc_greedy_decoder.cpp index 5f199c78d916c5..1a962bca895dba 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/ctc_greedy_decoder.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/ctc_greedy_decoder.cpp @@ -46,7 +46,7 @@ static void CreateCommonCTCGreedyDecoderOp(ProgramBuilder& p, const std::shared_ if (p.use_new_shape_infer()) { uint32_t blank_index = UINT32_MAX; if (reordered_inputs.size() == 3) { - auto blank_index_node = std::dynamic_pointer_cast(op->get_input_node_shared_ptr(2)); + auto blank_index_node = ov::as_type_ptr(op->get_input_node_shared_ptr(2)); if (!blank_index_node) { OPENVINO_THROW("Unsupported blank_index node type in ", op->get_friendly_name(), " (", op->get_type_name(), ")"); } @@ -70,7 +70,7 @@ static void CreateCommonCTCGreedyDecoderOp(ProgramBuilder& p, const std::shared_ } else { uint32_t blank_index = static_cast(op->get_input_shape(0).back() - 1); if (reordered_inputs.size() == 3) { - auto blank_index_node = std::dynamic_pointer_cast(op->get_input_node_shared_ptr(2)); + auto blank_index_node = ov::as_type_ptr(op->get_input_node_shared_ptr(2)); if (!blank_index_node) { OPENVINO_THROW("Unsupported blank_index node type in ", op->get_friendly_name(), " (", op->get_type_name(), ")"); } diff --git a/src/plugins/intel_gpu/src/plugin/ops/cum_sum.cpp b/src/plugins/intel_gpu/src/plugin/ops/cum_sum.cpp index 9d0078e3b2761c..f5aa326b78dbc7 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/cum_sum.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/cum_sum.cpp @@ -22,7 +22,7 @@ static void CreateCumSumOp(ProgramBuilder& p, const std::shared_ptrget_input_size() == 2) { - auto axes_constant = std::dynamic_pointer_cast(op->get_input_node_shared_ptr(1)); + auto axes_constant = ov::as_type_ptr(op->get_input_node_shared_ptr(1)); OPENVINO_ASSERT(axes_constant != nullptr, "[GPU] Unsupported parameter nodes type in ", op->get_friendly_name(), " (", op->get_type_name(), ")"); axis = axes_constant->cast_vector()[0]; } diff --git a/src/plugins/intel_gpu/src/plugin/ops/dft.cpp b/src/plugins/intel_gpu/src/plugin/ops/dft.cpp index 46a1a28b0a5cf8..708b24ef165680 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/dft.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/dft.cpp @@ -30,7 +30,7 @@ void createDft(ProgramBuilder& p, if (op->is_dynamic() && p.use_new_shape_infer()) { std::vector axes; - auto axes_constant = std::dynamic_pointer_cast(op->get_input_node_shared_ptr(1)); + auto axes_constant = ov::as_type_ptr(op->get_input_node_shared_ptr(1)); if (axes_constant != nullptr) { axes = axes_constant->cast_vector(); uint8_t axis_correction = static_cast(op->get_input_partial_shape(0).size()); @@ -42,7 +42,7 @@ void createDft(ProgramBuilder& p, if (op->get_input_size() == 3) { std::vector signal_size; - auto signal_size_constant = std::dynamic_pointer_cast(op->get_input_node_shared_ptr(2)); + auto signal_size_constant = ov::as_type_ptr(op->get_input_node_shared_ptr(2)); if (signal_size_constant != nullptr) { signal_size = signal_size_constant->cast_vector(); } @@ -56,7 +56,7 @@ void createDft(ProgramBuilder& p, } else { const auto& out_shape = op->get_output_shape(0); - auto axes_constant = std::dynamic_pointer_cast(op->get_input_node_shared_ptr(1)); + auto axes_constant = ov::as_type_ptr(op->get_input_node_shared_ptr(1)); OPENVINO_ASSERT(axes_constant != nullptr, "[GPU] Unsupported parameter nodes type in ", friendly_name, " (", op->get_type_name(), ")"); auto axes = axes_constant->cast_vector(); uint8_t axis_correction = static_cast(op->get_input_shape(0).size()); @@ -67,7 +67,7 @@ void createDft(ProgramBuilder& p, std::vector signal_size; if (op->get_input_size() == 3) { - auto signal_size_constant = std::dynamic_pointer_cast(op->get_input_node_shared_ptr(2)); + auto signal_size_constant = ov::as_type_ptr(op->get_input_node_shared_ptr(2)); OPENVINO_ASSERT(signal_size_constant != nullptr, "[GPU] Unsupported parameter nodes type in ", friendly_name, " (", op->get_type_name(), ")"); signal_size = signal_size_constant->cast_vector(); } diff --git a/src/plugins/intel_gpu/src/plugin/ops/eltwise.cpp b/src/plugins/intel_gpu/src/plugin/ops/eltwise.cpp index ad0eb26c6e1cc0..237638c7602c50 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/eltwise.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/eltwise.cpp @@ -166,7 +166,7 @@ static void CreateLogicalXorOp(ProgramBuilder& p, const std::shared_ptr& op) { validate_inputs_count(op, {2}); - auto power_node = std::dynamic_pointer_cast(op->get_input_node_shared_ptr(1)); + auto power_node = ov::as_type_ptr(op->get_input_node_shared_ptr(1)); if (power_node) { if (ov::shape_size(power_node->get_output_shape(0)) == 1) { float pow; diff --git a/src/plugins/intel_gpu/src/plugin/ops/embedding_bag.cpp b/src/plugins/intel_gpu/src/plugin/ops/embedding_bag.cpp index 74b9c1c0230c0f..0fe8d7211c4951 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/embedding_bag.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/embedding_bag.cpp @@ -24,7 +24,7 @@ static void CreateEmbeddingBagOffsetsSumOp(ProgramBuilder& p, const std::shared_ int32_t defaultIndex = -1; if (inputs.size() > 3) { - auto index_node = std::dynamic_pointer_cast(op->get_input_node_shared_ptr(3)); + auto index_node = ov::as_type_ptr(op->get_input_node_shared_ptr(3)); OPENVINO_ASSERT(index_node != nullptr, "[GPU] Unsupported parameter nodes type in ", op->get_friendly_name(), " (", op->get_type_name(), ")"); float val; @@ -110,7 +110,7 @@ static void CreateEmbeddingSegmentsSumOp(ProgramBuilder& p, const std::shared_pt int32_t defaultIndex = -1; // port of default_index is 4 by default, but we removed "num_segments" above, so now it's equal to 3 if (inputs.size() > 3) { - auto index_node = std::dynamic_pointer_cast(op->get_input_node_shared_ptr(4)); + auto index_node = ov::as_type_ptr(op->get_input_node_shared_ptr(4)); OPENVINO_ASSERT(index_node != nullptr, "[GPU] Unsupported parameter nodes type in ", op->get_friendly_name(), " (", op->get_type_name(), ")"); float val; diff --git a/src/plugins/intel_gpu/src/plugin/ops/eye.cpp b/src/plugins/intel_gpu/src/plugin/ops/eye.cpp index 82f82ecca41715..333b7ed5673e7e 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/eye.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/eye.cpp @@ -29,7 +29,7 @@ static void CreateEyeOp(ProgramBuilder& p, const std::shared_ptr 0 && j > 0; --i, --j) { dims[i - 1] = output_shapes[j - 1]; } - const ov::op::v0::Constant* constant = dynamic_cast(op->get_input_node_ptr(2)); + const ov::op::v0::Constant* constant = ov::as_type(op->get_input_node_ptr(2)); OPENVINO_ASSERT(constant != nullptr, "Unsupported parameter nodes type in ", op->get_friendly_name(), " (", op->get_type_name(), ")"); int32_t shift{}; diff --git a/src/plugins/intel_gpu/src/plugin/ops/fully_connected.cpp b/src/plugins/intel_gpu/src/plugin/ops/fully_connected.cpp index 5f4fe19c5c4c08..7e619503d34069 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/fully_connected.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/fully_connected.cpp @@ -44,7 +44,7 @@ static void CreateFullyConnectedCompressedOp(ProgramBuilder& p, const std::share float zp_value = 0.0f; bool has_scalar_zp = false; if (zp_name.size() > 0) { - auto zp_const = std::dynamic_pointer_cast(op->get_input_node_shared_ptr(W_ZP_IDX)); + auto zp_const = ov::as_type_ptr(op->get_input_node_shared_ptr(W_ZP_IDX)); if (zp_const && ov::shape_size(zp_const->get_output_shape(0)) == 1) { has_scalar_zp = true; zp_value = zp_const->cast_vector()[0]; diff --git a/src/plugins/intel_gpu/src/plugin/ops/gather.cpp b/src/plugins/intel_gpu/src/plugin/ops/gather.cpp index e8d9236a7e6f6d..b9ff77e888ee02 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/gather.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/gather.cpp @@ -101,7 +101,7 @@ void CreateGatherOpBase(ProgramBuilder& p, const std::shared_ptr& op, const i const auto input_rank = input_shape.rank().get_length(); const auto& indices = op->input_value(1); const auto& indices_node = indices.get_node_shared_ptr(); - auto indices_constant = std::dynamic_pointer_cast(indices_node); + auto indices_constant = ov::as_type_ptr(indices_node); bool is_indices_constant = (indices_constant) ? true : false; if (is_static && axis == 0 && input_rank > 1 && indices.get_partial_shape().rank().get_length() == 0 && @@ -149,7 +149,7 @@ void CreateGatherOpBase(ProgramBuilder& p, const std::shared_ptr& op, const i float zp_value = 0.0f; bool has_scalar_zp = false; if (op->get_input_size() == 5) { - std::shared_ptr zp_const = std::dynamic_pointer_cast(op->get_input_node_shared_ptr(4)); + std::shared_ptr zp_const = ov::as_type_ptr(op->get_input_node_shared_ptr(4)); if (zp_const && ov::shape_size(zp_const->get_output_shape(0)) == 1) { has_scalar_zp = true; zp_value = zp_const->cast_vector()[0]; diff --git a/src/plugins/intel_gpu/src/plugin/ops/interpolate.cpp b/src/plugins/intel_gpu/src/plugin/ops/interpolate.cpp index 9ed7136c83e615..ff52d32d2d24c3 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/interpolate.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/interpolate.cpp @@ -18,7 +18,7 @@ static std::vector ExtractAxes(const std::shared_ptr axes; auto inputRank = op->get_input_partial_shape(0).size(); if (op->get_input_size() == axes_index + 1) { - auto axes_constant = std::dynamic_pointer_cast(op->get_input_node_shared_ptr(axes_index)); + auto axes_constant = ov::as_type_ptr(op->get_input_node_shared_ptr(axes_index)); OPENVINO_ASSERT(axes_constant, "Unsupported parameter node type in ", op->get_friendly_name(), " (", op->get_type_name(), ")"); axes = axes_constant->cast_vector(); @@ -76,10 +76,10 @@ static void CreateInterpolateOp(ProgramBuilder& p, const std::shared_ptrget_attrs(); - auto sizes_constant = std::dynamic_pointer_cast(op->get_input_node_shared_ptr(SIZES_INDEX)); + auto sizes_constant = ov::as_type_ptr(op->get_input_node_shared_ptr(SIZES_INDEX)); std::vector sizes = sizes_constant ? sizes_constant->cast_vector() : std::vector{}; - auto scales_constant = std::dynamic_pointer_cast(op->get_input_node_shared_ptr(SCALES_INDEX)); + auto scales_constant = ov::as_type_ptr(op->get_input_node_shared_ptr(SCALES_INDEX)); std::vector scales = scales_constant ? scales_constant->cast_vector() : std::vector{}; std::vector axes = ExtractAxes(op, AXES_INDEX); @@ -156,7 +156,7 @@ static void CreateInterpolateOp(ProgramBuilder& p, const std::shared_ptrget_attrs(); - auto scales_or_sizes_constant = std::dynamic_pointer_cast(op->get_input_node_shared_ptr(eScalesOrSizesIndex)); + auto scales_or_sizes_constant = ov::as_type_ptr(op->get_input_node_shared_ptr(eScalesOrSizesIndex)); std::vector scales = scales_or_sizes_constant && attrs.shape_calculation_mode == ov::op::v11::Interpolate::ShapeCalcMode::SCALES ? scales_or_sizes_constant->cast_vector() : std::vector{}; std::vector sizes = scales_or_sizes_constant && attrs.shape_calculation_mode == ov::op::v11::Interpolate::ShapeCalcMode::SIZES ? diff --git a/src/plugins/intel_gpu/src/plugin/ops/loop.cpp b/src/plugins/intel_gpu/src/plugin/ops/loop.cpp index bb11308064f7e7..9fb6ca47a4690e 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/loop.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/loop.cpp @@ -75,7 +75,7 @@ static void SetLoopInputOutputMap(ProgramBuilder& p, // set input mapping if (const auto& sliceInfo = - std::dynamic_pointer_cast(loop_input_desc)) { + ov::as_type_ptr(loop_input_desc)) { // sliced input input_primitive_maps.emplace_back(external_id, internal_id, sliceInfo->m_axis, sliceInfo->m_start, sliceInfo->m_end, sliceInfo->m_stride); @@ -94,7 +94,7 @@ static void SetLoopInputOutputMap(ProgramBuilder& p, // set back edges if (const auto& mergedInput = - std::dynamic_pointer_cast(loop_input_desc)) { + ov::as_type_ptr(loop_input_desc)) { // backedge const auto& to = body_inputs.at(mergedInput->m_body_parameter_index); const auto& from = body_outputs.at(mergedInput->m_body_value_index); @@ -118,7 +118,7 @@ static void SetLoopInputOutputMap(ProgramBuilder& p, // update primitive_map if (const auto& concatOutput = - std::dynamic_pointer_cast(loop_output_desc)) { + ov::as_type_ptr(loop_output_desc)) { // output which requires concatenation output_primitive_maps.emplace_back(external_input_info, internal_id, concatOutput->m_axis, concatOutput->m_start, concatOutput->m_end, concatOutput->m_stride); @@ -128,7 +128,7 @@ static void SetLoopInputOutputMap(ProgramBuilder& p, << concatOutput->m_axis << "," << concatOutput->m_start << "," << concatOutput->m_end << "," << concatOutput->m_stride << "}" << std::endl; } - if (std::dynamic_pointer_cast(loop_output_desc)) { + if (ov::as_type_ptr(loop_output_desc)) { // output which requires no concatenation output_primitive_maps.emplace_back(external_input_info, internal_id); GPU_DEBUG_LOG << "loop_output_descs[" << layerName << "][BodyOutputDescription] external:" @@ -158,7 +158,7 @@ static void SetLoopInputOutputMap(ProgramBuilder& p, // update primitive_map if (const auto& concatOutput = - std::dynamic_pointer_cast(loop_output_desc)) { + ov::as_type_ptr(loop_output_desc)) { // output which requires concatenation output_primitive_maps.emplace_back(external_id, internal_id, concatOutput->m_axis, concatOutput->m_start, concatOutput->m_end, concatOutput->m_stride); @@ -168,7 +168,7 @@ static void SetLoopInputOutputMap(ProgramBuilder& p, << concatOutput->m_axis << "," << concatOutput->m_start << "," << concatOutput->m_end << "," << concatOutput->m_stride << "}" << std::endl; } - if (std::dynamic_pointer_cast(loop_output_desc)) { + if (ov::as_type_ptr(loop_output_desc)) { // output which requires no concatenation output_primitive_maps.emplace_back(external_id, internal_id); GPU_DEBUG_LOG << "loop_output_descs[" << layerName << "][BodyOutputDescription] external:" @@ -224,7 +224,7 @@ static void CreateCommonLoopOp(ProgramBuilder& p, const std::shared_ptr current_iteration_input_op; if (is_loop_op) { - auto loop_op = std::dynamic_pointer_cast(op); + auto loop_op = ov::as_type_ptr(op); auto special_body_ports = loop_op->get_special_body_ports(); if (special_body_ports.current_iteration_input_idx >= 0) { const auto& body_inputs = loop_op->get_function()->get_parameters(); diff --git a/src/plugins/intel_gpu/src/plugin/ops/lrn.cpp b/src/plugins/intel_gpu/src/plugin/ops/lrn.cpp index de9f2b5607b4ba..1a42cb419e6a19 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/lrn.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/lrn.cpp @@ -26,7 +26,7 @@ static void CreateLRNOp(ProgramBuilder& p, const std::shared_ptr(op->get_input_node_shared_ptr(1)); + auto axis_const = ov::as_type_ptr(op->get_input_node_shared_ptr(1)); OPENVINO_ASSERT(axis_const != nullptr, "[GPU] Unsupported parameter nodes type in ", op->get_friendly_name(), " (", op->get_type_name(), ")"); auto axis_value = axis_const->cast_vector(); auto localSize = static_cast(op->get_nsize()); diff --git a/src/plugins/intel_gpu/src/plugin/ops/multinomial.cpp b/src/plugins/intel_gpu/src/plugin/ops/multinomial.cpp index b78e1300f883cc..3b0ea4ce0bf16b 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/multinomial.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/multinomial.cpp @@ -122,7 +122,7 @@ static void CreateMultinomialOp(ProgramBuilder& p, const std::shared_ptr(op->get_input_node_shared_ptr(1)); + auto const_num_samples = ov::as_type_ptr(op->get_input_node_shared_ptr(1)); OPENVINO_ASSERT(const_num_samples != nullptr, "[GPU] Unsupported num_samples node type in ", op->get_friendly_name(), " (", op->get_type_name(), ")"); std::int64_t num_samples{}; diff --git a/src/plugins/intel_gpu/src/plugin/ops/mvn.cpp b/src/plugins/intel_gpu/src/plugin/ops/mvn.cpp index 80c05098b72366..08e0324e071557 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/mvn.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/mvn.cpp @@ -50,7 +50,7 @@ static void CreateMVNOp(ProgramBuilder& p, const std::shared_ptr& op) { validate_inputs_count(op, {2}); - auto inConst = std::dynamic_pointer_cast(op->get_input_node_shared_ptr(1)); + auto inConst = ov::as_type_ptr(op->get_input_node_shared_ptr(1)); OPENVINO_ASSERT(inConst != nullptr, "[GPU] Unsupported parameter nodes type in ", op->get_friendly_name(), " (", op->get_type_name(), ")"); std::vector axes = inConst->cast_vector(); diff --git a/src/plugins/intel_gpu/src/plugin/ops/normalize_l2.cpp b/src/plugins/intel_gpu/src/plugin/ops/normalize_l2.cpp index 7733d0f1fdc847..7a6b9d8375410a 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/normalize_l2.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/normalize_l2.cpp @@ -20,7 +20,7 @@ static void CreateNormalizeL2Op(ProgramBuilder& p, const std::shared_ptr(op->get_input_node_shared_ptr(1)); + auto const_axis = ov::as_type_ptr(op->get_input_node_shared_ptr(1)); OPENVINO_ASSERT(const_axis != nullptr, "[GPU] Unsupported axis node type in ", op->get_friendly_name(), " (", op->get_type_name(), ")"); auto axis = const_axis->cast_vector(); diff --git a/src/plugins/intel_gpu/src/plugin/ops/one_hot.cpp b/src/plugins/intel_gpu/src/plugin/ops/one_hot.cpp index 09e9d81db088df..52b911c686cdb3 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/one_hot.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/one_hot.cpp @@ -18,9 +18,9 @@ static void CreateOneHotOp(ProgramBuilder& p, const std::shared_ptrget_axis(); - auto depth_value_node = std::dynamic_pointer_cast(op->get_input_node_shared_ptr(1)); - auto on_value_node = std::dynamic_pointer_cast(op->get_input_node_shared_ptr(2)); - auto off_value_node = std::dynamic_pointer_cast(op->get_input_node_shared_ptr(3)); + auto depth_value_node = ov::as_type_ptr(op->get_input_node_shared_ptr(1)); + auto on_value_node = ov::as_type_ptr(op->get_input_node_shared_ptr(2)); + auto off_value_node = ov::as_type_ptr(op->get_input_node_shared_ptr(3)); OPENVINO_ASSERT(on_value_node != nullptr || off_value_node != nullptr || depth_value_node != nullptr, "[GPU] Unsupported on/off/depth nodes type in ", op->get_friendly_name(), " (", op->get_type_name(), ")"); diff --git a/src/plugins/intel_gpu/src/plugin/ops/pad.cpp b/src/plugins/intel_gpu/src/plugin/ops/pad.cpp index 09489689687fc4..5aa382c13f54a0 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/pad.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/pad.cpp @@ -21,7 +21,7 @@ static void CreatePadOpInternal(ProgramBuilder& p, const std::shared_ptr non_constant_inputs = {inputs[0]}; int32_t non_constant_input_mask = 0; - auto pads_begin_constant = std::dynamic_pointer_cast(op->input_value(1).get_node_shared_ptr()); + auto pads_begin_constant = ov::as_type_ptr(op->input_value(1).get_node_shared_ptr()); std::vector pads_begin = std::vector{}; if (pads_begin_constant) { pads_begin = pads_begin_constant->cast_vector(); @@ -30,7 +30,7 @@ static void CreatePadOpInternal(ProgramBuilder& p, const std::shared_ptr(op->input_value(2).get_node_shared_ptr()); + auto pads_end_constant = ov::as_type_ptr(op->input_value(2).get_node_shared_ptr()); std::vector pads_end = std::vector{}; if (pads_end_constant) { pads_end = pads_end_constant->cast_vector(); @@ -42,7 +42,7 @@ static void CreatePadOpInternal(ProgramBuilder& p, const std::shared_ptrget_pad_mode() == ov::op::PadMode::CONSTANT && op->get_input_size() == 4) { - auto const_node = std::dynamic_pointer_cast(op->get_input_node_shared_ptr(3)); + auto const_node = ov::as_type_ptr(op->get_input_node_shared_ptr(3)); if (const_node) { const bool check_value_range = false; // Allows the usage of infinity value as pad_value OPENVINO_ASSERT(ov::op::util::get_single_value(const_node, pad_value, check_value_range), diff --git a/src/plugins/intel_gpu/src/plugin/ops/paged_attention.cpp b/src/plugins/intel_gpu/src/plugin/ops/paged_attention.cpp index b56807d720b870..9898cb10c18fde 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/paged_attention.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/paged_attention.cpp @@ -50,7 +50,7 @@ static void CreatePagedAttentionExtensionOp(ProgramBuilder& p, const std::shared const size_t alibi_idx = 11; const size_t rotated_block_indices_idx = 13; - std::shared_ptr scale_const = std::dynamic_pointer_cast(op->get_input_node_shared_ptr(scale_idx)); + std::shared_ptr scale_const = ov::as_type_ptr(op->get_input_node_shared_ptr(scale_idx)); if (scale_const) { OPENVINO_ASSERT(ov::shape_size(scale_const->get_output_shape(0)) == 1); prim.scale_val = scale_const->cast_vector()[0]; @@ -58,14 +58,14 @@ static void CreatePagedAttentionExtensionOp(ProgramBuilder& p, const std::shared prim.scale_val = cldnn::optional_value(); } - std::shared_ptr alibi_const = std::dynamic_pointer_cast(op->get_input_node_shared_ptr(alibi_idx)); + std::shared_ptr alibi_const = ov::as_type_ptr(op->get_input_node_shared_ptr(alibi_idx)); OPENVINO_ASSERT(alibi_const != nullptr); prim.has_alibi = ov::shape_size(alibi_const->get_output_shape(0)) > 0; prim.num_outputs = 1; std::shared_ptr rotated_block_indices_const = - std::dynamic_pointer_cast(op->get_input_node_shared_ptr(rotated_block_indices_idx)); + ov::as_type_ptr(op->get_input_node_shared_ptr(rotated_block_indices_idx)); OPENVINO_ASSERT(rotated_block_indices_const != nullptr); prim.has_rotated_blocks = ov::shape_size(rotated_block_indices_const->get_output_shape(0)) > 0; diff --git a/src/plugins/intel_gpu/src/plugin/ops/prior_box.cpp b/src/plugins/intel_gpu/src/plugin/ops/prior_box.cpp index 2f50a772c45be6..ba7dd9a6803d86 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/prior_box.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/prior_box.cpp @@ -111,8 +111,8 @@ static void CreatePriorBoxOp(ProgramBuilder& p, const std::shared_ptr(op->get_input_node_shared_ptr(0)); - const auto image_size_constant = std::dynamic_pointer_cast(op->get_input_node_shared_ptr(1)); + const auto output_size_constant = ov::as_type_ptr(op->get_input_node_shared_ptr(0)); + const auto image_size_constant = ov::as_type_ptr(op->get_input_node_shared_ptr(1)); // output_size should be constant to be static output shape OPENVINO_ASSERT(output_size_constant, @@ -183,8 +183,8 @@ static void CreatePriorBoxOp(ProgramBuilder& p, const std::shared_ptrget_output_partial_shape(0); if (!output_pshape.is_dynamic()) { - const auto output_size_constant = std::dynamic_pointer_cast(op->get_input_node_shared_ptr(0)); - const auto image_size_constant = std::dynamic_pointer_cast(op->get_input_node_shared_ptr(1)); + const auto output_size_constant = ov::as_type_ptr(op->get_input_node_shared_ptr(0)); + const auto image_size_constant = ov::as_type_ptr(op->get_input_node_shared_ptr(1)); // output_size should be constant to be static output shape OPENVINO_ASSERT(output_size_constant, diff --git a/src/plugins/intel_gpu/src/plugin/ops/reduce.cpp b/src/plugins/intel_gpu/src/plugin/ops/reduce.cpp index 683cec31b7787e..ff50526c1db8d2 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/reduce.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/reduce.cpp @@ -30,7 +30,7 @@ static void CreateReduceOp(ProgramBuilder& p, const std::shared_ptr& o auto input_pshape = op->get_input_partial_shape(0); int64_t rank = input_pshape.size(); - auto axes_constant = std::dynamic_pointer_cast(op->get_input_node_shared_ptr(1)); + auto axes_constant = ov::as_type_ptr(op->get_input_node_shared_ptr(1)); OPENVINO_ASSERT(axes_constant != nullptr, "[GPU] Unsupported parameter nodes type in ", op->get_friendly_name(), " (", op->get_type_name(), ")"); std::vector axes = axes_constant->cast_vector(); diff --git a/src/plugins/intel_gpu/src/plugin/ops/reshape.cpp b/src/plugins/intel_gpu/src/plugin/ops/reshape.cpp index 7e98d79583cc07..de085d8c008d6d 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/reshape.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/reshape.cpp @@ -27,7 +27,7 @@ static void CreateCommonReshapeOp(ProgramBuilder& p, const std::shared_ptris_dynamic()) { std::shared_ptr reshape_prim = nullptr; - auto second_const_input = op->get_input_size() == 2 ? std::dynamic_pointer_cast(op->get_input_node_shared_ptr(1)) : nullptr; + auto second_const_input = op->get_input_size() == 2 ? ov::as_type_ptr(op->get_input_node_shared_ptr(1)) : nullptr; std::vector output_pattern = {}; if (second_const_input != nullptr) { output_pattern = second_const_input->cast_vector(); diff --git a/src/plugins/intel_gpu/src/plugin/ops/roll.cpp b/src/plugins/intel_gpu/src/plugin/ops/roll.cpp index 5e6965430641bc..d2e55c60c4272c 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/roll.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/roll.cpp @@ -22,11 +22,11 @@ void CreateRollOp(ProgramBuilder& p, const std::shared_ptr& op const auto& op_friendly_name = op->get_friendly_name(); const auto& input_pshape = op->get_input_partial_shape(0); - auto shift_constant = std::dynamic_pointer_cast(op->get_input_node_shared_ptr(1)); + auto shift_constant = ov::as_type_ptr(op->get_input_node_shared_ptr(1)); OPENVINO_ASSERT(shift_constant != nullptr, "[GPU] Unsupported parameter nodes type in ", op_friendly_name, " (", op->get_type_name(), ")"); const auto shift_raw = shift_constant->cast_vector(); - auto axes_constant = std::dynamic_pointer_cast(op->get_input_node_shared_ptr(2)); + auto axes_constant = ov::as_type_ptr(op->get_input_node_shared_ptr(2)); OPENVINO_ASSERT(axes_constant != nullptr, "[GPU] Unsupported parameter nodes type in ", op_friendly_name, " (", op->get_type_name(), ")"); auto axes_raw = axes_constant->cast_vector(); diff --git a/src/plugins/intel_gpu/src/plugin/ops/scatter_elements_update.cpp b/src/plugins/intel_gpu/src/plugin/ops/scatter_elements_update.cpp index 1a5d8424e0a402..66aedf7a8be728 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/scatter_elements_update.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/scatter_elements_update.cpp @@ -17,7 +17,7 @@ static void CreateScatterElementsUpdateOp(ProgramBuilder& p, const std::shared_p auto inputs = p.GetInputInfo(op); std::string layerName = layer_type_name_ID(op); - auto axes_constant = std::dynamic_pointer_cast(op->get_input_node_shared_ptr(3)); + auto axes_constant = ov::as_type_ptr(op->get_input_node_shared_ptr(3)); OPENVINO_ASSERT(axes_constant, "Unsupported parameter nodes type in ", op->get_friendly_name(), " (", op->get_type_name(), ")"); int64_t axis = ov::util::try_normalize_axis(axes_constant->cast_vector()[0], diff --git a/src/plugins/intel_gpu/src/plugin/ops/scatter_update.cpp b/src/plugins/intel_gpu/src/plugin/ops/scatter_update.cpp index a7e145dde1cae9..637b021990bf63 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/scatter_update.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/scatter_update.cpp @@ -18,7 +18,7 @@ static void CreateScatterUpdateOp(ProgramBuilder& p, const std::shared_ptr(op->get_input_node_shared_ptr(3)); + auto axes_constant = ov::as_type_ptr(op->get_input_node_shared_ptr(3)); OPENVINO_ASSERT(axes_constant != nullptr, "[GPU] Unsupported parameter nodes type in ", op->get_friendly_name(), " (", op->get_type_name(), ")"); int64_t axis = axes_constant->cast_vector()[0]; auto primitive = cldnn::scatter_update(layerName, diff --git a/src/plugins/intel_gpu/src/plugin/ops/space_to_batch.cpp b/src/plugins/intel_gpu/src/plugin/ops/space_to_batch.cpp index 5a155a1ede2381..f5dfce222da0a8 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/space_to_batch.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/space_to_batch.cpp @@ -26,7 +26,7 @@ static void CreateSpaceToBatchOp(ProgramBuilder& p, const std::shared_ptr(op->get_input_node_shared_ptr(i)); + auto inConst = ov::as_type_ptr(op->get_input_node_shared_ptr(i)); bool is_const_input = (inConst != nullptr); OPENVINO_ASSERT((i == 1) || (i >= 2 && non_constant_input != is_const_input), @@ -47,7 +47,7 @@ static void CreateSpaceToBatchOp(ProgramBuilder& p, const std::shared_ptr(op->get_input_node_shared_ptr(i)); + auto inConst = ov::as_type_ptr(op->get_input_node_shared_ptr(i)); std::vector sizes = inConst->cast_vector(); int32_t default_size = i == 1 ? 1 : 0; diff --git a/src/plugins/intel_gpu/src/plugin/ops/split.cpp b/src/plugins/intel_gpu/src/plugin/ops/split.cpp index 8a36cfa30995fa..67fb58ce90204c 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/split.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/split.cpp @@ -59,7 +59,7 @@ static void CreateCommonSplitOp(ProgramBuilder& p, const std::shared_ptr(op->get_input_node_shared_ptr(1)); + auto const_axis = ov::as_type_ptr(op->get_input_node_shared_ptr(1)); if (const_axis) { axis = ov::util::try_normalize_axis(const_axis->cast_vector()[0], op->get_input_partial_shape(0).rank(), diff --git a/src/plugins/intel_gpu/src/plugin/ops/strided_slice.cpp b/src/plugins/intel_gpu/src/plugin/ops/strided_slice.cpp index 1c7354a54140b1..a9b045fe8d85c5 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/strided_slice.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/strided_slice.cpp @@ -33,7 +33,7 @@ static void CreateStridedSliceOp(ProgramBuilder& p, const std::shared_ptr(op->input_value(1).get_node_shared_ptr()); + auto begin_constant = ov::as_type_ptr(op->input_value(1).get_node_shared_ptr()); std::vector begin; if (begin_constant) { auto const_vals = begin_constant->cast_vector(); @@ -41,7 +41,7 @@ static void CreateStridedSliceOp(ProgramBuilder& p, const std::shared_ptrget_element_type())); } } - auto end_constant = std::dynamic_pointer_cast(op->input_value(2).get_node_shared_ptr()); + auto end_constant = ov::as_type_ptr(op->input_value(2).get_node_shared_ptr()); std::vector end; if (end_constant) { auto const_vals = end_constant->cast_vector(); @@ -49,7 +49,7 @@ static void CreateStridedSliceOp(ProgramBuilder& p, const std::shared_ptrget_element_type())); } } - auto stride_constant = std::dynamic_pointer_cast(op->input_value(3).get_node_shared_ptr()); + auto stride_constant = ov::as_type_ptr(op->input_value(3).get_node_shared_ptr()); std::vector strides = stride_constant ? stride_constant->cast_vector() : std::vector{}; do { diff --git a/src/plugins/intel_gpu/src/plugin/ops/tile.cpp b/src/plugins/intel_gpu/src/plugin/ops/tile.cpp index 5202e5e2dd231d..796bda40049d48 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/tile.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/tile.cpp @@ -17,7 +17,7 @@ static void CreateTileOp(ProgramBuilder& p, const std::shared_ptr(op->get_input_node_shared_ptr(1))) { + if (auto repeats_const = ov::as_type_ptr(op->get_input_node_shared_ptr(1))) { std::vector repeats = repeats_const->cast_vector(); // TODO: Remove code below once new shape infer is enabled diff --git a/src/plugins/intel_gpu/src/plugin/ops/topk.cpp b/src/plugins/intel_gpu/src/plugin/ops/topk.cpp index fb5e021fec42eb..a384eaadd8fac6 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/topk.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/topk.cpp @@ -28,7 +28,7 @@ static void TopKImpl(ProgramBuilder& p, if (p.use_new_shape_infer()) { size_t num_outputs = op->get_output_size(); - auto topk_constant = std::dynamic_pointer_cast(op->input_value(1).get_node_shared_ptr()); + auto topk_constant = ov::as_type_ptr(op->input_value(1).get_node_shared_ptr()); auto argmaxPrim = cldnn::arg_max_min(layerName, inputs[0], inputs[1], diff --git a/src/plugins/intel_gpu/src/plugin/ops/transpose.cpp b/src/plugins/intel_gpu/src/plugin/ops/transpose.cpp index a0ae110f47a9de..e95f74430a925f 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/transpose.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/transpose.cpp @@ -19,7 +19,7 @@ static void CreateTransposeOp(ProgramBuilder& p, const std::shared_ptr order; if (op->get_input_size() == 2) { - auto order_constant = std::dynamic_pointer_cast(op->get_input_node_shared_ptr(1)); + auto order_constant = ov::as_type_ptr(op->get_input_node_shared_ptr(1)); OPENVINO_ASSERT(order_constant != nullptr, "[GPU] Unsupported parameter nodes type in ", op->get_friendly_name(), " (", op->get_type_name(), ")"); order = order_constant->cast_vector(); } diff --git a/src/plugins/intel_gpu/src/plugin/ops/unary.cpp b/src/plugins/intel_gpu/src/plugin/ops/unary.cpp index 5f18c6557aef68..bba0911ee03706 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/unary.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/unary.cpp @@ -76,7 +76,7 @@ static void CreateReluOp(ProgramBuilder& p, const std::shared_ptr& op) { validate_inputs_count(op, {2}); - auto slope_node = std::dynamic_pointer_cast(op->get_input_node_shared_ptr(1)); + auto slope_node = ov::as_type_ptr(op->get_input_node_shared_ptr(1)); auto slope_shape = op->get_input_partial_shape(1); auto out_shape = op->get_output_partial_shape(0); @@ -165,8 +165,8 @@ static void CreateErfOp(ProgramBuilder& p, const std::shared_ptr& op) { validate_inputs_count(op, {3}); - auto alpha_node = std::dynamic_pointer_cast(op->get_input_node_shared_ptr(1)); - auto beta_node = std::dynamic_pointer_cast(op->get_input_node_shared_ptr(2)); + auto alpha_node = ov::as_type_ptr(op->get_input_node_shared_ptr(1)); + auto beta_node = ov::as_type_ptr(op->get_input_node_shared_ptr(2)); if (!alpha_node || !beta_node) { OPENVINO_THROW("[GPU] Unsupported parameter nodes type in ", op->get_friendly_name(), " (", op->get_type_name(), ")"); } @@ -191,8 +191,8 @@ static void CreateNegativeOp(ProgramBuilder& p, const std::shared_ptr& op) { validate_inputs_count(op, {3}); - auto alpha_node = std::dynamic_pointer_cast(op->get_input_node_shared_ptr(1)); - auto lambda_node = std::dynamic_pointer_cast(op->get_input_node_shared_ptr(2)); + auto alpha_node = ov::as_type_ptr(op->get_input_node_shared_ptr(1)); + auto lambda_node = ov::as_type_ptr(op->get_input_node_shared_ptr(2)); if (!alpha_node || !lambda_node) { OPENVINO_THROW("Unsupported parameter nodes type in ", op->get_friendly_name(), " (", op->get_type_name(), ")"); } @@ -236,7 +236,7 @@ static void CreateCoshOp(ProgramBuilder& p, const std::shared_ptr& op) { validate_inputs_count(op, {1, 2}); if (op->get_input_size() == 2) { - auto beta_node = std::dynamic_pointer_cast(op->get_input_node_shared_ptr(1)); + auto beta_node = ov::as_type_ptr(op->get_input_node_shared_ptr(1)); if (beta_node) { if (ov::shape_size(beta_node->get_output_shape(0)) == 1) { float beta; diff --git a/src/plugins/intel_gpu/src/plugin/ops/unique.cpp b/src/plugins/intel_gpu/src/plugin/ops/unique.cpp index df10146fefd2af..28e9c023358162 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/unique.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/unique.cpp @@ -19,7 +19,7 @@ void CreateUniqueOp(ProgramBuilder& p, const std::shared_ptrget_input_size() == 2) { - auto axis_constant = std::dynamic_pointer_cast(op->get_input_node_shared_ptr(1)); + auto axis_constant = ov::as_type_ptr(op->get_input_node_shared_ptr(1)); OPENVINO_ASSERT(axis_constant != nullptr, "[GPU] Unsupported parameter nodes type in ", op->get_friendly_name(), " (", op->get_type_name(), ")"); axis = axis_constant->cast_vector().at(0); axis = ov::util::try_normalize_axis(axis, op->get_input_partial_shape(0).rank(), *op); diff --git a/src/plugins/intel_gpu/src/plugin/transformations/bcast_and_pad_zp_buffers.cpp b/src/plugins/intel_gpu/src/plugin/transformations/bcast_and_pad_zp_buffers.cpp index 9e85fbbb535946..bfae380a93e046 100644 --- a/src/plugins/intel_gpu/src/plugin/transformations/bcast_and_pad_zp_buffers.cpp +++ b/src/plugins/intel_gpu/src/plugin/transformations/bcast_and_pad_zp_buffers.cpp @@ -128,7 +128,7 @@ BroadcastAndPadZeroPointBuffers::BroadcastAndPadZeroPointBuffers(size_t pad_size return false; } - auto conv = std::dynamic_pointer_cast(m.get_match_root()); + auto conv = ov::as_type_ptr(m.get_match_root()); auto in_shape = conv->get_input_partial_shape(0); auto out_shape = conv->get_output_partial_shape(0); const size_t channel_idx = 1; @@ -137,7 +137,7 @@ BroadcastAndPadZeroPointBuffers::BroadcastAndPadZeroPointBuffers(size_t pad_size return false; } - if (auto azp = std::dynamic_pointer_cast(pattern_map.at(azp_m).get_node_shared_ptr())) { + if (auto azp = ov::as_type_ptr(pattern_map.at(azp_m).get_node_shared_ptr())) { auto target_shape = azp->get_shape(); const size_t azp_c_idx = target_shape.size() == in_shape.size() ? 1 : 0; auto aligned_azp = pad_quantization_parameter(azp, in_shape[channel_idx].get_length(), azp_c_idx, pad_size); @@ -146,7 +146,7 @@ BroadcastAndPadZeroPointBuffers::BroadcastAndPadZeroPointBuffers(size_t pad_size conv->input(op::Convolution::Args::AZP).replace_source_output(aligned_azp); } - if (auto wzp = std::dynamic_pointer_cast(pattern_map.at(wzp_m).get_node_shared_ptr())) { + if (auto wzp = ov::as_type_ptr(pattern_map.at(wzp_m).get_node_shared_ptr())) { auto target_shape = wzp->get_shape(); std::shared_ptr aligned_wzp; @@ -165,7 +165,7 @@ BroadcastAndPadZeroPointBuffers::BroadcastAndPadZeroPointBuffers(size_t pad_size conv->input(op::Convolution::Args::WZP).replace_source_output(aligned_wzp); } - if (auto cmp = std::dynamic_pointer_cast(pattern_map.at(cmp_m).get_node_shared_ptr())) { + if (auto cmp = ov::as_type_ptr(pattern_map.at(cmp_m).get_node_shared_ptr())) { auto target_shape = cmp->get_shape(); const size_t cmp_c_idx = target_shape.size() == out_shape.size() ? 1 : 0; auto aligned_cmp = pad_quantization_parameter(cmp, out_shape[channel_idx].get_length(), cmp_c_idx, pad_size); diff --git a/src/plugins/intel_gpu/src/plugin/transformations/binary_conv_to_conv.cpp b/src/plugins/intel_gpu/src/plugin/transformations/binary_conv_to_conv.cpp index 40c4dfa781eed2..77a9444a216a1f 100644 --- a/src/plugins/intel_gpu/src/plugin/transformations/binary_conv_to_conv.cpp +++ b/src/plugins/intel_gpu/src/plugin/transformations/binary_conv_to_conv.cpp @@ -36,7 +36,7 @@ ConvertBinaryConvolutionToConvolution::ConvertBinaryConvolutionToConvolution() { using namespace ov::pass::pattern; auto binary_fq = [](const Output& node) { - auto fq = std::dynamic_pointer_cast(node.get_node_shared_ptr()); + auto fq = ov::as_type_ptr(node.get_node_shared_ptr()); if (!fq) return false; @@ -56,9 +56,9 @@ ConvertBinaryConvolutionToConvolution::ConvertBinaryConvolutionToConvolution() { ov::matcher_pass_callback callback = [=](ov::pass::pattern::Matcher& m) { const auto& pattern_map = m.get_pattern_value_map(); - auto binary_conv = std::dynamic_pointer_cast(pattern_map.at(binary_conv_m).get_node_shared_ptr()); + auto binary_conv = ov::as_type_ptr(pattern_map.at(binary_conv_m).get_node_shared_ptr()); auto activations = pattern_map.at(activations_input_m); - auto weights = std::dynamic_pointer_cast(pattern_map.at(weights_input_m).get_node_shared_ptr()); + auto weights = ov::as_type_ptr(pattern_map.at(weights_input_m).get_node_shared_ptr()); auto fp_element_type = activations.get_element_type(); ov::Tensor new_weights_data(fp_element_type, weights->get_output_shape(0)); diff --git a/src/plugins/intel_gpu/src/plugin/transformations/clamp_fp16_output.cpp b/src/plugins/intel_gpu/src/plugin/transformations/clamp_fp16_output.cpp index ba779eb0f52ca9..b8af155866462f 100644 --- a/src/plugins/intel_gpu/src/plugin/transformations/clamp_fp16_output.cpp +++ b/src/plugins/intel_gpu/src/plugin/transformations/clamp_fp16_output.cpp @@ -41,7 +41,7 @@ ClampFP16Output::ClampFP16Output() { 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 softmax = std::dynamic_pointer_cast(pattern_map.at(softmax_m).get_node_shared_ptr()); + auto softmax = ov::as_type_ptr(pattern_map.at(softmax_m).get_node_shared_ptr()); if (!softmax || transformation_callback(softmax)) { return false; } diff --git a/src/plugins/intel_gpu/src/plugin/transformations/convert_convolution.cpp b/src/plugins/intel_gpu/src/plugin/transformations/convert_convolution.cpp index 32a92c08470d97..371c134afa028b 100644 --- a/src/plugins/intel_gpu/src/plugin/transformations/convert_convolution.cpp +++ b/src/plugins/intel_gpu/src/plugin/transformations/convert_convolution.cpp @@ -73,9 +73,9 @@ ov::Tensor get_compensation(ov::Tensor* w_tensor, ov::Tensor* azp_tensor, ov::Te } ov::Tensor get_compensation(std::shared_ptr w, std::shared_ptr azp, std::shared_ptr wzp, int64_t groups) { - auto w_const = std::dynamic_pointer_cast(w); - auto azp_const = std::dynamic_pointer_cast(azp); - auto wzp_const = std::dynamic_pointer_cast(wzp); + auto w_const = ov::as_type_ptr(w); + auto azp_const = ov::as_type_ptr(azp); + auto wzp_const = ov::as_type_ptr(wzp); OPENVINO_ASSERT(w_const != nullptr && azp_const != nullptr); @@ -132,17 +132,17 @@ AsymmetricConvolutionMatcher::AsymmetricConvolutionMatcher() { return false; } - auto conv_node = std::dynamic_pointer_cast(pattern_map.at(convolution_m).get_node_shared_ptr()); + auto conv_node = ov::as_type_ptr(pattern_map.at(convolution_m).get_node_shared_ptr()); int64_t groups = -1; - if (auto grouped_conv = std::dynamic_pointer_cast(conv_node)) { + if (auto grouped_conv = ov::as_type_ptr(conv_node)) { auto weights_shape = grouped_conv->get_input_partial_shape(1); if (weights_shape[0].is_dynamic()) return false; groups = weights_shape[0].get_length(); } - auto weights = std::dynamic_pointer_cast(pattern_map.at(weights_m).get_node_shared_ptr()); + auto weights = ov::as_type_ptr(pattern_map.at(weights_m).get_node_shared_ptr()); std::shared_ptr no_bias = std::make_shared(); std::shared_ptr optional_wzp_point = std::make_shared(); std::shared_ptr optional_azp_point = std::make_shared(); @@ -196,10 +196,10 @@ ConvolutionMatcher::ConvolutionMatcher() { return false; } - auto conv_node = std::dynamic_pointer_cast(pattern_map.at(convolution_m).get_node_shared_ptr()); + auto conv_node = ov::as_type_ptr(pattern_map.at(convolution_m).get_node_shared_ptr()); int64_t groups = -1; - if (auto grouped_conv = std::dynamic_pointer_cast(conv_node)) { + if (auto grouped_conv = ov::as_type_ptr(conv_node)) { auto weights_shape = grouped_conv->get_input_partial_shape(1); if (weights_shape[0].is_dynamic()) return false; diff --git a/src/plugins/intel_gpu/src/plugin/transformations/convert_fc_to_compressed.cpp b/src/plugins/intel_gpu/src/plugin/transformations/convert_fc_to_compressed.cpp index 0ed17f36c21d22..35865430b65091 100644 --- a/src/plugins/intel_gpu/src/plugin/transformations/convert_fc_to_compressed.cpp +++ b/src/plugins/intel_gpu/src/plugin/transformations/convert_fc_to_compressed.cpp @@ -76,7 +76,7 @@ ConvertFullyConnectedToFullyConnectedCompressed::ConvertFullyConnectedToFullyCon OPENVINO_ASSERT(pattern_map.count(weights_m)); OPENVINO_ASSERT(pattern_map.count(bias_m)); OPENVINO_ASSERT(pattern_map.count(convert_m)); - auto fc = std::dynamic_pointer_cast(pattern_map.at(fully_connected_m).get_node_shared_ptr()); + auto fc = ov::as_type_ptr(pattern_map.at(fully_connected_m).get_node_shared_ptr()); if (!fc || transformation_callback(fc)) { return false; } @@ -86,13 +86,13 @@ ConvertFullyConnectedToFullyConnectedCompressed::ConvertFullyConnectedToFullyCon bool grouped = std::count_if(scale_shape.begin(), scale_shape.end(), [](size_t d) { return d > 1; }) > 1; bool sub_with_convert = (pattern_map.count(sub_with_convert_m) > 0) ? true : false; - auto weight_ptr = std::dynamic_pointer_cast(pattern_map.at(weights_m).get_node_shared_ptr()); + auto weight_ptr = ov::as_type_ptr(pattern_map.at(weights_m).get_node_shared_ptr()); bool weight_u8 = false; if (weight_ptr->get_element_type() == ov::element::u8 || weight_ptr->get_element_type() == ov::element::i8) weight_u8 = true; auto reshape_const_to_2d = [has_transpose, grouped](std::shared_ptr node) { - auto constant = std::dynamic_pointer_cast(node); + auto constant = ov::as_type_ptr(node); OPENVINO_ASSERT(constant != nullptr); ov::Shape current_shape = constant->get_shape(); if (current_shape.size() <= 2) @@ -107,7 +107,7 @@ ConvertFullyConnectedToFullyConnectedCompressed::ConvertFullyConnectedToFullyCon }; auto convert_const_to_u8 = [&](std::shared_ptr node) { - auto constant = std::dynamic_pointer_cast(node); + auto constant = ov::as_type_ptr(node); // Convert ZP to u8 if (constant->get_element_type() == ov::element::u8) return std::dynamic_pointer_cast(constant); @@ -156,7 +156,7 @@ ConvertFullyConnectedToFullyConnectedCompressed::ConvertFullyConnectedToFullyCon } if (pattern_map.count(mul2_m)) { - auto mul2_op_const = std::dynamic_pointer_cast(pattern_map.at(mul2_const_m).get_node_shared_ptr()); + auto mul2_op_const = ov::as_type_ptr(pattern_map.at(mul2_const_m).get_node_shared_ptr()); fc_input_scale = ov::op::util::eltwise_fold(fc_input_scale, mul2_op_const).get_node_shared_ptr(); } diff --git a/src/plugins/intel_gpu/src/plugin/transformations/convert_matmul_to_fc.cpp b/src/plugins/intel_gpu/src/plugin/transformations/convert_matmul_to_fc.cpp index 6e85f8efe0784a..6757cf09d88526 100644 --- a/src/plugins/intel_gpu/src/plugin/transformations/convert_matmul_to_fc.cpp +++ b/src/plugins/intel_gpu/src/plugin/transformations/convert_matmul_to_fc.cpp @@ -36,7 +36,7 @@ ConvertMatMulToFullyConnected::ConvertMatMulToFullyConnected() { 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; } @@ -50,7 +50,7 @@ ConvertMatMulToFullyConnected::ConvertMatMulToFullyConnected() { auto input_b = fc_input_b.get_node_shared_ptr(); for (auto& user : input_b->get_users()) { if (user != matmul && ov::is_type(user) && ov::is_type(input_b)) { - auto other_matmul = std::dynamic_pointer_cast(user); + auto other_matmul = ov::as_type_ptr(user); // Transpose for input_b generates invalid input for other sibling matmul if (input_b == other_matmul->get_input_node_shared_ptr(0) || fc_input_b == fc_input_a || (input_b == other_matmul->get_input_node_shared_ptr(1) && matmul->get_transpose_b() != other_matmul->get_transpose_b())) { @@ -62,12 +62,12 @@ ConvertMatMulToFullyConnected::ConvertMatMulToFullyConnected() { // fc_input_a and fc_input_b - are the final inputs that will be set to FullyConnected. // So in case of adding new operations that takes matmul inputs we need keep update fc_input_a and fc_input_b. 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())) { is_convert = true; fc_input_b = convert_node->get_input_node_shared_ptr(0); } - auto transpose_node = std::dynamic_pointer_cast(fc_input_b.get_node_shared_ptr()); + auto transpose_node = ov::as_type_ptr(fc_input_b.get_node_shared_ptr()); if (transpose_node) { fc_input_b = transpose_node->get_input_node_shared_ptr(0); } @@ -159,7 +159,7 @@ ConvertMatMulToFullyConnected::ConvertMatMulToFullyConnected() { bool can_reuse_transpose = false; if (!matmul->get_transpose_b()) { if (transpose_node && transpose_node->get_input_size() == 2) { - auto order_constant = std::dynamic_pointer_cast(transpose_node->get_input_node_shared_ptr(1)); + auto order_constant = ov::as_type_ptr(transpose_node->get_input_node_shared_ptr(1)); if (order_constant) { std::vector order = order_constant->cast_vector(); diff --git a/src/plugins/intel_gpu/src/plugin/transformations/convert_pooling_to_reduce.cpp b/src/plugins/intel_gpu/src/plugin/transformations/convert_pooling_to_reduce.cpp index 4ec5e1e60f7235..7839709d2b515c 100644 --- a/src/plugins/intel_gpu/src/plugin/transformations/convert_pooling_to_reduce.cpp +++ b/src/plugins/intel_gpu/src/plugin/transformations/convert_pooling_to_reduce.cpp @@ -18,7 +18,7 @@ ov::intel_gpu::ConvertAvgPoolingToReduce::ConvertAvgPoolingToReduce() { // Check all AvgPool nodes auto m = std::make_shared(ov::pass::pattern::wrap_type(), "ConvertAvgPoolingToReduce"); register_matcher(m, [&](ov::pass::pattern::Matcher& m) { - auto pool = std::dynamic_pointer_cast(m.get_match_root()); + auto pool = ov::as_type_ptr(m.get_match_root()); if (!pool || transformation_callback(pool)) { return false; } diff --git a/src/plugins/intel_gpu/src/plugin/transformations/convert_shapeof.cpp b/src/plugins/intel_gpu/src/plugin/transformations/convert_shapeof.cpp index bfae31f779698a..1677042b586cac 100644 --- a/src/plugins/intel_gpu/src/plugin/transformations/convert_shapeof.cpp +++ b/src/plugins/intel_gpu/src/plugin/transformations/convert_shapeof.cpp @@ -14,7 +14,7 @@ ov::intel_gpu::ConvertShapeOf1To3::ConvertShapeOf1To3() { auto shapeof1 = ov::pass::pattern::wrap_type(); matcher_pass_callback callback = [](ov::pass::pattern::Matcher& m) { - auto shapeof1 = std::dynamic_pointer_cast(m.get_match_root()); + auto shapeof1 = ov::as_type_ptr(m.get_match_root()); if (!shapeof1) { return false; } diff --git a/src/plugins/intel_gpu/src/plugin/transformations/convert_stridedslices_to_variadicsplit.cpp b/src/plugins/intel_gpu/src/plugin/transformations/convert_stridedslices_to_variadicsplit.cpp index 56dd9952c8acaf..500a156be56fcb 100644 --- a/src/plugins/intel_gpu/src/plugin/transformations/convert_stridedslices_to_variadicsplit.cpp +++ b/src/plugins/intel_gpu/src/plugin/transformations/convert_stridedslices_to_variadicsplit.cpp @@ -43,13 +43,13 @@ ConvertStridedSlicesToVariadicSplit::ConvertStridedSlicesToVariadicSplit() { if (transformation_callback(m.get_match_root())) { return false; } - auto fc = std::dynamic_pointer_cast(m.get_match_root()); + auto fc = ov::as_type_ptr(m.get_match_root()); ov::NodeVector strided_slice_nodes; std::vector split_lengths; int64_t begin_offset = 0; int64_t end_offset = 0; for (const auto& user : fc->get_users()) { - const auto strided_slice_node = std::dynamic_pointer_cast(user); + const auto strided_slice_node = ov::as_type_ptr(user); if (strided_slice_node) { auto valid_ps = [](const ov::PartialShape& shape) -> bool { return shape.rank().is_static() && shape[shape.rank().get_length() - 1].is_static(); diff --git a/src/plugins/intel_gpu/src/plugin/transformations/dynamic_quantize_fully_connected.cpp b/src/plugins/intel_gpu/src/plugin/transformations/dynamic_quantize_fully_connected.cpp index 7b365ab7164ba7..a8eb149ff28646 100644 --- a/src/plugins/intel_gpu/src/plugin/transformations/dynamic_quantize_fully_connected.cpp +++ b/src/plugins/intel_gpu/src/plugin/transformations/dynamic_quantize_fully_connected.cpp @@ -36,7 +36,7 @@ DynamicQuantizeFullyConnected::DynamicQuantizeFullyConnected(uint64_t group_size const auto& pattern_map = m.get_pattern_value_map(); const auto& m_data = pattern_map.at(data).get_node_shared_ptr(); - auto m_fc = std::dynamic_pointer_cast(m.get_match_root()); + auto m_fc = ov::as_type_ptr(m.get_match_root()); auto weight_shape = m_fc->get_input_partial_shape(1); const size_t innermost_size = weight_shape[weight_shape.size() - 1].get_length(); diff --git a/src/plugins/intel_gpu/src/plugin/transformations/einsum_decomposition.cpp b/src/plugins/intel_gpu/src/plugin/transformations/einsum_decomposition.cpp index 6f18b227e6699a..8a8a709069ce59 100644 --- a/src/plugins/intel_gpu/src/plugin/transformations/einsum_decomposition.cpp +++ b/src/plugins/intel_gpu/src/plugin/transformations/einsum_decomposition.cpp @@ -896,7 +896,7 @@ void contract_two_inputs(EinsumDecomposition* einsum_decompose_ptr, EinsumDecomposition::EinsumDecomposition() { ov::matcher_pass_callback callback = [this](ov::pass::pattern::Matcher& m) { - auto einsum_node = std::dynamic_pointer_cast(m.get_match_root()); + auto einsum_node = ov::as_type_ptr(m.get_match_root()); if (!einsum_node) { return false; } diff --git a/src/plugins/intel_gpu/src/plugin/transformations/fc_horizontal_fusion.cpp b/src/plugins/intel_gpu/src/plugin/transformations/fc_horizontal_fusion.cpp index 327de1424c34c9..48e4540384de27 100644 --- a/src/plugins/intel_gpu/src/plugin/transformations/fc_horizontal_fusion.cpp +++ b/src/plugins/intel_gpu/src/plugin/transformations/fc_horizontal_fusion.cpp @@ -38,19 +38,19 @@ FullyConnectedHorizontalFusion::FullyConnectedHorizontalFusion(bool fuse_mlp_swi // if it is not constant, the only allowed cases are Constant => convert // All FCs have same # of valid inputs (e.g., if one of the fc has zp, all fcs have zp) auto is_constant = [](const std::shared_ptr node) { - if (std::dynamic_pointer_cast(node)) + if (ov::as_type_ptr(node)) return true; - if (std::dynamic_pointer_cast(node) && std::dynamic_pointer_cast(node->get_input_node_shared_ptr(0))) + if (ov::as_type_ptr(node) && ov::as_type_ptr(node->get_input_node_shared_ptr(0))) return true; - if (std::dynamic_pointer_cast(node) && std::dynamic_pointer_cast(node->get_input_node_shared_ptr(0))) + if (ov::as_type_ptr(node) && ov::as_type_ptr(node->get_input_node_shared_ptr(0))) return true; return false; }; auto is_placeholder = [](const std::shared_ptr node) { - return std::dynamic_pointer_cast(node); + return ov::as_type_ptr(node); }; - const auto& fc = std::dynamic_pointer_cast(output.get_node_shared_ptr()); + const auto& fc = ov::as_type_ptr(output.get_node_shared_ptr()); const auto& input = fc->get_input_node_shared_ptr(0); if (!fc->get_input_partial_shape(0).is_dynamic()) return false; @@ -58,7 +58,7 @@ FullyConnectedHorizontalFusion::FullyConnectedHorizontalFusion(bool fuse_mlp_swi int32_t nodes_with_bias = 0; int32_t nodes_with_zp = 0; for (const auto& u : input->get_users()) { - const auto& fc_user = std::dynamic_pointer_cast(u); + const auto& fc_user = ov::as_type_ptr(u); if (!fc_user) continue; auto num_inputs = fc_user->inputs().size(); @@ -93,13 +93,13 @@ FullyConnectedHorizontalFusion::FullyConnectedHorizontalFusion(bool fuse_mlp_swi ov::NodeVector zp_nodes; int32_t bias_rank = -1; for (auto user : input_node->get_users()) { - auto fc_user = std::dynamic_pointer_cast(user); + auto fc_user = ov::as_type_ptr(user); if (fc_user) { OPENVINO_ASSERT(fc_user->inputs().size() >= 4, "Compressed FC should have at least 4 inputs"); fc_nodes.push_back(fc_user); fc_nodes_vec.push_back(fc_user); weight_nodes.push_back(fc_user->get_input_node_shared_ptr(1)); - if (!std::dynamic_pointer_cast(fc_user->get_input_node_shared_ptr(2))) { + if (!ov::as_type_ptr(fc_user->get_input_node_shared_ptr(2))) { if (bias_rank == -1) bias_rank = static_cast(fc_user->get_input_partial_shape(2).size()); if (bias_rank != static_cast(fc_user->get_input_partial_shape(2).size())) @@ -198,7 +198,7 @@ FullyConnectedHorizontalFusion::FullyConnectedHorizontalFusion(bool fuse_mlp_swi } } } - fc_nodes[i] = std::dynamic_pointer_cast(new_fc); + fc_nodes[i] = ov::as_type_ptr(new_fc); bias_node->clear_control_dependencies(); orig_fc->clear_control_dependencies(); } @@ -225,10 +225,10 @@ FullyConnectedHorizontalFusion::FullyConnectedHorizontalFusion(bool fuse_mlp_swi bool is_scalar = (ov::shape_size(zp_nodes[0]->get_output_shape(0)) == 1); int32_t scalar_zp_val = 0; if (is_scalar) { - if (auto zp_const = std::dynamic_pointer_cast(zp_nodes[0])) { + if (auto zp_const = ov::as_type_ptr(zp_nodes[0])) { scalar_zp_val = zp_const->cast_vector()[0]; - } else if (auto zp_convert = std::dynamic_pointer_cast(zp_nodes[0])) { - auto zp_const = std::dynamic_pointer_cast(zp_convert->get_input_node_shared_ptr(0)); + } else if (auto zp_convert = ov::as_type_ptr(zp_nodes[0])) { + auto zp_const = ov::as_type_ptr(zp_convert->get_input_node_shared_ptr(0)); scalar_zp_val = zp_const->cast_vector()[0]; } fused_zps = zp_nodes[0]; @@ -240,11 +240,11 @@ FullyConnectedHorizontalFusion::FullyConnectedHorizontalFusion(bool fuse_mlp_swi return false; // validate all zp values are same int32_t cur_zp_val = 0; - if (auto zp_const = std::dynamic_pointer_cast(zp_nodes[i])) { + if (auto zp_const = ov::as_type_ptr(zp_nodes[i])) { cur_zp_val = zp_const->cast_vector()[0]; - } else if (auto zp_convert = std::dynamic_pointer_cast(zp_nodes[i])) { + } else if (auto zp_convert = ov::as_type_ptr(zp_nodes[i])) { auto zp_const = - std::dynamic_pointer_cast(zp_convert->get_input_node_shared_ptr(0)); + ov::as_type_ptr(zp_convert->get_input_node_shared_ptr(0)); cur_zp_val = zp_const->cast_vector()[0]; } else { OPENVINO_ASSERT("Unsupported zp input node for FC horizontal fusion"); diff --git a/src/plugins/intel_gpu/src/plugin/transformations/fc_per_layer_scaling.cpp b/src/plugins/intel_gpu/src/plugin/transformations/fc_per_layer_scaling.cpp index 618578919d4024..c5c0e67fd4f751 100644 --- a/src/plugins/intel_gpu/src/plugin/transformations/fc_per_layer_scaling.cpp +++ b/src/plugins/intel_gpu/src/plugin/transformations/fc_per_layer_scaling.cpp @@ -30,7 +30,7 @@ FullyConnectedPerLayerScaling::FullyConnectedPerLayerScaling(float scale_factor) ov::matcher_pass_callback callback = [OV_CAPTURE_CPY_AND_THIS](Matcher& m) { if (scale_factor == 0.f || scale_factor == 1.f) return false; - auto fc = std::dynamic_pointer_cast(m.get_match_root()); + auto fc = ov::as_type_ptr(m.get_match_root()); if (!fc || transformation_callback(fc)) return false; @@ -53,7 +53,7 @@ FullyConnectedPerLayerScaling::FullyConnectedPerLayerScaling(float scale_factor) fc->input(0).replace_source_output(scale_down); // If FC has bias as input, scaling must be applied to bias as well - if (!std::dynamic_pointer_cast(bias)) { + if (!ov::as_type_ptr(bias)) { std::shared_ptr bias_scale_down_const = (bias->get_element_type() == ov::element::f16) ? scale_down_const_f16 : scale_down_const_f32; auto bias_scale_down = std::make_shared(bias, bias_scale_down_const); bias_scale_down->set_friendly_name(fc->get_friendly_name() + "_bias_scale_down"); diff --git a/src/plugins/intel_gpu/src/plugin/transformations/group_norm_composition.cpp b/src/plugins/intel_gpu/src/plugin/transformations/group_norm_composition.cpp index c298a2cb4bfb8e..ce9041cac4921b 100644 --- a/src/plugins/intel_gpu/src/plugin/transformations/group_norm_composition.cpp +++ b/src/plugins/intel_gpu/src/plugin/transformations/group_norm_composition.cpp @@ -57,7 +57,7 @@ GroupNormComposition::GroupNormComposition() { auto scale = pattern_map.at(scale_const_m); { // The total number of elements in scale must be equal to feature_dim. - auto const_scale = std::dynamic_pointer_cast(scale.get_node_shared_ptr()); + auto const_scale = ov::as_type_ptr(scale.get_node_shared_ptr()); auto const_scale_shape = const_scale->get_output_shape(0); int64_t const_scale_size = 1; for (auto& dim : const_scale_shape) { @@ -74,7 +74,7 @@ GroupNormComposition::GroupNormComposition() { auto bias = pattern_map.at(bias_const_m); { // The total number of elements in bias must be equal to feature_dim. - auto const_bias = std::dynamic_pointer_cast(bias.get_node_shared_ptr()); + auto const_bias = ov::as_type_ptr(bias.get_node_shared_ptr()); auto const_bias_shape = const_bias->get_output_shape(0); int64_t const_bias_size = 1; for (auto& dim : const_bias_shape) { @@ -89,11 +89,11 @@ GroupNormComposition::GroupNormComposition() { } auto bias_1d = std::make_shared(bias); - auto pre_reshape = std::dynamic_pointer_cast(pattern_map.at(pre_reshape_m).get_node_shared_ptr()); + auto pre_reshape = ov::as_type_ptr(pattern_map.at(pre_reshape_m).get_node_shared_ptr()); auto pre_reshape_pshape = pre_reshape->get_output_partial_shape(0); auto num_groups = pre_reshape_pshape[1].get_max_length(); - auto mvn = std::dynamic_pointer_cast(pattern_map.at(mvn_m).get_node_shared_ptr()); + auto mvn = ov::as_type_ptr(pattern_map.at(mvn_m).get_node_shared_ptr()); auto group_norm = std::make_shared(data, scale_1d, bias_1d, num_groups, mvn->get_eps()); diff --git a/src/plugins/intel_gpu/src/plugin/transformations/increase_position_ids_precision.cpp b/src/plugins/intel_gpu/src/plugin/transformations/increase_position_ids_precision.cpp index a79a339a501798..af7a73df4ba07e 100644 --- a/src/plugins/intel_gpu/src/plugin/transformations/increase_position_ids_precision.cpp +++ b/src/plugins/intel_gpu/src/plugin/transformations/increase_position_ids_precision.cpp @@ -50,9 +50,9 @@ IncreasePositionIdsPrecision::IncreasePositionIdsPrecision() { 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_node = std::dynamic_pointer_cast(pattern_map.at(gemm_or_matmul).get_node_shared_ptr()); - auto cos_node = std::dynamic_pointer_cast(pattern_map.at(cos).get_node_shared_ptr()); - auto sin_node = std::dynamic_pointer_cast(pattern_map.at(sin).get_node_shared_ptr()); + auto matmul_node = ov::as_type_ptr(pattern_map.at(gemm_or_matmul).get_node_shared_ptr()); + auto cos_node = ov::as_type_ptr(pattern_map.at(cos).get_node_shared_ptr()); + auto sin_node = ov::as_type_ptr(pattern_map.at(sin).get_node_shared_ptr()); if (!matmul_node || transformation_callback(matmul_node)) return false; @@ -74,7 +74,7 @@ IncreasePositionIdsPrecision::IncreasePositionIdsPrecision() { if (input_et == desired_et) continue; - auto in_convert = std::dynamic_pointer_cast(incoming_node); + auto in_convert = ov::as_type_ptr(incoming_node); if (in_convert && in_convert->get_users().size() == 1 && input_et.bitwidth() <= desired_et.bitwidth()) { auto convert = std::make_shared(incoming_node->input_value(0), desired_et); diff --git a/src/plugins/intel_gpu/src/plugin/transformations/indirect_kv_cache.cpp b/src/plugins/intel_gpu/src/plugin/transformations/indirect_kv_cache.cpp index 7ecf4f28496e4d..edd2c398ab8825 100644 --- a/src/plugins/intel_gpu/src/plugin/transformations/indirect_kv_cache.cpp +++ b/src/plugins/intel_gpu/src/plugin/transformations/indirect_kv_cache.cpp @@ -65,11 +65,11 @@ IndirectGemmOpt::IndirectGemmOpt() { } const auto& pattern_map = m.get_pattern_value_map(); - auto kv_cache_node = std::dynamic_pointer_cast(pattern_map.at(kv_cache).get_node_shared_ptr()); + auto kv_cache_node = ov::as_type_ptr(pattern_map.at(kv_cache).get_node_shared_ptr()); auto beam_idx_node = pattern_map.at(beam_idx).get_node_shared_ptr(); auto gather_input_node = pattern_map.at(gather_input).get_node_shared_ptr(); - auto gather_node = std::dynamic_pointer_cast(pattern_map.at(gather_past).get_node_shared_ptr()); + auto gather_node = ov::as_type_ptr(pattern_map.at(gather_past).get_node_shared_ptr()); auto gather_axis = gather_node->get_axis(); ov::replace_node(gather_node, gather_input_node); @@ -88,7 +88,7 @@ IndirectGemmOpt::IndirectGemmOpt() { auto kv_cache_users = indirect_kv_cache->get_output_target_inputs(0); auto matmul_kv_cache_index = kv_cache_users.begin()->get_index(); - auto gemm_node = std::dynamic_pointer_cast(m.get_match_root()); + auto gemm_node = ov::as_type_ptr(m.get_match_root()); auto order_in0 = gemm_node->get_input0_transpose_order(); auto order_in1 = gemm_node->get_input1_transpose_order(); auto order_out = gemm_node->get_output_transpose_order(); @@ -145,14 +145,14 @@ IndirectSDPAOpt::IndirectSDPAOpt() { } const auto& pattern_map = m.get_pattern_value_map(); - auto kv_cache_node_0 = std::dynamic_pointer_cast(pattern_map.at(kv_cache_0).get_node_shared_ptr()); - auto kv_cache_node_1 = std::dynamic_pointer_cast(pattern_map.at(kv_cache_1).get_node_shared_ptr()); + auto kv_cache_node_0 = ov::as_type_ptr(pattern_map.at(kv_cache_0).get_node_shared_ptr()); + auto kv_cache_node_1 = ov::as_type_ptr(pattern_map.at(kv_cache_1).get_node_shared_ptr()); auto beam_idx_node = pattern_map.at(beam_idx).get_node_shared_ptr(); auto gather_input_node_0 = pattern_map.at(gather_input_0).get_node_shared_ptr(); auto gather_input_node_1 = pattern_map.at(gather_input_1).get_node_shared_ptr(); - auto gather_node_0 = std::dynamic_pointer_cast(pattern_map.at(gather_past_0).get_node_shared_ptr()); - auto gather_node_1 = std::dynamic_pointer_cast(pattern_map.at(gather_past_1).get_node_shared_ptr()); + auto gather_node_0 = ov::as_type_ptr(pattern_map.at(gather_past_0).get_node_shared_ptr()); + auto gather_node_1 = ov::as_type_ptr(pattern_map.at(gather_past_1).get_node_shared_ptr()); auto gather_axis_0 = gather_node_0->get_axis(); auto gather_axis_1 = gather_node_1->get_axis(); OPENVINO_ASSERT(gather_axis_0 == gather_axis_1); @@ -183,7 +183,7 @@ IndirectSDPAOpt::IndirectSDPAOpt() { replace_node_unsafe(kv_cache_node_0, indirect_kv_cache_0); replace_node_unsafe(kv_cache_node_1, indirect_kv_cache_1); - auto sdpa = std::dynamic_pointer_cast(m.get_match_root()); + auto sdpa = ov::as_type_ptr(m.get_match_root()); auto order_in0 = sdpa->get_input0_transpose_order(); auto order_in1 = sdpa->get_input1_transpose_order(); auto order_in2 = sdpa->get_input2_transpose_order(); diff --git a/src/plugins/intel_gpu/src/plugin/transformations/kv_cache_compression.cpp b/src/plugins/intel_gpu/src/plugin/transformations/kv_cache_compression.cpp index 6b6150a8e32db4..6a50a55e619fc9 100644 --- a/src/plugins/intel_gpu/src/plugin/transformations/kv_cache_compression.cpp +++ b/src/plugins/intel_gpu/src/plugin/transformations/kv_cache_compression.cpp @@ -178,12 +178,12 @@ KVCacheCompressionMatcher::KVCacheCompressionMatcher(ov::element::Type compressi auto query_node = pattern_map.at(query).get_node_shared_ptr(); auto key_new_token_node = pattern_map.at(key_new_token).get_node_shared_ptr(); - auto key_cache_node = std::dynamic_pointer_cast(pattern_map.at(key_cache).get_node_shared_ptr()); - auto value_cache_node = std::dynamic_pointer_cast(pattern_map.at(value_cache).get_node_shared_ptr()); - auto sdpa_node = std::dynamic_pointer_cast(m.get_match_root()); + auto key_cache_node = ov::as_type_ptr(pattern_map.at(key_cache).get_node_shared_ptr()); + auto value_cache_node = ov::as_type_ptr(pattern_map.at(value_cache).get_node_shared_ptr()); + auto sdpa_node = ov::as_type_ptr(m.get_match_root()); - auto key_past_rv_node = std::dynamic_pointer_cast(pattern_map.at(key_past).get_node_shared_ptr()); - auto value_past_rv_node = std::dynamic_pointer_cast(pattern_map.at(value_past).get_node_shared_ptr()); + auto key_past_rv_node = ov::as_type_ptr(pattern_map.at(key_past).get_node_shared_ptr()); + auto value_past_rv_node = ov::as_type_ptr(pattern_map.at(value_past).get_node_shared_ptr()); auto data_rank = key_cache_node->get_input_partial_shape(0).size(); auto get_shape_group_sizes = [&](const std::vector& transposed_order) { diff --git a/src/plugins/intel_gpu/src/plugin/transformations/kv_cache_fusion.cpp b/src/plugins/intel_gpu/src/plugin/transformations/kv_cache_fusion.cpp index 7661673e764949..64095a744120a3 100644 --- a/src/plugins/intel_gpu/src/plugin/transformations/kv_cache_fusion.cpp +++ b/src/plugins/intel_gpu/src/plugin/transformations/kv_cache_fusion.cpp @@ -56,10 +56,10 @@ KVCacheFusionMatcher::KVCacheFusionMatcher() { } const auto& pattern_map = m.get_pattern_value_map(); - auto concat_node = std::dynamic_pointer_cast(pattern_map.at(concat).get_node_shared_ptr()); + auto concat_node = ov::as_type_ptr(pattern_map.at(concat).get_node_shared_ptr()); - auto past_node = std::dynamic_pointer_cast(pattern_map.at(past).get_node_shared_ptr()); - auto present_node = std::dynamic_pointer_cast(pattern_map.at(present).get_node_shared_ptr()); + auto past_node = ov::as_type_ptr(pattern_map.at(past).get_node_shared_ptr()); + auto present_node = ov::as_type_ptr(pattern_map.at(present).get_node_shared_ptr()); if (past_node->get_variable_id() != present_node->get_variable_id()) return false; diff --git a/src/plugins/intel_gpu/src/plugin/transformations/lora_horizontal_fusion.cpp b/src/plugins/intel_gpu/src/plugin/transformations/lora_horizontal_fusion.cpp index d9059e63338876..e31ada8173f11c 100644 --- a/src/plugins/intel_gpu/src/plugin/transformations/lora_horizontal_fusion.cpp +++ b/src/plugins/intel_gpu/src/plugin/transformations/lora_horizontal_fusion.cpp @@ -21,23 +21,23 @@ LoRAHorizontalFusion::LoRAHorizontalFusion() { auto is_lora_pattern = [](const std::shared_ptr& node) { #define check(node) if (!node) return false; - const auto& add = std::dynamic_pointer_cast(node); check(add) + const auto& add = ov::as_type_ptr(node); check(add) size_t matmul2_idx = ov::is_type(add->get_input_node_shared_ptr(0)) ? 0 : 1; - const auto& matmul2 = std::dynamic_pointer_cast(add->get_input_node_shared_ptr(matmul2_idx)); check(matmul2) + const auto& matmul2 = ov::as_type_ptr(add->get_input_node_shared_ptr(matmul2_idx)); check(matmul2) - const auto& multiply = std::dynamic_pointer_cast(matmul2->get_input_node_shared_ptr(0)); check(multiply) + const auto& multiply = ov::as_type_ptr(matmul2->get_input_node_shared_ptr(0)); check(multiply) - const auto& variable_b = std::dynamic_pointer_cast(matmul2->get_input_node_shared_ptr(1)); check(variable_b) + const auto& variable_b = ov::as_type_ptr(matmul2->get_input_node_shared_ptr(1)); check(variable_b) size_t matmul1_idx = ov::is_type(multiply->get_input_node_shared_ptr(0)) ? 0 : 1; - const auto& matmul1 = std::dynamic_pointer_cast(multiply->get_input_node_shared_ptr(matmul1_idx)); check(matmul1) + const auto& matmul1 = ov::as_type_ptr(multiply->get_input_node_shared_ptr(matmul1_idx)); check(matmul1) size_t alpha_idx = (matmul1_idx + 1) % 2; const auto& variable_alpha = - std::dynamic_pointer_cast(multiply->get_input_node_shared_ptr(alpha_idx)); check(variable_alpha) + ov::as_type_ptr(multiply->get_input_node_shared_ptr(alpha_idx)); check(variable_alpha) - const auto& variable_a = std::dynamic_pointer_cast(matmul1->get_input_node_shared_ptr(1)); check(variable_a) + const auto& variable_a = ov::as_type_ptr(matmul1->get_input_node_shared_ptr(1)); check(variable_a) #undef check return true; @@ -104,8 +104,8 @@ LoRAHorizontalFusion::LoRAHorizontalFusion() { "_fused_" + std::to_string(variable_alpha_nodes.size()) + "_ReadValues"); ov::copy_runtime_info(variable_alpha_nodes, fused_variable_alpha); - bool transpose_a1 = std::dynamic_pointer_cast(matmul1_nodes[0])->get_transpose_a(); - bool transpose_b1 = std::dynamic_pointer_cast(matmul1_nodes[0])->get_transpose_b(); + bool transpose_a1 = ov::as_type_ptr(matmul1_nodes[0])->get_transpose_a(); + bool transpose_b1 = ov::as_type_ptr(matmul1_nodes[0])->get_transpose_b(); auto fused_matmul1 = std::make_shared(pattern_map.at(lora_input), fused_variable_a, transpose_a1, transpose_b1); auto fused_matmul1_name = matmul1_nodes[0]->get_friendly_name() + "_fused_" + std::to_string(matmul1_nodes.size()) + "_MatMuls"; fused_matmul1->set_friendly_name(fused_matmul1_name); diff --git a/src/plugins/intel_gpu/src/plugin/transformations/op/gemm.cpp b/src/plugins/intel_gpu/src/plugin/transformations/op/gemm.cpp index 7c0622ec0e9bdd..63d7b9f3f8fa06 100644 --- a/src/plugins/intel_gpu/src/plugin/transformations/op/gemm.cpp +++ b/src/plugins/intel_gpu/src/plugin/transformations/op/gemm.cpp @@ -104,7 +104,7 @@ std::vector shape_infer(const Gemm* op, } OPENVINO_ASSERT(op != nullptr, "op should not be nullptr for shape_infer."); - auto out_shapes = ov::op::v0::shape_infer(dynamic_cast(op), std::vector{shape_a_t, shape_b_t}); + auto out_shapes = ov::op::v0::shape_infer(ov::as_type(op), std::vector{shape_a_t, shape_b_t}); if (order_c.size() > 0) { return { transpose_pshape(out_shapes[0], order_c) }; diff --git a/src/plugins/intel_gpu/src/plugin/transformations/op/sdpa.cpp b/src/plugins/intel_gpu/src/plugin/transformations/op/sdpa.cpp index 3988306ba5eff4..46a8ba621d1a25 100644 --- a/src/plugins/intel_gpu/src/plugin/transformations/op/sdpa.cpp +++ b/src/plugins/intel_gpu/src/plugin/transformations/op/sdpa.cpp @@ -161,7 +161,7 @@ std::vector shape_infer(const SDPA* op, } OPENVINO_ASSERT(op != nullptr, "op should not be nullptr for shape_infer."); - auto op_v13 = dynamic_cast(op); + auto op_v13 = ov::as_type(op); OPENVINO_ASSERT(op_v13 != nullptr, "ov::op::v13::ScaledDotProductAttention*>(op) should not be nullptr."); auto out_shapes = ov::op::v13::shape_infer(op_v13, transposed_input_shapes); diff --git a/src/plugins/intel_gpu/src/plugin/transformations/print_model_statistics.cpp b/src/plugins/intel_gpu/src/plugin/transformations/print_model_statistics.cpp index ece3b7487fc463..25d639b0f02530 100644 --- a/src/plugins/intel_gpu/src/plugin/transformations/print_model_statistics.cpp +++ b/src/plugins/intel_gpu/src/plugin/transformations/print_model_statistics.cpp @@ -22,7 +22,7 @@ size_t collect_stats(const std::shared_ptr& m, std::map(op)) { + if (auto subgraph_op = ov::as_type_ptr(op)) { for (const auto& subgraph : subgraph_op->get_functions()) { total += collect_stats(subgraph, ops_stat); } diff --git a/src/plugins/intel_gpu/src/plugin/transformations/transpose_fusion.cpp b/src/plugins/intel_gpu/src/plugin/transformations/transpose_fusion.cpp index f2fc64dedc7200..081497c920d7d3 100644 --- a/src/plugins/intel_gpu/src/plugin/transformations/transpose_fusion.cpp +++ b/src/plugins/intel_gpu/src/plugin/transformations/transpose_fusion.cpp @@ -41,7 +41,7 @@ bool has_optimized_version(const ov::Output& output, bool supports_imm if (!ov::is_type(order_node)) return false; - auto transpose_order = std::dynamic_pointer_cast(order_node)->cast_vector(); + auto transpose_order = ov::as_type_ptr(order_node)->cast_vector(); static const std::vector> allowed_orders = { {0, 1, 2, 3}, {0, 1, 3, 2}, @@ -81,7 +81,7 @@ TransposeSDPAMatcher::TransposeSDPAMatcher() { } }; auto not_transpose = [is_fp_type](const ov::Output& output) -> bool { - return std::dynamic_pointer_cast(output.get_node_shared_ptr()) == nullptr + return ov::as_type_ptr(output.get_node_shared_ptr()) == nullptr && is_fp_type(output); }; @@ -111,7 +111,7 @@ TransposeSDPAMatcher::TransposeSDPAMatcher() { ov::matcher_pass_callback callback = [OV_CAPTURE_CPY_AND_THIS](Matcher& m) { const auto& pattern_map = m.get_pattern_value_map(); - auto sdpa = std::dynamic_pointer_cast(m.get_match_root()); + auto sdpa = ov::as_type_ptr(m.get_match_root()); if (!sdpa || transformation_callback(sdpa)) { return false; @@ -129,14 +129,14 @@ TransposeSDPAMatcher::TransposeSDPAMatcher() { const std::shared_ptr& transpose_order_const_node, std::vector& order, size_t& output_idx) { - auto transpose_order_const = std::dynamic_pointer_cast(transpose_order_const_node); + auto transpose_order_const = ov::as_type_ptr(transpose_order_const_node); order = transpose_order_const->cast_vector(); // Allow any transposes without head_size dim position change if (order.back() != static_cast(order.size() - 1)) return false; - auto transpose = std::dynamic_pointer_cast(transpose_node); + auto transpose = ov::as_type_ptr(transpose_node); output_idx = transpose->get_input_source_output(0).get_index(); return true; @@ -191,7 +191,7 @@ TransposeSDPAMatcher::TransposeSDPAMatcher() { TransposeMatMulMatcher::TransposeMatMulMatcher(bool supports_immad) { auto not_transpose = [](const ov::Output& output) -> bool { - return std::dynamic_pointer_cast(output.get_node_shared_ptr()) == nullptr + return ov::as_type_ptr(output.get_node_shared_ptr()) == nullptr && output.get_element_type().is_real(); }; @@ -229,13 +229,13 @@ TransposeMatMulMatcher::TransposeMatMulMatcher(bool supports_immad) { ov::matcher_pass_callback callback = [OV_CAPTURE_CPY_AND_THIS](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; } auto users = matmul->get_output_target_inputs(0); - if (users.size() == 1 && dynamic_cast(users.begin()->get_node()) != nullptr) { + if (users.size() == 1 && ov::as_type(users.begin()->get_node()) != nullptr) { return false; } @@ -246,18 +246,18 @@ TransposeMatMulMatcher::TransposeMatMulMatcher(bool supports_immad) { size_t input_b_output_idx = matmul->get_input_source_output(1).get_index(); if (pattern_map.count(transpose_a_m) > 0) { - auto tranpose_a_order = std::dynamic_pointer_cast(pattern_map.at(transpose_a_order_m).get_node_shared_ptr()); + auto tranpose_a_order = ov::as_type_ptr(pattern_map.at(transpose_a_order_m).get_node_shared_ptr()); order_a = tranpose_a_order->cast_vector(); - auto tranpose_a = std::dynamic_pointer_cast(pattern_map.at(transpose_a_m).get_node_shared_ptr()); + auto tranpose_a = ov::as_type_ptr(pattern_map.at(transpose_a_m).get_node_shared_ptr()); input_a_output_idx = tranpose_a->get_input_source_output(0).get_index(); } if (matmul->get_transpose_a() && order_a.size() > 1) { std::swap(*(order_a.end() - 1), *(order_a.end() - 2)); } if (pattern_map.count(transpose_b_m) > 0) { - auto tranpose_b_order = std::dynamic_pointer_cast(pattern_map.at(transpose_b_order_m).get_node_shared_ptr()); + auto tranpose_b_order = ov::as_type_ptr(pattern_map.at(transpose_b_order_m).get_node_shared_ptr()); order_b = tranpose_b_order->cast_vector(); - auto tranpose_b = std::dynamic_pointer_cast(pattern_map.at(transpose_b_m).get_node_shared_ptr()); + auto tranpose_b = ov::as_type_ptr(pattern_map.at(transpose_b_m).get_node_shared_ptr()); input_b_output_idx = tranpose_b->get_input_source_output(0).get_index(); } if (matmul->get_transpose_b() && order_b.size() > 1) { @@ -280,7 +280,7 @@ TransposeMatMulMatcher::TransposeMatMulMatcher(bool supports_immad) { TransposeMatMulTransposeMatcher::TransposeMatMulTransposeMatcher(bool supports_immad) { auto not_transpose = [](const ov::Output& output) -> bool { - return std::dynamic_pointer_cast(output.get_node_shared_ptr()) == nullptr + return ov::as_type_ptr(output.get_node_shared_ptr()) == nullptr && output.get_element_type().is_real(); }; auto transpose_predicate = [supports_immad](const ov::Output& output) -> bool { @@ -303,12 +303,12 @@ TransposeMatMulTransposeMatcher::TransposeMatMulTransposeMatcher(bool supports_i ov::matcher_pass_callback callback = [OV_CAPTURE_CPY_AND_THIS](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; } - auto tranpose_c_order = std::dynamic_pointer_cast(pattern_map.at(transpose_c_order_m).get_node_shared_ptr()); + auto tranpose_c_order = ov::as_type_ptr(pattern_map.at(transpose_c_order_m).get_node_shared_ptr()); auto order_a = op::Gemm::default_order(matmul->get_input_partial_shape(0).size()); auto order_b = op::Gemm::default_order(matmul->get_input_partial_shape(1).size()); auto order_c = tranpose_c_order->cast_vector(); @@ -316,18 +316,18 @@ TransposeMatMulTransposeMatcher::TransposeMatMulTransposeMatcher(bool supports_i size_t input_b_output_idx = matmul->get_input_source_output(1).get_index(); if (pattern_map.count(transpose_a_m) > 0) { - auto tranpose_a_order = std::dynamic_pointer_cast(pattern_map.at(transpose_a_order_m).get_node_shared_ptr()); + auto tranpose_a_order = ov::as_type_ptr(pattern_map.at(transpose_a_order_m).get_node_shared_ptr()); order_a = tranpose_a_order->cast_vector(); - auto tranpose_a = std::dynamic_pointer_cast(pattern_map.at(transpose_a_m).get_node_shared_ptr()); + auto tranpose_a = ov::as_type_ptr(pattern_map.at(transpose_a_m).get_node_shared_ptr()); input_a_output_idx = tranpose_a->get_input_source_output(0).get_index(); } if (matmul->get_transpose_a() && order_a.size() > 1) { std::swap(*(order_a.end() - 1), *(order_a.end() - 2)); } if (pattern_map.count(transpose_b_m) > 0) { - auto tranpose_b_order = std::dynamic_pointer_cast(pattern_map.at(transpose_b_order_m).get_node_shared_ptr()); + auto tranpose_b_order = ov::as_type_ptr(pattern_map.at(transpose_b_order_m).get_node_shared_ptr()); order_b = tranpose_b_order->cast_vector(); - auto tranpose_b = std::dynamic_pointer_cast(pattern_map.at(transpose_b_m).get_node_shared_ptr()); + auto tranpose_b = ov::as_type_ptr(pattern_map.at(transpose_b_m).get_node_shared_ptr()); input_b_output_idx = tranpose_b->get_input_source_output(0).get_index(); } if (matmul->get_transpose_b() && order_b.size() > 1) { diff --git a/src/plugins/intel_gpu/src/plugin/transformations/unsqueeze_broadcast_reshape_matmul_fusion.cpp b/src/plugins/intel_gpu/src/plugin/transformations/unsqueeze_broadcast_reshape_matmul_fusion.cpp index a62b65d3ceb24a..6a2a9ba627573b 100644 --- a/src/plugins/intel_gpu/src/plugin/transformations/unsqueeze_broadcast_reshape_matmul_fusion.cpp +++ b/src/plugins/intel_gpu/src/plugin/transformations/unsqueeze_broadcast_reshape_matmul_fusion.cpp @@ -23,7 +23,7 @@ UnsqueezeBroadcastReshapeMatmulFusion::UnsqueezeBroadcastReshapeMatmulFusion() { using namespace ov::pass::pattern; auto not_reshape = [](const ov::Output& output) -> bool { - return std::dynamic_pointer_cast(output.get_node_shared_ptr()) == nullptr; + return ov::as_type_ptr(output.get_node_shared_ptr()) == nullptr; }; auto unsqueeze_predicate = [](const ov::Output& output) -> bool { @@ -58,8 +58,8 @@ UnsqueezeBroadcastReshapeMatmulFusion::UnsqueezeBroadcastReshapeMatmulFusion() { auto valid_broadcast_target_shape = [](const std::vector& target_shape) { return std::count_if(target_shape.begin(), target_shape.end(), [](int32_t s) { return s != 1; }) == 1; }; - auto broadcast = std::dynamic_pointer_cast(pattern_map.at(broadcast_m).get_node_shared_ptr()); - auto target_shape_constant = std::dynamic_pointer_cast(broadcast->get_input_node_shared_ptr(1)); + auto broadcast = ov::as_type_ptr(pattern_map.at(broadcast_m).get_node_shared_ptr()); + auto target_shape_constant = ov::as_type_ptr(broadcast->get_input_node_shared_ptr(1)); if (target_shape_constant) { auto target_shape_val = target_shape_constant->cast_vector(); if (!valid_broadcast_target_shape(target_shape_val)) @@ -69,7 +69,7 @@ UnsqueezeBroadcastReshapeMatmulFusion::UnsqueezeBroadcastReshapeMatmulFusion() { auto input_a = pattern_map.at(input_a_m).get_node_shared_ptr(); auto input_b = pattern_map.at(input_b_m).get_node_shared_ptr(); - auto matmul = std::dynamic_pointer_cast(m.get_match_root()); + auto matmul = ov::as_type_ptr(m.get_match_root()); auto order_a = matmul->get_input0_transpose_order(); auto order_b = matmul->get_input1_transpose_order(); auto order_c = matmul->get_output_transpose_order(); diff --git a/src/plugins/intel_gpu/src/plugin/transformations/unsqueeze_broadcast_reshape_sdpa_fusion.cpp b/src/plugins/intel_gpu/src/plugin/transformations/unsqueeze_broadcast_reshape_sdpa_fusion.cpp index 3f4480eaef0cbb..9d5ea8db863556 100644 --- a/src/plugins/intel_gpu/src/plugin/transformations/unsqueeze_broadcast_reshape_sdpa_fusion.cpp +++ b/src/plugins/intel_gpu/src/plugin/transformations/unsqueeze_broadcast_reshape_sdpa_fusion.cpp @@ -72,11 +72,11 @@ UnsqueezeBroadcastReshapeSDPAFusion::UnsqueezeBroadcastReshapeSDPAFusion() { auto valid_broadcast_target_shape = [](const std::vector& target_shape) { return std::count_if(target_shape.begin(), target_shape.end(), [](int32_t s) { return s != 1; }) == 1; }; - auto broadcast_b = std::dynamic_pointer_cast(pattern_map.at(broadcast_b_m).get_node_shared_ptr()); - auto broadcast_c = std::dynamic_pointer_cast(pattern_map.at(broadcast_c_m).get_node_shared_ptr()); + auto broadcast_b = ov::as_type_ptr(pattern_map.at(broadcast_b_m).get_node_shared_ptr()); + auto broadcast_c = ov::as_type_ptr(pattern_map.at(broadcast_c_m).get_node_shared_ptr()); std::vector target_shape_val_b; - auto target_shape_constant_b = std::dynamic_pointer_cast(broadcast_c->get_input_node_shared_ptr(1)); + auto target_shape_constant_b = ov::as_type_ptr(broadcast_c->get_input_node_shared_ptr(1)); if (target_shape_constant_b) { target_shape_val_b = target_shape_constant_b->cast_vector(); if (!valid_broadcast_target_shape(target_shape_val_b)) { @@ -85,7 +85,7 @@ UnsqueezeBroadcastReshapeSDPAFusion::UnsqueezeBroadcastReshapeSDPAFusion() { } std::vector target_shape_val_c; - auto target_shape_constant_c = std::dynamic_pointer_cast(broadcast_b->get_input_node_shared_ptr(1)); + auto target_shape_constant_c = ov::as_type_ptr(broadcast_b->get_input_node_shared_ptr(1)); if (target_shape_constant_c) { target_shape_val_c = target_shape_constant_c->cast_vector(); if (!valid_broadcast_target_shape(target_shape_val_c)) { @@ -103,7 +103,7 @@ UnsqueezeBroadcastReshapeSDPAFusion::UnsqueezeBroadcastReshapeSDPAFusion() { data_inputs.push_back(pattern_map.at(input_b_m).get_node_shared_ptr()); // K data_inputs.push_back(pattern_map.at(input_c_m).get_node_shared_ptr()); // V - auto sdpa = std::dynamic_pointer_cast(m.get_match_root()); + auto sdpa = ov::as_type_ptr(m.get_match_root()); if (pattern_map.find(sdpa_with_attn_mask_m) != pattern_map.end()) { data_inputs.push_back(sdpa->get_input_source_output(3)); // attn_mask } else if (pattern_map.find(sdpa_with_attn_mask_and_scale_m) != pattern_map.end()) { diff --git a/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp b/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp index 662323813aa27f..618988352d8be6 100644 --- a/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp +++ b/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp @@ -414,7 +414,7 @@ void TransformationsPipeline::apply(std::shared_ptr func) { if (!config.get_property(ov::intel_gpu::hint::enable_sdpa_optimization)) return false; - auto sdpa = std::dynamic_pointer_cast(node); + auto sdpa = ov::as_type_ptr(node); const auto& query_ps = sdpa->get_input_partial_shape(0); const auto& key_ps = sdpa->get_input_partial_shape(1); const auto& value_ps = sdpa->get_input_partial_shape(2); @@ -563,13 +563,13 @@ void TransformationsPipeline::apply(std::shared_ptr func) { } auto isCellPrimitiveSupported = [](const_node_ptr &node) -> bool { - if (std::dynamic_pointer_cast(node)) { + if (ov::as_type_ptr(node)) { return false; - } else if (std::dynamic_pointer_cast(node)) { + } else if (ov::as_type_ptr(node)) { return false; - } else if (const auto &lstm_cell = std::dynamic_pointer_cast(node)) { + } else if (const auto &lstm_cell = ov::as_type_ptr(node)) { return false; - } else if (const auto &lstm_cell_v1 = std::dynamic_pointer_cast(node)) { + } else if (const auto &lstm_cell_v1 = ov::as_type_ptr(node)) { return lstm_cell_v1->get_clip() == 0.0f && lstm_cell_v1->get_activations() == std::vector{"sigmoid", "tanh", "tanh"}; } return false; @@ -586,11 +586,11 @@ void TransformationsPipeline::apply(std::shared_ptr func) { auto max_seq_len = data_pshape[1]; if (data_pshape.rank().is_static() && data_pshape.rank().get_length() > 1 && !data_pshape[1].is_static()) return false; - if (std::dynamic_pointer_cast(node)) { + if (ov::as_type_ptr(node)) { return false; - } else if (std::dynamic_pointer_cast(node)) { + } else if (ov::as_type_ptr(node)) { return false; - } else if (const auto &lstm_seq = std::dynamic_pointer_cast(node)) { + } else if (const auto &lstm_seq = ov::as_type_ptr(node)) { return lstm_seq->get_clip() == 0.0f && lstm_seq->get_activations() == std::vector{"sigmoid", "tanh", "tanh"} && max_seq_len != 1 && @@ -629,9 +629,9 @@ void TransformationsPipeline::apply(std::shared_ptr func) { pass_config->set_callback( [](const_node_ptr &node) -> bool { - const auto mvn = std::dynamic_pointer_cast(node); + const auto mvn = ov::as_type_ptr(node); if (mvn != nullptr && node->get_input_size() == 2) { - if (auto axes_node = dynamic_cast(mvn->get_input_node_ptr(1))) { + if (auto axes_node = ov::as_type(mvn->get_input_node_ptr(1))) { auto mvn_axes = axes_node->cast_vector(); auto out_rank = mvn->get_output_partial_shape(0).size(); ov::util::try_normalize_axes(mvn_axes, out_rank, *mvn); @@ -882,7 +882,7 @@ void TransformationsPipeline::apply(std::shared_ptr func) { auto pass_config = manager.get_pass_config(); pass_config->set_callback( [unroll_loop](const std::shared_ptr &node) -> bool { - auto sub_graph_op = std::dynamic_pointer_cast(node); + auto sub_graph_op = ov::as_type_ptr(node); int64_t num_iter = sub_graph_op->get_num_iterations(); if (!unroll_loop) return num_iter != 1; diff --git a/src/plugins/intel_gpu/tests/common/subgraphs_builders.hpp b/src/plugins/intel_gpu/tests/common/subgraphs_builders.hpp index 381cfd7dd6bb93..c774049fe0690f 100644 --- a/src/plugins/intel_gpu/tests/common/subgraphs_builders.hpp +++ b/src/plugins/intel_gpu/tests/common/subgraphs_builders.hpp @@ -180,7 +180,7 @@ inline std::shared_ptr make_llm_kv_cache_pattern(ov::Dimension batch if (build_state_initializer) { auto state_initializer = make_state_initializer(in_new_token, element_type, kv_cache_size, {0, 1, 2, 3}); for (auto op : model->get_ops()) { - if (auto read_value = std::dynamic_pointer_cast(op)) { + if (auto read_value = ov::as_type_ptr(op)) { read_value->set_arguments(ov::OutputVector{state_initializer}); } } @@ -312,7 +312,7 @@ inline std::shared_ptr make_llm_kv_cache_sdpa_pattern(ov::Dimension b ov::pass::MakeStateful({{past_k, present_k}, {past_v, present_v}}).run_on_model(model); auto state_initializer = make_state_initializer(in_v_token, element_type, kv_cache_size, qkv_order); for (auto op : model->get_ops()) { - if (auto read_value = std::dynamic_pointer_cast(op)) { + if (auto read_value = ov::as_type_ptr(op)) { read_value->set_arguments(ov::OutputVector{state_initializer}); } } diff --git a/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/top_k.cpp b/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/top_k.cpp index 4532baf455a4ee..dcdff1f7eda3d9 100644 --- a/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/top_k.cpp +++ b/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/top_k.cpp @@ -88,11 +88,11 @@ class TopKLayerGPUTest : public testing::WithParamInterface topk; if (input_type == ov::test::utils::InputLayerType::CONSTANT) { auto k = std::make_shared(ov::element::i64, ov::Shape{}, &keepK); - topk = std::dynamic_pointer_cast(std::make_shared(params[0], k, axis, mode, sort)); + topk = ov::as_type_ptr(std::make_shared(params[0], k, axis, mode, sort)); } else { auto k = std::make_shared(ov::element::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)); } @@ -207,4 +207,3 @@ INSTANTIATE_TEST_SUITE_P(smoke_TopK_parameter_dynamic, TopKLayerGPUTest, TopKLayerGPUTest::getTestCaseName); } // namespace - diff --git a/src/plugins/intel_npu/src/plugin/npuw/partitioning/partitioning.cpp b/src/plugins/intel_npu/src/plugin/npuw/partitioning/partitioning.cpp index b4c101d2bae06d..73ea8f6b601feb 100644 --- a/src/plugins/intel_npu/src/plugin/npuw/partitioning/partitioning.cpp +++ b/src/plugins/intel_npu/src/plugin/npuw/partitioning/partitioning.cpp @@ -636,9 +636,9 @@ void Partitioner::identifySubgraphs() { // It happens when this layer is the original model's output // Keep it to make the ugly top-level I/O matching procedure work. // FIXME: This needs to be refactored - group.sg._results.push_back(std::dynamic_pointer_cast(maybe_result)); + group.sg._results.push_back(ov::as_type_ptr(maybe_result)); result_cache[output_layer_ptr] = - LinkPtrFrom{this_group_idx, std::dynamic_pointer_cast(maybe_result)}; + LinkPtrFrom{this_group_idx, ov::as_type_ptr(maybe_result)}; } else if (has_external_readers) { // Introduce and record a new Result // As the graph is processed in the topological order, diff --git a/src/plugins/intel_npu/src/plugin/npuw/util.cpp b/src/plugins/intel_npu/src/plugin/npuw/util.cpp index ffefb747ffb18f..f6bb6f439cff25 100644 --- a/src/plugins/intel_npu/src/plugin/npuw/util.cpp +++ b/src/plugins/intel_npu/src/plugin/npuw/util.cpp @@ -110,7 +110,7 @@ ov::Tensor ov::npuw::util::tensor_from_const(const std::shared_ptr& no NPUW_ASSERT(ov::op::util::is_constant(node)); NPUW_ASSERT(node->outputs().size() == 1); const auto port = node->output(0); - auto cnst_node = std::dynamic_pointer_cast(node); + auto cnst_node = ov::as_type_ptr(node); return ov::Tensor(port.get_element_type(), port.get_shape(), const_cast(cnst_node->get_data_ptr())); }