[GPU] Don't invalidate users after reorder insertion (#19137)

This commit is contained in:
Sergey Shlyapnikov 2023-08-14 14:16:54 +04:00 committed by GitHub
parent 4996d1f034
commit 86c4c6785d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 0 deletions

View File

@ -200,6 +200,7 @@ void add_required_reorders::run(program& p) {
auto new_reorder = std::make_shared<reorder>(input.id() + "_padding_reorder_" + usr->id(), input.id(), layout_wo_padding);
auto& new_reorder_node = p.get_or_create(new_reorder);
p.add_intermediate(new_reorder_node, *usr, idx);
new_reorder_node.recalc_output_layout(false);
} else {
continue;
}

View File

@ -147,6 +147,39 @@ TEST(add_required_reorders, prevent_input_dt_changing_for_convs) {
ASSERT_EQ(prog->get_node("conv1").get_input_layout(0).data_type, data_types::u8);
}
TEST(add_required_reorders, prevent_users_invalidation) {
auto& engine = get_test_engine();
// Create padded input memory
auto input_mem_padded = engine.allocate_memory({ {1, 16, 8, 8}, data_types::f16, format::bfyx, padding{{0, 0, 2, 2}, 0} });
auto weights_mem = engine.allocate_memory({ {16, 16, 1, 1}, data_types::f16, format::bfyx });
auto input = input_layout("input", input_mem_padded->get_layout());
auto weights = data("weights", weights_mem);
auto conv = convolution("conv", input_info("input"), "weights", "", 1, { 1, 1 }, { 1, 1 }, { 1, 1 }, { 2, 2 }, false);
auto prog = program::build_program(engine,
topology(input, weights, conv),
get_test_default_config(engine),
false,
true);
ASSERT_NE(prog, nullptr);
ASSERT_TRUE(prog->has_node("conv"));
const auto& conv_node = prog->get_node("conv");
// Force OneDNN impl type to insert padded_layout -> non_padded_layout reorder
prog->get_node("conv").set_preferred_impl_type(impl_types::onednn);
program_wrapper::apply_opt_pass<add_required_reorders>(*prog);
const auto& conv_input = conv_node.get_dependency(0);
ASSERT_TRUE(conv_input.is_type<reorder>());
ASSERT_TRUE(conv_input.is_valid_output_layout());
}
TEST(add_required_reorders, skip_adding_reorder_batch_axis_padding) {
auto& engine = get_test_engine();