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

[Good First Issue]: Possible Conditional Compilation Optimization for type_to_fuse_map #23069

Open
riverlijunjie opened this issue Feb 25, 2024 · 9 comments
Assignees
Labels
good first issue Good for newcomers no_stale Do not mark as stale

Comments

@riverlijunjie
Copy link
Contributor

riverlijunjie commented Feb 25, 2024

Context

Conditional Compilation is very helpful to optimize openvino binaries size for specified platforms and models, seems it can be used for type_to_fuse_map to do some binaries optimization:

type_to_fuse_map type_to_fuse{
{opset4::Convert::get_type_info_static(), fuse_type_to_convert},
{opset4::ShapeOf::get_type_info_static(), fuse_type_to_shapeof},
{opset6::Assign::get_type_info_static(),
m_store_original_precision_as_rt_attribute ? store_original_type_as_attribute : wrap_into_original_type},
{opset6::ReadValue::get_type_info_static(),
m_store_original_precision_as_rt_attribute ? store_original_type_as_attribute : wrap_into_original_type},
{opset3::NonMaxSuppression::get_type_info_static(), fuse_type_to_nms3},
{opset4::NonMaxSuppression::get_type_info_static(), fuse_type_to_nms4},
{opset5::NonMaxSuppression::get_type_info_static(), fuse_type_to_nms5},
{opset9::NonMaxSuppression::get_type_info_static(), fuse_type_to_nms9},
{op::v13::NMSRotated::get_type_info_static(), fuse_type_to_nms_rotated},
{opset8::MatrixNms::get_type_info_static(), fuse_type_to_matrix_nms},
{opset8::MulticlassNms::get_type_info_static(), fuse_type_to_multiclass_nms},
{opset9::MulticlassNms::get_type_info_static(), fuse_type_to_multiclass_nms},
{opset9::GenerateProposals::get_type_info_static(), fuse_type_to_generate_proposals},
{opset6::CTCGreedyDecoderSeqLen::get_type_info_static(), fuse_type_to_ctc_greedy_decoder_seq_len},
{opset1::TopK::get_type_info_static(), fuse_type_to_topk},
{opset4::TopK::get_type_info_static(), fuse_type_to_topk},
{opset11::TopK::get_type_info_static(), fuse_type_to_topk},
{opset8::MaxPool::get_type_info_static(), fuse_type_to_maxpool},
{opset4::NonZero::get_type_info_static(), fuse_type_to_nonzero},
{opset4::Bucketize::get_type_info_static(), fuse_type_to_bucketize},
{opset4::Equal::get_type_info_static(), fuse_type_to_binary_comparision<opset4::Equal>},
{opset4::NotEqual::get_type_info_static(), fuse_type_to_binary_comparision<opset4::NotEqual>},
{opset4::Greater::get_type_info_static(), fuse_type_to_binary_comparision<opset4::Greater>},
{opset4::GreaterEqual::get_type_info_static(), fuse_type_to_binary_comparision<opset4::GreaterEqual>},
{opset4::Less::get_type_info_static(), fuse_type_to_binary_comparision<opset4::Less>},
{opset4::LessEqual::get_type_info_static(), fuse_type_to_binary_comparision<opset4::LessEqual>},
{opset10::IsFinite::get_type_info_static(), fuse_type_to_binary_comparision<opset10::IsFinite>},
{opset10::IsNaN::get_type_info_static(), fuse_type_to_binary_comparision<opset10::IsNaN>},
{opset10::IsInf::get_type_info_static(), fuse_type_to_binary_comparision<opset10::IsInf>},
{opset4::LogicalAnd::get_type_info_static(), fuse_type_to_logical<opset4::LogicalAnd>},
{opset4::LogicalOr::get_type_info_static(), fuse_type_to_logical<opset4::LogicalOr>},
{opset4::LogicalXor::get_type_info_static(), fuse_type_to_logical<opset4::LogicalXor>},
{opset4::LogicalNot::get_type_info_static(), fuse_type_to_logical<opset4::LogicalNot>},
{opset1::Xor::get_type_info_static(), fuse_type_to_logical<opset1::Xor>},
{opset4::ReduceLogicalAnd::get_type_info_static(), fuse_type_to_reduce_logical<opset4::ReduceLogicalAnd>},
{opset4::ReduceLogicalOr::get_type_info_static(), fuse_type_to_reduce_logical<opset4::ReduceLogicalOr>},
{opset1::ShapeOf::get_type_info_static(), fuse_type_to_shapeof_v0},
{opset4::Range::get_type_info_static(), fuse_type_to_range_v4},
{opset9::Eye::get_type_info_static(), fuse_type_to_eye_v9},
{opset10::Unique::get_type_info_static(), fuse_type_to_unique_v10},
{opset8::RandomUniform::get_type_info_static(), fuse_type_to_random_uniform_v8},
{opset13::Multinomial::get_type_info_static(), fuse_type_to_multinomial_v13},
{opset1::PriorBox::get_type_info_static(), fuse_type_to_prior_box<opset1::PriorBox>},
{opset8::PriorBox::get_type_info_static(), fuse_type_to_prior_box<opset8::PriorBox>},
{opset1::PriorBoxClustered::get_type_info_static(), fuse_type_to_prior_box<opset1::PriorBoxClustered>}};

