Skip to content

Commit

Permalink
[GPU] Disable using port indices for query mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyamin-Roman committed Mar 12, 2024
1 parent 9086a07 commit bbda257
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ class ProgramBuilder final {
bool use_new_shape_infer() const { return allow_new_shape_infer; }
bool requires_new_shape_infer(const std::shared_ptr<ov::Node>& op) const;
bool is_inner_program() const { return m_is_inner_program; }
bool is_query_mode() { return queryMode; }

std::shared_ptr<ov::threading::IStreamsExecutor> get_task_executor() const { return m_task_executor; }
std::shared_ptr<cldnn::ICompilationContext> get_compilation_context() const { return m_compilation_context; }
Expand Down
26 changes: 20 additions & 6 deletions src/plugins/intel_gpu/src/plugin/ops/parameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,13 @@ static void CreateParameterOp(ProgramBuilder& p, const std::shared_ptr<ov::op::v
// look at the expected color format of this input
auto input_name = layer_type_name_ID(op);
cldnn::layout input_layout(input_pshape, element_type, input_format);
int64_t port_index = p.get_parameter_index(op);
OPENVINO_ASSERT(port_index != -1, "[GPU] Parameter port index for ", input_name, " not found");

bool query_mode = p.is_query_mode();
int64_t port_index = -1;
if (!query_mode) {
port_index = p.get_parameter_index(op);
OPENVINO_ASSERT(port_index != -1, "[GPU] Parameter port index for ", input_name, " not found");
}

auto is_convert_color_type = [](const std::shared_ptr<ov::Node> &node) {
return ov::is_type<ov::op::v8::NV12toRGB>(node) ||
Expand Down Expand Up @@ -85,7 +90,10 @@ static void CreateParameterOp(ProgramBuilder& p, const std::shared_ptr<ov::op::v
size_t batch = input_pshape[0].get_length();
input_layout.format = cldnn::format::nv12;
input_layout.set_partial_shape({ 1, input_pshape[1], input_pshape[2], input_pshape[3] });
p.inputLayouts.insert({ port_index, input_layout });

if (!query_mode) {
p.inputLayouts.insert({ port_index, input_layout });
}

std::string suffix = "";
std::vector<cldnn::input_info> surfaces_inputs;
Expand All @@ -94,7 +102,10 @@ static void CreateParameterOp(ProgramBuilder& p, const std::shared_ptr<ov::op::v
suffix = "_" + std::to_string(i);
std::string batched_name = input_name + suffix;
p.add_primitive(*op, cldnn::input_layout(batched_name, input_layout));
p.inputPrimitiveIDs[port_index].emplace_back(batched_name);

if (!query_mode) {
p.inputPrimitiveIDs[port_index].emplace_back(batched_name);
}

auto reorder_layout = input_layout;
reorder_layout.format = cldnn::format::bfyx;
Expand All @@ -116,8 +127,11 @@ static void CreateParameterOp(ProgramBuilder& p, const std::shared_ptr<ov::op::v
auto reorder_name = "reorder:" + input_name + ProgramBuilder::m_preProcessTag;

p.add_primitive(*op, cldnn::input_layout(input_name, input_layout));
p.inputPrimitiveIDs[port_index] = { input_name };
p.inputLayouts.insert({ port_index, input_layout });

if (!query_mode) {
p.inputPrimitiveIDs[port_index] = { input_name };
p.inputLayouts.insert({ port_index, input_layout });
}

if (connected_to_quantize(op)) {
// Techically this reorder is not needed, but for some reason it impacts layout propagation logic
Expand Down
8 changes: 5 additions & 3 deletions src/plugins/intel_gpu/src/plugin/ops/result.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ static void CreateResultOp(ProgramBuilder& p, const std::shared_ptr<ov::op::v0::
out_data_type);
p.add_primitive(*op, reorder_primitive, { input_id, op->get_friendly_name() });

int64_t port_index = p.get_result_index(op);
OPENVINO_ASSERT(port_index != -1, "[GPU] Result port index for ", input_id, " not found");
p.prevPrimitiveIDs[port_index] = input_id;
if (!p.is_query_mode()) {
int64_t port_index = p.get_result_index(op);
OPENVINO_ASSERT(port_index != -1, "[GPU] Result port index for ", input_id, " not found");
p.prevPrimitiveIDs[port_index] = input_id;
}
}

REGISTER_FACTORY_IMPL(v0, Result);
Expand Down

0 comments on commit bbda257

Please sign in to comment.