[shape_infer]Implement shape inference of DepthToSpace,SpaceToDepth, BatchToSpace,SpaceToBatch (#8465)

* Implement the batch to space shape infer

* Implement the space_to_batch shape inference.

* Implement shape infer of space_to_depth and depth_to_space OPs

* Fix Azure building issue.

* Add namespace for the shape_infer function.

* Avoid using friend declaration for shape infer.

* update coding style issue

* Update based on review comments

* Apply review comments

* Add test cases.

* Update the shape infer flow.

* Fix the bug in the previous test case.

* Update coding style.

* Fix the code bug caused by the DepthToSpace check fix.

* update coding style.

* Implment the Dimension/StaticDimension division operator by a value

* Refine the the code.

* Fix the issue when T is implicitly construct StaticShape with PartialShape when comparing

* Update the CI issue.

* Move the shape_infer helper into src folder.

* Apply the review comments.

* Coding style fix.

* Remove the ngraph folder

* Applied review comments

* Fix CI windows building issue

* Move test into new folder.

* Not support divisor is negative.

* Apply review comments.

* Fix CI issues

* Apply review comments.

* Update

Co-authored-by: Evgenya Stepyreva <evgenya.stepyreva@intel.com>
This commit is contained in:
Luwei ZhouandEvgenya Stepyreva authored and GitHub committed 2022-01-12 00:32:14 +00:00
1 parent 6fbfd96ba0
commit 5bf44b92e1
27 files changed
+757 -233

No files matched your search

@@ -38,6 +38,10 @@
#include "shape_inference.hpp"
#include "shape_nodes.hpp"
#include "fake_quantize.hpp"
#include "batch_to_space_shape_inference.hpp"
#include "depth_to_space_shape_inference.hpp"
#include "space_to_batch_shape_inference.hpp"
#include "space_to_depth_shape_inference.hpp"
#include "experimental_detectron_detection_output_shape_inference.hpp"
#include "bucketize_shape_inference.hpp"
#include "embedding_segments_sum_shape_inference.hpp"
@@ -230,6 +234,14 @@ void shape_inference(ov::Node* op,
shape_infer(node, input_shapes, output_shapes);
} else if (auto node = ov::as_type<ov::opset1::ShuffleChannels>(op)) {
shape_infer(node, input_shapes, output_shapes);
} else if (auto node = ov::as_type<ov::opset2::BatchToSpace>(op)) {
shape_infer(node, input_shapes, output_shapes, constant_data);
} else if (auto node = ov::as_type<ov::opset2::SpaceToBatch>(op)) {
shape_infer(node, input_shapes, output_shapes, constant_data);
} else if (auto node = ov::as_type<ov::opset1::DepthToSpace>(op)) {
shape_infer(node, input_shapes, output_shapes);
} else if (auto node = ov::as_type<ov::opset1::SpaceToDepth>(op)) {
shape_infer(node, input_shapes, output_shapes);
} else if (auto node = ov::as_type<ov::opset4::Broadcast>(op)) {
shape_infer(node, input_shapes, output_shapes, constant_data);
} else if (auto node = ov::as_type<ov::opset1::Broadcast>(op)) {
@@ -41,6 +41,19 @@ StaticDimension& StaticDimension::operator*=(const StaticDimension& dim) {
return (*this = *this * dim);
}
StaticDimension StaticDimension::operator/(const value_type divisor) const {
OPENVINO_ASSERT(divisor >= 0, "divisor must be greater than 0");
if (m_dimension % divisor) {
return StaticDimension{};
}
return StaticDimension(m_dimension / divisor);
}
StaticDimension& StaticDimension::operator/=(const value_type divisor) {
return (*this = *this / divisor);
}
StaticDimension StaticDimension::operator&(const StaticDimension& dim) const {
return (*this == dim) ? dim : 0;
}
@@ -60,6 +60,8 @@ public:
StaticDimension& operator+=(const StaticDimension& dim);
StaticDimension& operator*=(const StaticDimension& dim);
StaticDimension& operator&=(const StaticDimension& dim);
StaticDimension operator/(const value_type divisor) const;
StaticDimension &operator/=(const value_type divisor);
private:
value_type m_dimension = 0;