Need to consider usage of CC factory here, because in case of conditional compilation, this map will hold all the operations, which are not even used in the model.
See https://github.com/openvinotoolkit/openvino/blob/master/src/common/conditional_compilation/include/openvino/cc/factory.h

What needs to be done?

  1. Apply Conditional Compilation for type_to_fuse_map to optimize binaries size.
  2. Measure how many binaries size benefit can be achieved from this optimization.

Example Pull Requests

No response

Resources

Contact points

@riverlijunjie

Ticket

No response

@riverlijunjie riverlijunjie added good first issue Good for newcomers no_stale Do not mark as stale labels Feb 25, 2024
@github-project-automation github-project-automation bot moved this to Contributors Needed in Good first issues Feb 25, 2024
@RamyaKappagantu
Copy link

Hi @riverlijunjie , I would like to work on this task as a part of GSoC pre-requisite. Could you please assign this to me?

@ilya-lavrenov ilya-lavrenov moved this from Contributors Needed to Assigned in Good first issues Feb 28, 2024
@p-wysocki
Copy link
Contributor

Hello @RamyaKappagantu, are you still working on this? Is there anything we could help you with?

@p-wysocki p-wysocki moved this from Assigned to Contributors Needed in Good first issues Apr 3, 2024
@MirImaadAli1
Copy link

.take

Copy link
Contributor

github-actions bot commented Apr 8, 2024

Thank you for looking into this issue! Please let us know if you have any questions or require any help.

@p-wysocki p-wysocki moved this from Contributors Needed to Assigned in Good first issues Apr 8, 2024
@p-wysocki
Copy link
Contributor

Hello @MirImaadAli1, are you still working on that issue? Do you need any help?

@mlukasze mlukasze moved this from Assigned to Contributors Needed in Good first issues Jul 25, 2024
@11happy
Copy link
Contributor

11happy commented Jan 25, 2025

.take

Copy link
Contributor

Thank you for looking into this issue! Please let us know if you have any questions or require any help.

@11happy
Copy link
Contributor

11happy commented Feb 1, 2025

Hello @riverlijunjie , @p-wysocki is this the correct way to approach this problem,
first I define a CC domain , then I register a factory pattern via the factory class & then we use the createNodeifRequired method
I took reference from the tests implemented in this file src/common/conditional_compilation/tests/selective_build_analyzer.cpp

@11happy
Copy link
Contributor

11happy commented Feb 1, 2025

Currently I have it implemented this way on my end , would see if this corectly compiles & if I can see the binary size improvements . I did this selective build mentioned in this doc
https://github.com/openvinotoolkit/openvino/blob/master/src/common/conditional_compilation/docs/develop_cc_for_new_component.md
edit : this way is having some compilation issues that I am fixing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers no_stale Do not mark as stale
Projects
Status: Contributors Needed
Development

No branches or pull requests

5 participants