From a8272478a09c745a0efac9cbe13877600a57abb4 Mon Sep 17 00:00:00 2001 From: fishbell Date: Mon, 23 Dec 2024 18:36:20 +0800 Subject: [PATCH] clean up code Signed-off-by: fishbell --- .../include/intel_gpu/primitives/reorder.hpp | 7 +--- .../graph/graph_optimizer/compile_graph.cpp | 6 ++-- .../prepare_primitive_fusing.cpp | 1 - .../src/graph/impls/onednn/reorder_onednn.cpp | 6 +--- src/plugins/intel_gpu/src/graph/program.cpp | 1 - src/plugins/intel_gpu/src/graph/reorder.cpp | 34 ++----------------- 6 files changed, 6 insertions(+), 49 deletions(-) diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/reorder.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/reorder.hpp index 79256f500d20c2..ee53cbd8027087 100644 --- a/src/plugins/intel_gpu/include/intel_gpu/primitives/reorder.hpp +++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/reorder.hpp @@ -223,17 +223,12 @@ struct reorder : public primitive_base { memory_type input_mem_type = memory_type::buffer; /// @brief Parameters required for reorder weights. std::shared_ptr weights_reorder_params = {}; - /// @brief Parameters required for source transpose. - std::vector src_permutation; + inline bool has_surface_input() const { return input.size() == 1 && input_mem_type == memory_type::surface; } - void set_src_permutation(const std::vector & src_perm) { - this->src_permutation = src_perm; - } - /// @brief Convert truncation Mode bool truncate = false; diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/compile_graph.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/compile_graph.cpp index 585dfb505aa344..fb4d6bfa590312 100644 --- a/src/plugins/intel_gpu/src/graph/graph_optimizer/compile_graph.cpp +++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/compile_graph.cpp @@ -44,8 +44,6 @@ void compile_graph::run(program& p) { std::string fail_reason = ""; try { if (selected_impl_manager) { - if (node->id() == "reorder:/detect/Reshape_14_reorder") - std::cout << "break" << std::endl; node->selected_impl = selected_impl_manager->create(*node, *params); } } catch (std::exception& e) { @@ -64,8 +62,8 @@ void compile_graph::run(program& p) { }); } } - for (auto& iter : tasks) - task_executor->run_and_wait({iter}); + + task_executor->run_and_wait(tasks); tasks.clear(); if (exception) { diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_primitive_fusing.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_primitive_fusing.cpp index 93f0905b3a1ef7..96bb1a65da7279 100644 --- a/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_primitive_fusing.cpp +++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_primitive_fusing.cpp @@ -137,7 +137,6 @@ void prepare_primitive_fusing::fuse_reorders(program &p) { program_helpers::do_for_types(*node, [&p](reorder_node& node) { auto& input = node.input(); - // Restrictions: // - inputs cannot be padded // - primitives input cannot be output diff --git a/src/plugins/intel_gpu/src/graph/impls/onednn/reorder_onednn.cpp b/src/plugins/intel_gpu/src/graph/impls/onednn/reorder_onednn.cpp index 12738741f9c7b6..7e24cebd6b9ee9 100644 --- a/src/plugins/intel_gpu/src/graph/impls/onednn/reorder_onednn.cpp +++ b/src/plugins/intel_gpu/src/graph/impls/onednn/reorder_onednn.cpp @@ -54,11 +54,7 @@ struct reorder_onednn : typed_primitive_onednn_impl()->src_permutation; - if (permute_order.size()) - input_md = test_md.permute_axes({0, 3, 1, 2}); + auto input_md = onednn::layout_to_memory_desc(input_layout); auto output_md = onednn::layout_to_memory_desc(output_layout); OPENVINO_ASSERT(input_md.get_format_kind() != dnnl::memory::format_kind::any, diff --git a/src/plugins/intel_gpu/src/graph/program.cpp b/src/plugins/intel_gpu/src/graph/program.cpp index 6531c3e22627b2..d57df3f7d33c53 100644 --- a/src/plugins/intel_gpu/src/graph/program.cpp +++ b/src/plugins/intel_gpu/src/graph/program.cpp @@ -598,7 +598,6 @@ void program::pre_optimize_graph(bool is_internal) { apply_opt_pass(); } - apply_opt_pass(); // check if there exists some layout incompatibilities and add an reorder node if required apply_opt_pass(); diff --git a/src/plugins/intel_gpu/src/graph/reorder.cpp b/src/plugins/intel_gpu/src/graph/reorder.cpp index 5a2e83eeb8631f..49a0d7cd8ccef0 100644 --- a/src/plugins/intel_gpu/src/graph/reorder.cpp +++ b/src/plugins/intel_gpu/src/graph/reorder.cpp @@ -170,22 +170,7 @@ layout reorder_inst::calc_output_layout(reorder_node const& node, kernel_impl_pa // TODO Shouldn't transform be called every time ifmt != ofmt? return layout(odt, ofmt, input_layout.get_tensor().transform(ofmt, 1), op); } else { - // debug code, to fuse reorder with src permute - auto org_ps = input_layout.get_partial_shape(); - auto output_shape = ov::PartialShape(); - int64_t input_static_rank = org_ps.rank().get_length(); - auto permute_order = desc->src_permutation; - if (permute_order.empty()) { - for (int64_t i = 0; i <= input_static_rank - 1; ++i) { - permute_order.emplace_back(i); // for compliance first - } - } - - for (int64_t i = 0; i < input_static_rank; ++i) { - output_shape.push_back(org_ps[permute_order[i]]); - } - return { layout(odt, ofmt, ov::intel_gpu::tensor_from_dims(output_shape.to_shape()), desc->output_paddings[0]) }; - //return layout(odt, ofmt, input_layout.get_tensor(), op); + return layout(odt, ofmt, input_layout.get_tensor(), op); } } @@ -206,22 +191,7 @@ std::vector reorder_inst::calc_output_layouts(reorder_node const& /*node #endif // ENABLE_ONEDNN_FOR_GPU return { desc->weights_reorder_params->get_output_layout() }; } else { - // debug code, to fuse reorder with src permute - auto org_ps = input_layout.get(); - ShapeType output_shape; - int64_t input_static_rank = org_ps.rank().get_length(); - auto permute_order = desc->src_permutation; - if (permute_order.empty()) { - for (int64_t i = 0; i <= input_static_rank - 1; ++i) { - permute_order.emplace_back(i); // for compliance first - } - } - - for (int64_t i = 0; i < input_static_rank; ++i) { - output_shape.push_back(org_ps[permute_order[i]]); - } - return { layout(output_shape, desc->output_data_types[0].value(), ofmt, desc->output_paddings[0]) }; - //return { layout(input_layout.get(), desc->output_data_types[0].value(), ofmt, desc->output_paddings[0]) }; + return { layout(input_layout.get(), desc->output_data_types[0].value(), ofmt, desc->output_paddings[0]) }; } }