Skip to content

Commit

Permalink
[shape infer]Review Reshape class for shape inference aspects (openvi…
Browse files Browse the repository at this point in the history
…notoolkit#18679)

* Add static shape adapter
- Adapters holds CPU dimension which can be reference to it or vector
- Add ov::optional for holding optional result from shape inference
- Add new `infer` function in `IStaticShapeInfer`

* Temporary support of StaticShape

* Minor corrections in ShapeInferenceTA

* Migrate shape_infer to new interface version

* Replace StaticShape by adapter implementation

* Replace IShapeInferCommon by IStaticShapeInfer

* Correct code formatting

* Fix build issues

* NodeValidationFailure::create for StaticShapeRef

* Review shape inference for reshape operator
- review shape_infer implementation
- add more unit test for static and dynamic shapes

* Fix build issues

* Correct minus one dim calculation

* Fix build issues on windows

* Improve resolving special minus one

* Use NODE_SHAPE_INFER_CHECK

* Update product in/out calculations

* Temporary add ngraph header to solve build issue

* Correct minus one dim calc when static part same

* Add check for scalar input

* Remove debug message

* Fix `minus one` dynamic dimension calculation

* Fix `minus one` dynamic dimension calculation

* Fix merge issues in reshape
Minor refactor reshape evaluate

* Don't pass input label on minus one pattern
when input dimension will be modified.
  • Loading branch information
praasz authored Oct 27, 2023
1 parent 69e1258 commit 751d844
Show file tree
Hide file tree
Showing 12 changed files with 1,126 additions and 524 deletions.
8 changes: 4 additions & 4 deletions src/common/transformations/tests/utils/convert_precision.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2192,7 +2192,7 @@ TEST(TransformationTests, align_mixed_fp16_fp32_with_parameter_for_shape_1) {
auto upscale_const = ov::op::v0::Constant::create(element::f32, Shape{1}, {2.0f});
auto mul_1 = make_shared<ov::op::v1::Multiply>(shape_input, upscale_const);
auto axis_const = ov::op::v0::Constant::create(element::i64, Shape{1}, {0});
auto final_float_shape = make_shared<ov::op::v1::ReduceProd>(mul_1, axis_const);
auto final_float_shape = make_shared<ov::op::v1::ReduceProd>(mul_1, axis_const, true);
auto final_int_shape = make_shared<ov::op::v0::Convert>(final_float_shape, element::i64);
auto reshape_1 = make_shared<ov::op::v1::Reshape>(input_1, final_int_shape, false);

Expand All @@ -2214,7 +2214,7 @@ TEST(TransformationTests, align_mixed_fp16_fp32_with_parameter_for_shape_1) {
auto upscale_const = ov::op::v0::Constant::create(element::f32, Shape{1}, {2.0f});
auto mul_1 = make_shared<ov::op::v1::Multiply>(shape_input, upscale_const);
auto axis_const = ov::op::v0::Constant::create(element::i64, Shape{1}, {0});
auto final_float_shape = make_shared<ov::op::v1::ReduceProd>(mul_1, axis_const);
auto final_float_shape = make_shared<ov::op::v1::ReduceProd>(mul_1, axis_const, true);
auto final_int_shape = make_shared<ov::op::v0::Convert>(final_float_shape, element::i64);
auto reshape_1 = make_shared<ov::op::v1::Reshape>(input_1, final_int_shape, false);

Expand All @@ -2235,7 +2235,7 @@ TEST(TransformationTests, align_mixed_fp16_fp32_with_parameter_for_shape_2) {
auto upscale_const = ov::op::v0::Constant::create(element::f32, Shape{1}, {2.0f});
auto mul_1 = make_shared<ov::op::v1::Multiply>(shape_input, upscale_const);
auto axis_const = ov::op::v0::Constant::create(element::i64, Shape{1}, {0});
auto final_float_shape = make_shared<ov::op::v1::ReduceProd>(mul_1, axis_const);
auto final_float_shape = make_shared<ov::op::v1::ReduceProd>(mul_1, axis_const, true);
auto final_int_shape = make_shared<ov::op::v0::Convert>(final_float_shape, element::i64);
auto reshape_1 = make_shared<ov::op::v1::Reshape>(input_1, final_int_shape, false);

Expand All @@ -2260,7 +2260,7 @@ TEST(TransformationTests, align_mixed_fp16_fp32_with_parameter_for_shape_2) {
auto upscale_const = ov::op::v0::Constant::create(element::f32, Shape{1}, {2.0f});
auto mul_1 = make_shared<ov::op::v1::Multiply>(shape_input, upscale_const);
auto axis_const = ov::op::v0::Constant::create(element::i64, Shape{1}, {0});
auto final_float_shape = make_shared<ov::op::v1::ReduceProd>(mul_1, axis_const);
auto final_float_shape = make_shared<ov::op::v1::ReduceProd>(mul_1, axis_const, true);
auto final_int_shape = make_shared<ov::op::v0::Convert>(final_float_shape, element::i64);
auto reshape_1 = make_shared<ov::op::v1::Reshape>(convert_to_f16, final_int_shape, false);
auto convert_to_f32 = make_shared<ov::op::v0::Convert>(reshape_1, element::f32);
Expand Down
Loading

0 comments on commit 751d844

Please sign in to comment.