[GPU][DG2] Fix unit test: test_select_preferred_formats.setting_target_conv_format (#14837)

* Fix wrong weight shape
* Output layout initialization
* Ensure preferred output format is selected
This commit is contained in:
Felix Dohyun Kim 2023-01-02 17:36:18 +09:00 committed by GitHub
parent a8fa767f41
commit 9cde294b7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -1868,7 +1868,7 @@ void layout_optimizer::select_preferred_formats_for_onednn(program_node& node, d
}
if (node.get_preferred_output_fmt() == format::any) {
for (size_t usr = 0 ; usr < node.get_users().size() ; usr++)
for (size_t usr = 0; usr < std::max<size_t>(1, node.get_users().size()); usr++)
node.set_preferred_output_fmt(usr, dst_fmt);
}

View File

@ -25,12 +25,12 @@ using namespace testing;
TEST(test_select_preferred_formats, setting_target_conv_format) {
auto& engine = get_test_engine();
auto input = engine.allocate_memory({ data_types::f16, format::bfyx, { 1, 32, 64, 64 } });
auto weights = engine.allocate_memory({ data_types::f16, format::bfyx, { 1, 32, 64, 64 } });
auto weights = engine.allocate_memory({ data_types::f16, format::bfyx, { 32, 32, 3, 3 } });
topology topology;
topology.add(data("weights", weights));
topology.add(input_layout("input", input->get_layout()));
topology.add(reorder("reorder", input_info("input"), format::b_fs_yx_fsv16, data_types::f16)),
topology.add(reorder("reorder", input_info("input"), format::b_fs_yx_fsv16, data_types::f16));
topology.add(convolution("conv1", input_info("reorder"), { "weights" }));
build_options build;
@ -41,6 +41,9 @@ TEST(test_select_preferred_formats, setting_target_conv_format) {
layout_optimizer lo(true);
auto prog = program::build_program(engine, topology, build, false, true);
// It initializes output_layout.
// It's necessary because this test runs select_preferred_formats pass alone.
prog->get_node("conv1").get_output_layouts(false);
program_wrapper::apply_opt_pass<select_preferred_formats>(*prog, lo);
ASSERT_NE(prog, nullptr);