From 457a67a08288f5adda706c8f9036fe767e8a55ca Mon Sep 17 00:00:00 2001 From: "yuan.xiong" Date: Thu, 12 Dec 2024 13:46:56 +0800 Subject: [PATCH] Skip mark_node in shape flow for broadcast node if dependency nodes are data and shape_of Signed-off-by: yuan.xiong --- .../mark_shape_of_subgraphs.cpp | 109 +----------------- 1 file changed, 6 insertions(+), 103 deletions(-) diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/mark_shape_of_subgraphs.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/mark_shape_of_subgraphs.cpp index d8e4f2288ada85..7108a4870289c2 100644 --- a/src/plugins/intel_gpu/src/graph/graph_optimizer/mark_shape_of_subgraphs.cpp +++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/mark_shape_of_subgraphs.cpp @@ -16,119 +16,22 @@ using namespace cldnn; -namespace { - bool has_input_layout_dep(const std::vector>& shape_of_deps) { - for (auto& shape_of_dep : shape_of_deps) { - // input_layout node - if (shape_of_dep.first->is_type()) { - return true; - } - } - return false; - } - - bool has_shape_of_dep(const std::vector>& broadcast_deps) { - for (auto& broadcast_dep : broadcast_deps) { - // shape_of node - if (broadcast_dep.first->is_type()) { - auto& shape_of_deps = broadcast_dep.first->get_dependencies(); - return has_input_layout_dep(shape_of_deps); - } - } - return false; - } - - bool has_broadcast_dep(const std::vector>& reorder_deps) { - for (auto& reorder_dep : reorder_deps) { - // broadcast node - if (reorder_dep.first->is_type()) { - auto& broadcast_deps = reorder_dep.first->get_dependencies(); - return has_shape_of_dep(broadcast_deps); - } - } - return false; - } - - bool has_reorder_reoder_dep(const std::vector>& eltwise_deps) { - for (auto& eltwise_dep : eltwise_deps) { - // reorder node (reorder -> eltwise) - if (eltwise_dep.first->is_type()) { - auto& eltwise_dep_reorder_deps = eltwise_dep.first->get_dependencies(); - - for (auto& eltwise_dep_reorder_dep : eltwise_dep_reorder_deps) { - // reorder node (broadcast -> reorder) - if (eltwise_dep_reorder_dep.first->is_type()) { - auto& reorder_dep_reorder_deps = eltwise_dep_reorder_dep.first->get_dependencies(); - return has_broadcast_dep(reorder_dep_reorder_deps); - } - } - } - } - return false; - } - - bool has_eltwise_dep(const std::vector>& reorder_deps) { - for (auto& reorder_dep : reorder_deps) { - // eltwise node - if (reorder_dep.first->is_type()) { - auto& eltwise_deps = reorder_dep.first->get_dependencies(); - return has_reorder_reoder_dep(eltwise_deps); - } - } - return false; - } - - bool has_reorder_dep(const std::vector>& conv_deps) { - for (auto& conv_dep : conv_deps) { - //if (conv_dep.first->id().find(dequantize_name) != std::string::npos) { - - // reorder node ( reorder -> convolution) - if (conv_dep.first->is_type()) { - auto& reorder_deps = conv_dep.first->get_dependencies(); - return has_eltwise_dep(reorder_deps); - } - } - return false; - } - - bool has_convolution_dep(const std::vector>& dependencies) { - for (auto& dependency : dependencies) { - // convolution node - if (dependency.first->is_type()) { - auto& conv_deps = dependency.first->get_dependencies(); - return has_reorder_dep(conv_deps); - } - } - return false; - } - - // check dependencies for reorder node added for convolution in quantized model - bool skip_quantization_conv_reorder(const program_node& node) { - // reorder -> convolution -> reorder -> eltwise -> reorder -> reorder -> broadcast -> shape_of -> input_layout - if (!node.is_type()) { - return false; - } - - auto& dependencies = node.get_dependencies(); - return has_convolution_dep(dependencies); - } - -} // namespace - void mark_shape_of_subgraphs::look_for_shape_of_subgraph(program_node& node) { if (node.is_type()) { mark_node(node); return; } - // skip mark_node for reorder node (after convolution node) for quantized model - if (skip_quantization_conv_reorder(node)) { - return; - } + // skip mark_node for broadcast node if dependency nodes are data and shape_of + auto& dependencies = node.get_dependencies(); + if (node.is_type() && dependencies.size() == 2) { + if (dependencies[0].first->is_type() && dependencies[1].first->is_type()) + return; // Check if all dependencies are constant or marked as a part of shape_of subgraph bool can_execute_in_subgraph = true; bool has_shape_of_subgraph_dep = false; + for (auto& dependency : node.get_dependencies()) { if (dependency.first->is_in_shape_of_subgraph()) { has_shape_of_subgraph_dep = true;