-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
squeeze v15 implementation #26995
Conversation
There was a problem hiding this 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).
namespace v15 { | ||
class OPENVINO_API Squeeze : public v0::Squeeze { |
There was a problem hiding this comment.
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).
openvino/src/core/src/op/squeeze.cpp
Lines 127 to 129 in be046ac
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):
To follow current approach it would be better to create SqueezeBase
class to share between v1::Squeeze
and v15::Squeeze
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
src/plugins/intel_cpu/tests/unit/shape_inference_test/squeeze_shape_inference_test.cpp
Outdated
Show resolved
Hide resolved
src/plugins/intel_cpu/tests/unit/shape_inference_test/squeeze_shape_inference_test.cpp
Outdated
Show resolved
Hide resolved
@@ -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()}); |
There was a problem hiding this comment.
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()})
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
openvino/src/core/src/partial_shape.cpp
Lines 174 to 176 in 961b891
ov::PartialShape ov::PartialShape::dynamic(Rank r) { | |
return PartialShape(r.is_static(), | |
std::vector<Dimension>(r.is_static() ? r.get_length() : 0, Dimension::dynamic())); |
There was a problem hiding this 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.
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()); |
There was a problem hiding this comment.
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()}); |
There was a problem hiding this comment.
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.
openvino/src/core/src/partial_shape.cpp
Lines 174 to 176 in 961b891
ov::PartialShape ov::PartialShape::dynamic(Rank r) { | |
return PartialShape(r.is_static(), | |
std::vector<Dimension>(r.is_static() ? r.get_length() : 0, Dimension::dynamic())); |
### 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]>
### 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]>
Details:
Tickets: