Skip to content

[Feature Request]: Problem in comparison function #30261

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

Open
1 task done
zszZSZzzz opened this issue Apr 21, 2025 · 0 comments
Open
1 task done

[Feature Request]: Problem in comparison function #30261

zszZSZzzz opened this issue Apr 21, 2025 · 0 comments
Assignees
Labels
category: GPU OpenVINO GPU plugin enhancement New feature or request feature New feature request

Comments

@zszZSZzzz
Copy link

Request Description

Sort may return false result when input structs have all compared fields equal. This in turn may causes inconsistent order or even crashes in some qsort implementations.
The location of the error function is openvino/src/plugins/intel_gpu/src/graph/program.cpp.
According to the following part of the code, when the two input structures are exactly the same, the function may return true instead of false.
std::sort(nodes_to_allocate.begin(), nodes_to_allocate.end(), [&po](std::shared_ptr<program_node> const& lhs, std::shared_ptr<program_node> const& rhs) { auto lhs_layout = lhs->get_output_layout(); auto rhs_layout = rhs->get_output_layout(); if (lhs_layout.is_dynamic() && lhs_layout.has_upper_bound()) { lhs_layout.set_tensor(lhs_layout.get_tensor()); } if (rhs_layout.is_dynamic() && rhs_layout.has_upper_bound()) { rhs_layout.set_tensor(rhs_layout.get_tensor()); } if (rhs_layout.is_dynamic() && !rhs_layout.has_upper_bound() && lhs_layout.is_dynamic() && !lhs_layout.has_upper_bound()) { return po.get_processing_number(lhs.get()) < po.get_processing_number(rhs.get()); } if (rhs_layout.is_dynamic()) return true; if (lhs_layout.is_dynamic()) return false; return (lhs_layout.bytes_count() > rhs_layout.bytes_count()); });
The fix is to replace the last two if statements with
if (rhs_layout.is_dynamic() && !lhs_layout.is_dynamic()) return true; if (lhs_layout.is_dynamic() && !rhs_layout.is_dynamic()) return false;

Feature Use Case

No response

Issue submission checklist

  • The feature request or improvement must be related to OpenVINO
@zszZSZzzz zszZSZzzz added enhancement New feature or request feature New feature request labels Apr 21, 2025
@ilya-lavrenov ilya-lavrenov added the category: GPU OpenVINO GPU plugin label Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: GPU OpenVINO GPU plugin enhancement New feature or request feature New feature request
Projects
None yet
Development

No branches or pull requests

4 participants