Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GPU] Fix static_impl != nullptr assertion for reorder node #27786

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
//

#include "broadcast_inst.h"
#include "shape_of_inst.h"
#include "read_value_inst.h"
#include "reshape_inst.h"
Expand Down Expand Up @@ -86,6 +87,13 @@ bool mark_shape_of_subgraphs::can_mark_node(const program_node& node) {
return false;
}

// skip mark_node for broadcast node if dependency nodes are data and shape_of
sshlyapn marked this conversation as resolved.
Show resolved Hide resolved
auto& dependencies = node.get_dependencies();
if (node.is_type<broadcast>() && dependencies.size() == 2) {
if (dependencies[0].first->is_type<data>() && dependencies[1].first->is_type<shape_of>())
return false;
}

return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,3 +318,108 @@ TEST(mark_shape_of_subgraphs, gather_compressed_no_mark) {
ASSERT_FALSE(check_subgraph(prog->get_node("shape_of"), prog->get_node("gather_compressed")));
ASSERT_FALSE(check_subgraph(prog->get_node("shape_of"), prog->get_node("concat")));
}

TEST(mark_shape_of_subgraphs, broadcast_not_existed_after_shapeof) {
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};
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("weights", weights));
topology.add(shape_of("shape_of", input_info("input"), data_types::i32));
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);
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);

auto prog = network.get_program();
ASSERT_NE(prog, nullptr);

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

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};
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(broadcast("broadcast", input_info("data_0"), input_info("shape_of"), {}, 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));
config.set_property(ov::intel_gpu::optimize_data(true));
network network(engine, topology, config);

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_indirect_shapeof) {
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};
auto data_0 = engine.allocate_memory({ ov::PartialShape{1}, data_types::i32, format::bfyx });
set_values(data_0, {0});

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));

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);

auto prog = network.get_program();
ASSERT_NE(prog, nullptr);

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

TEST(mark_shape_of_subgraphs, broadcast_w_direct_shapeof_and_data) {
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};
auto target_shape = engine.allocate_memory({ ov::PartialShape{4}, data_types::i32, format::bfyx });
set_values(target_shape, {4, 4, 1, 1});

topology topology;
topology.add(input_layout("input", input_layout_dynamic));
topology.add(data("target_shape", target_shape));
topology.add(shape_of("shape_of", input_info("input"), data_types::i32));
topology.add(broadcast("broadcast", input_info("shape_of"), input_info("target_shape"), {}, ov::op::BroadcastType::BIDIRECTIONAL));
topology.add(reshape("reshape", input_info("input"), input_info("broadcast"), false, ov::PartialShape{4, 4, 1, 1}));

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);

auto prog = network.get_program();
ASSERT_NE(prog, nullptr);

ASSERT_TRUE(check_subgraph(prog->get_node("shape_of"), prog->get_node("broadcast")));
}
Loading