[GPU] Remove reorder fix (#17691)

This commit is contained in:
Andrei Gorbachev 2023-05-25 11:32:32 +01:00 committed by GitHub
parent 5e299c1949
commit 71dcdf8a28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 0 deletions

View File

@ -349,6 +349,9 @@ void remove_redundant_reorders::run(program& p) {
if (node->get_dependencies().size() != 1) if (node->get_dependencies().size() != 1)
continue; continue;
if (node->has_fused_primitives())
continue;
auto& dep = node->get_dependency(0); auto& dep = node->get_dependency(0);
for (auto& user : dep.get_users()) { for (auto& user : dep.get_users()) {

View File

@ -17,6 +17,7 @@
#include "convolution_inst.h" #include "convolution_inst.h"
#include "permute_inst.h" #include "permute_inst.h"
#include "reshape_inst.h" #include "reshape_inst.h"
#include "activation_inst.h"
#include "pass_manager.h" #include "pass_manager.h"
#include "to_string_utils.h" #include "to_string_utils.h"
@ -211,3 +212,31 @@ TEST(remove_redundant_reorders, not_to_fuse_permute) {
network network(engine, topology, config); network network(engine, topology, config);
} }
TEST(remove_redundant_reorders, remove_fused) {
auto& engine = get_test_engine();
layout output_layout_fp16( data_types::f16, format::bfyx, { 1, 3, 2, 2 } );
layout output_layout_fp32( data_types::f32, format::bfyx, { 2, 3, 1, 2 } );
auto input1 = engine.allocate_memory({ data_types::f32, format::bfyx, { 1, 3, 2, 2 } });
topology topology;
topology.add(input_layout("input1", input1->get_layout()));
topology.add(reorder("reorder1", input_info("input1"), output_layout_fp16));
topology.add(activation("act", input_info("reorder1"), activation_func::relu));
topology.add(reorder("reorder2", input_info("input1"), output_layout_fp16));
topology.add(eltwise("sum", input_info("reorder2"), input_info("act"), eltwise_mode::sum));
topology.add(reorder("reorder3", input_info("sum"), output_layout_fp32));
ExecutionConfig config = get_test_default_config(engine);
config.set_property(ov::intel_gpu::optimize_data(true));
auto prog = program::build_program(engine, topology, config, false, true);
layout_optimizer lo(true);
program_wrapper::apply_opt_pass<prepare_primitive_fusing>(*prog, lo);
bool optimize_data = config.get_property(ov::intel_gpu::optimize_data);
program_wrapper::apply_opt_pass<remove_redundant_reorders>(*prog, lo, optimize_data);
ASSERT_NE(prog, nullptr);
network network(engine, topology, config);
ASSERT_TRUE(has_node(*prog, "reorder2"));
}