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

[CPU]remove useless convert pair(Convert[a->b] -> Convert[b->a]) #27868

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

xipingyan
Copy link
Contributor

Details:

  • Remove useless Convert pair(Convert[a->b] -> Convert[b->a])
  • In order to fix some test fail. introduce DisableEliminateUselessConvert.
  • Don't add test case. A little upgrade can cover it in the functional test "ConcatSDPTransposeTestSetState"

Tickets:

  • ticket-id

Don't add test case. A little upgrade can cover it in the functional test "ConcatSDPTransposeTestSetState"

Signed-off-by: xipingya <[email protected]>
1: Rootcause: I removed useless convert, but some test still need it.
Just add "DisableEliminateUselessConvert" runtime info to disable it.
2: some test function test also need it.

Signed-off-by: xipingya <[email protected]>
@github-actions github-actions bot added category: IE Tests OpenVINO Test: plugins and common category: CPU OpenVINO CPU plugin category: Python API OpenVINO Python bindings category: transformations OpenVINO Runtime library - Transformations labels Dec 3, 2024
I still have concern here.

why is "filterSupportedPrimitiveDescriptors" called for parameter node here?

Signed-off-by: xipingya <[email protected]>
             .convert_element_type(element::f32);

still need to call DisableEliminateUselessConvert

Signed-off-by: xipingya <[email protected]>
@github-actions github-actions bot added the category: TEMPLATE OpenVINO Template plugin label Dec 6, 2024
@xipingyan xipingyan force-pushed the xp/remove_useless_convert branch from aa4610b to 786302e Compare December 6, 2024 07:03
@xipingyan
Copy link
Contributor Author

hi @maxnick @dmitry-gorokhov @zhangYiIntel , I am not sure my solution is right or not (https://github.com/openvinotoolkit/openvino/pull/27868/files#diff-7a7a15dded44a2171cd0b23b2e456097939e46394ef697f601ee55d0772b36d6R457-R468),
Because many tests contain these patterns, they will cause many tests to fail.
If you think my solution is feasible, I will continue to fix these test fail, if not, I will close it.
Could you please help comment it? Thanks.

if (convert && convert->get_output_size() > 0u && convert->get_input_size() > 0u) {
auto convert2 = ov::as_type_ptr<ov::op::v0::Convert>(
convert->get_output_target_inputs(0).begin()->get_node()->shared_from_this());
if (convert2 && convert->get_input_element_type(0) == convert2->get_output_element_type(0) &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general such optimization is not safe. Cases like Convert[fp32->fp16] -> Convert[fp16->f32] still needs to be executed explicitly as long as its elemintation will affect model accuracy.

However we still can adjust the pass to the patterns which are safe to remove (then src/dst precisions can be converted to intermediate precision w/o any loss).
@itikhono Do you think it is reasonable extension for the existing EliminateConvert pass?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @dmitry-gorokhov for the clarification.

if (convert->get_input_element_type(0) == convert->get_element_type()) {
return replace_output_update_name(convert->output(0), convert->input_value(0));
}

// Only for some test.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is definetelly incorrect way to solve test failures. Test exptected behavior should be updated instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: CPU OpenVINO CPU plugin category: IE Tests OpenVINO Test: plugins and common category: Python API OpenVINO Python bindings category: TEMPLATE OpenVINO Template plugin category: transformations OpenVINO Runtime library - Transformations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants