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

squeeze v15 implementation #26995

Merged
merged 54 commits into from
Oct 30, 2024
Merged

Conversation

barnasm1
Copy link
Contributor

@barnasm1 barnasm1 commented Oct 10, 2024

Details:

  • Add v15::Squeeze class with support dynamic rank result based on v0::Squeeze

Tickets:

@barnasm1 barnasm1 requested a review from a team as a code owner October 10, 2024 12:06
@barnasm1 barnasm1 self-assigned this Oct 10, 2024
@barnasm1 barnasm1 added the category: Core OpenVINO Core (aka ngraph) label Oct 10, 2024
@github-actions github-actions bot added the category: CPP API OpenVINO CPP API bindings label Oct 10, 2024
Copy link
Contributor

@mitruska mitruska left a comment

Choose a reason for hiding this comment

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

The changes should be covered by tests, as we have discussed please follow similar merged PR for example: #23754
The main reason for introducing new version of Squeeze op is the output shape inference logic update (not included in this PR so far).

Comment on lines 43 to 44
namespace v15 {
class OPENVINO_API Squeeze : public v0::Squeeze {
Copy link
Contributor

Choose a reason for hiding this comment

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

Usage of the previous op version as a base class seems convenient, but may lead to some issues.
For example, in the transformations the wrap_type<v0::Squeeze> will match to v15::Squeeze as well, because of its base class.

Also validate_and_infer_types will be called for the v0::Squeeze constructor (and for v15::Squeeze if overwritten to call updated shape_infer).

namespace v15 {
Squeeze::Squeeze(const Output<Node>& data, const Output<Node>& axes, const bool allow_axis_skip)
: v0::Squeeze({data, axes}),

Similar issue has been resolved for TopK (PR):
image


To follow current approach it would be better to create SqueezeBase class to share between v1::Squeeze and v15::Squeeze.

cc: @itikhono, @praasz

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@mlukasze mlukasze requested a review from mitruska October 21, 2024 05:03
@github-actions github-actions bot added the category: build OpenVINO cmake script / infra label Oct 22, 2024
src/core/tests/type_prop/squeeze.cpp Outdated Show resolved Hide resolved
src/core/tests/type_prop/squeeze.cpp Outdated Show resolved Hide resolved
src/core/tests/type_prop/squeeze.cpp Outdated Show resolved Hide resolved
src/core/tests/type_prop/squeeze.cpp Outdated Show resolved Hide resolved
@mlukasze mlukasze requested review from mmikolajcz and praasz October 30, 2024 05:49
@barnasm1 barnasm1 enabled auto-merge October 30, 2024 07:45
@praasz praasz disabled auto-merge October 30, 2024 07:50
@barnasm1 barnasm1 enabled auto-merge October 30, 2024 08:23
@@ -59,7 +170,7 @@ std::vector<TRShape> shape_infer(const Squeeze* op,
return dim.compatible(1);
});
if (has_squeezable_dim) {
output_shape = PartialShape::dynamic(arg_rank.get_length() - 1);
output_shape = PartialShape::dynamic({arg_rank.get_length() - 1, arg_rank.get_length()});
Copy link
Contributor

@mitruska mitruska Oct 30, 2024

Choose a reason for hiding this comment

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

Could you explain what is the expected result for such PartialShape definition and point specific unit test for this change?
It looks like Rank object initialized with range Dimension (while rank can be only static or dynamic, ranges for Rank are not supported).

output_shape = PartialShape::dynamic({arg_rank.get_length() - 1, arg_rank.get_length()})

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are a few test for that particular case: 6450f72#diff-17ddb7d4bd361c05e41dd9a2e22a538ddf79520a78bdd0fef7373540fe31ffddR100
If needed I can change it to fully dynamic result instead of expected Rank range.

Copy link
Contributor

Choose a reason for hiding this comment

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

The defined range for the rank has no effect here.
Such instantiation always leads to fully dynamic dimension, the provided range for the Rank is ignored.
All of the tests with replaced PartialShape::dynamic({2, 3}) to PartialShape::dynamic() will pass.

ov::PartialShape ov::PartialShape::dynamic(Rank r) {
return PartialShape(r.is_static(),
std::vector<Dimension>(r.is_static() ? r.get_length() : 0, Dimension::dynamic()));

Copy link
Contributor

@mitruska mitruska left a comment

Choose a reason for hiding this comment

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

The range defined for the Rank has no effect,
such instantiation always leads to fully dynamic dimension, the provided range for the Rank is ignored.
All of the implemented tests with expected PartialShape::dynamic({2, 3}) replaced to PartialShape::dynamic() will pass as well.

src/core/tests/type_prop/squeeze.cpp Outdated Show resolved Hide resolved
src/core/tests/type_prop/squeeze.cpp Outdated Show resolved Hide resolved
src/core/tests/type_prop/squeeze.cpp Outdated Show resolved Hide resolved
src/core/tests/type_prop/squeeze.cpp Outdated Show resolved Hide resolved
src/core/tests/type_prop/squeeze.cpp Outdated Show resolved Hide resolved
src/core/tests/type_prop/squeeze.cpp Outdated Show resolved Hide resolved
Comment on lines +433 to +438
EXPECT_EQ(squeeze->get_output_partial_shape(0), exp_shape.to_shape());
}
{
const auto squeeze = std::make_shared<op::v15::Squeeze>(param, axes_node);
EXPECT_EQ(squeeze->get_element_type(), element::f64);
EXPECT_EQ(squeeze->get_output_partial_shape(0), exp_shape.to_shape());
Copy link
Contributor

Choose a reason for hiding this comment

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

Is .to_shape() really needed while comparing with PartialShape?

@@ -59,7 +170,7 @@ std::vector<TRShape> shape_infer(const Squeeze* op,
return dim.compatible(1);
});
if (has_squeezable_dim) {
output_shape = PartialShape::dynamic(arg_rank.get_length() - 1);
output_shape = PartialShape::dynamic({arg_rank.get_length() - 1, arg_rank.get_length()});
Copy link
Contributor

Choose a reason for hiding this comment

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

The defined range for the rank has no effect here.
Such instantiation always leads to fully dynamic dimension, the provided range for the Rank is ignored.
All of the tests with replaced PartialShape::dynamic({2, 3}) to PartialShape::dynamic() will pass.

ov::PartialShape ov::PartialShape::dynamic(Rank r) {
return PartialShape(r.is_static(),
std::vector<Dimension>(r.is_static() ? r.get_length() : 0, Dimension::dynamic()));

@barnasm1 barnasm1 added this pull request to the merge queue Oct 30, 2024
Merged via the queue into openvinotoolkit:master with commit 6e35049 Oct 30, 2024
166 checks passed
@barnasm1 barnasm1 deleted the squeeze_v15_class branch October 30, 2024 19:04
github-merge-queue bot pushed a commit that referenced this pull request Oct 31, 2024
### Details:
- *Add Squeeze-15 downgrade transformation to Squeeze-0 for compatible
attribute*
 - *...*

### Tickets:
 - *CVS-154027*

### PR requires
[PR-26995](#26995) to be
merged

---------

Co-authored-by: Michal Lukaszewski <[email protected]>
github-merge-queue bot pushed a commit that referenced this pull request Oct 31, 2024
### Details:
- This PR includes commits from
#26995

### Tickets:
 - CVS-154024

---------

Signed-off-by: p-wysocki <[email protected]>
Co-authored-by: Michal Barnas <[email protected]>
Co-authored-by: Roman Kazantsev <[email protected]>
Co-authored-by: Michal Lukaszewski <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: build OpenVINO cmake script / infra category: Core OpenVINO Core (aka ngraph) category: CPP API OpenVINO CPP API bindings category: CPU OpenVINO CPU plugin category: IE Tests OpenVINO Test: plugins and common category: TEMPLATE OpenVINO Template plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants