Skip to content

Commit

Permalink
Clean code
Browse files Browse the repository at this point in the history
Signed-off-by: yuan.xiong <[email protected]>
  • Loading branch information
yuanxion committed Dec 22, 2024
1 parent ccfb6fe commit 697f77e
Showing 1 changed file with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -321,20 +321,18 @@ TEST(mark_shape_of_subgraphs, gather_compressed_no_mark) {

TEST(mark_shape_of_subgraphs, broadcast_not_existed_after_shapeof) {
auto& engine = get_test_engine();
auto reshape_pattern = engine.allocate_memory({ ov::PartialShape{4}, data_types::i32, format::bfyx });
set_values(reshape_pattern, {1, 4, 1, 1});
auto input_layout_dynamic = layout{ov::PartialShape{ov::Dimension::dynamic(), 4, ov::Dimension::dynamic(), ov::Dimension::dynamic()},
data_types::f32, format::bfyx};
auto data_0 = engine.allocate_memory({ ov::PartialShape{4}, data_types::i32, format::bfyx });
set_values(data_0, {1, 4, 1, 1});
auto weights = engine.allocate_memory({ data_types::f16, format::bfyx, {1152, 4, 1, 1} });

topology topology;
topology.add(input_layout("input", input_layout_dynamic));
topology.add(data("data_0", data_0));
topology.add(data("reshape_pattern", reshape_pattern));
topology.add(data("weights", weights));
topology.add(shape_of("shape_of", input_info("input"), data_types::i32));
topology.add(reshape("reshape", input_info("shape_of"), input_info("reshape_pattern"), false, {}));
topology.add(reshape("reshape", input_info("shape_of"), input_info("data_0"), false, {}));
topology.add(convolution("convolution", input_info("reshape"), "weights", "", 1, {1, 1}, {1, 1}, {0, 0}, {0, 0}, false));

ExecutionConfig config = get_test_default_config(engine);
Expand All @@ -348,7 +346,7 @@ TEST(mark_shape_of_subgraphs, broadcast_not_existed_after_shapeof) {
ASSERT_TRUE(check_subgraph(prog->get_node("shape_of"), prog->get_node("convolution")));
}

TEST(mark_shape_of_subgraphs, broadcast_w_data_and_shapeof_no_mark) {
TEST(mark_shape_of_subgraphs, broadcast_w_data_and_direct_shapeof_no_mark) {
auto& engine = get_test_engine();
auto input_layout_dynamic = layout{ov::PartialShape{ov::Dimension::dynamic(), 4, ov::Dimension::dynamic(), ov::Dimension::dynamic()},
data_types::f32, format::bfyx};
Expand All @@ -372,24 +370,23 @@ TEST(mark_shape_of_subgraphs, broadcast_w_data_and_shapeof_no_mark) {
auto prog = network.get_program();
ASSERT_NE(prog, nullptr);

ASSERT_FALSE(check_subgraph(prog->get_node("shape_of"), prog->get_node("convolution")));
ASSERT_FALSE(check_subgraph(prog->get_node("shape_of"), prog->get_node("broadcast")));
}

TEST(mark_shape_of_subgraphs, broadcast_w_data_and_shapeof_gather) {
TEST(mark_shape_of_subgraphs, broadcast_w_data_and_indirect_shapeof) {
auto& engine = get_test_engine();
auto input_layout_dynamic = layout{ov::PartialShape{1, 4, 2, 2}, data_types::f32, format::bfyx};
auto input_layout_dynamic = layout{ov::PartialShape{ov::Dimension::dynamic(), 4, ov::Dimension::dynamic(), ov::Dimension::dynamic()},
data_types::f32, format::bfyx};
auto data_0 = engine.allocate_memory({ ov::PartialShape{1}, data_types::i32, format::bfyx });
set_values(data_0, {0});
//auto weights = engine.allocate_memory({ data_types::f16, format::bfyx, {1152, 4, 2, 2} });

topology topology;
topology.add(input_layout("input", input_layout_dynamic));
topology.add(data("data_0", data_0));
topology.add(shape_of("shape_of", input_info("input"), data_types::i32));
topology.add(gather("gather", input_info("shape_of"), input_info("data_0"), 0, 0, {}));
topology.add(broadcast("broadcast", input_info("data_0"), input_info("gather"), {}, ov::op::BroadcastType::BIDIRECTIONAL));
//topology.add(data("weights", weights));
//topology.add(convolution("convolution", input_info("broadcast"), "weights", "", 1, {1, 1}, {1, 1}, {0, 0}, {0, 0}, false));

ExecutionConfig config = get_test_default_config(engine);
config.set_property(ov::intel_gpu::allow_new_shape_infer(true));
Expand All @@ -402,9 +399,10 @@ TEST(mark_shape_of_subgraphs, broadcast_w_data_and_shapeof_gather) {
ASSERT_TRUE(check_subgraph(prog->get_node("shape_of"), prog->get_node("broadcast")));
}

TEST(mark_shape_of_subgraphs, broadcast_w_shapeof_and_data) {
TEST(mark_shape_of_subgraphs, broadcast_w_direct_shapeof_and_data) {
auto& engine = get_test_engine();
auto input_layout_dynamic = layout{ov::PartialShape{1, 4, 2, 2}, data_types::f32, format::bfyx};
auto input_layout_dynamic = layout{ov::PartialShape{ov::Dimension::dynamic(), 4, ov::Dimension::dynamic(), ov::Dimension::dynamic()},
data_types::f32, format::bfyx};
auto target_shape = engine.allocate_memory({ ov::PartialShape{4}, data_types::i32, format::bfyx });
set_values(target_shape, {4, 4, 1, 1});

Expand Down

0 comments on commit 697f77e

Please sign in to comment.