[GPU] Fix permute reorder fusing bfzyx (#20896)
* fix accuracy issue of permute reorder fusing * add func test * remove debug code * use unit test * simplify condition * add additionall condition
This commit is contained in:
@@ -414,6 +414,7 @@ bool layout_optimizer::can_fuse_reorder(program_node& prev, program_node& next,
|
||||
}
|
||||
|
||||
bool layout_optimizer::can_fuse_reorder_to_prev(program_node& prev, reorder_node& node, format fmt_prev, format fmt_next) {
|
||||
bool allow_new_shape_infer = node.get_program().get_config().get_property(ov::intel_gpu::allow_new_shape_infer);
|
||||
// Because mvn and concatenation kernel can work cross-layout, if reorder only performs type conversion,
|
||||
// fusing reorder to the previous node can be done even if it is a dynamic shape case
|
||||
if ((prev.is_type<mvn>() || prev.is_type<concatenation>()) &&
|
||||
@@ -476,6 +477,10 @@ bool layout_optimizer::can_fuse_reorder_to_prev(program_node& prev, reorder_node
|
||||
if (fmt_prev.dimension() > 6 || fmt_next.dimension() > 6)
|
||||
return false;
|
||||
|
||||
// Skip reorder fusing to permute when allow_new_shape_infer is True and input and output rank is different
|
||||
if (allow_new_shape_infer && (fmt_prev.dimension() != fmt_next.dimension()))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -219,6 +219,37 @@ TEST(remove_redundant_reorders, not_to_fuse_permute) {
|
||||
network network(engine, topology, config);
|
||||
}
|
||||
|
||||
TEST(remove_redundant_reorders, not_to_fuse_permute_new_shape_infer) {
|
||||
auto& engine = get_test_engine();
|
||||
auto input1 = engine.allocate_memory({data_types::f16, format::bfyx, {4, 64, 512, 512}});
|
||||
auto input2 = engine.allocate_memory({data_types::f16, format::bfzyx, {1, 4, 64, 512, 512}});
|
||||
layout output_layout_fp16( data_types::f16, format::bfzyx, { 4, 512, 64, 512 } );
|
||||
|
||||
topology topology;
|
||||
topology.add(input_layout("input1", input1->get_layout()));
|
||||
topology.add(input_layout("input2", input2->get_layout()));
|
||||
topology.add(permute("permute", input_info("input1"), {0, 2, 3, 1}));
|
||||
topology.add(reorder("reorder1", input_info("permute"), output_layout_fp16));
|
||||
topology.add(reshape("reshape", input_info("reorder1"), false, {}, ov::PartialShape{1, 4, 512, 512, 64}));
|
||||
topology.add(concatenation("concat", {input_info("reshape"), input_info("input2")}, 4));
|
||||
|
||||
ExecutionConfig config = get_test_default_config(engine);
|
||||
config.set_property(ov::intel_gpu::allow_new_shape_infer(true));
|
||||
config.set_property(ov::intel_gpu::optimize_data(true));
|
||||
network network(engine, topology, config);
|
||||
network.set_input_data("input1", input1);
|
||||
network.set_input_data("input2", input2);
|
||||
|
||||
network.execute();
|
||||
|
||||
auto prog = network.get_program();
|
||||
ASSERT_NE(prog, nullptr);
|
||||
auto& permute_node = prog->get_node("permute");
|
||||
auto permute_layout = permute_node.get_output_layout();
|
||||
|
||||
ASSERT_EQ(permute_layout.format.value, format::bfyx);
|
||||
}
|
||||
|
||||
TEST(remove_redundant_reorders, remove_fused) {
|
||||
auto& engine = get_test_engine();
|
||||
layout output_layout_fp16( data_types::f16, format::bfyx, { 1, 3, 2, 2 } );
|
||||
|
||||
Reference in New Issue
Block a user