Skip to content

Commit

Permalink
Re-factor CPU shape inference tests to avoid names collisions
Browse files Browse the repository at this point in the history
Signed-off-by: Pawel Raasz <[email protected]>
  • Loading branch information
praasz committed Nov 27, 2024
1 parent 65e7463 commit a510f34
Show file tree
Hide file tree
Showing 82 changed files with 940 additions and 1,012 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ TEST_F(AdaptiveAvgPoolV8StaticShapeInferenceTest, default_ctor) {
const std::unordered_map<size_t, ov::Tensor> const_data{{1, {element::i32, ov::Shape{2}, spatial_dims}}};

op = make_op();
input_shapes = ShapeVector{{1, 3, 1, 2}, {2}};
input_shapes = StaticShapeVector{{1, 3, 1, 2}, {2}};
output_shapes = shape_inference(op.get(), input_shapes, const_data);

EXPECT_EQ(output_shapes.size(), 1);
Expand All @@ -37,7 +37,7 @@ TEST_F(AdaptiveAvgPoolV8StaticShapeInferenceTest, out_spatial_dims_as_constant)

op = make_op(data, out_shape);

input_shapes = ShapeVector{{1, 3, 10}, {1}};
input_shapes = StaticShapeVector{{1, 3, 10}, {1}};
output_shapes = shape_inference(op.get(), input_shapes);

EXPECT_EQ(output_shapes.size(), 1);
Expand All @@ -53,7 +53,7 @@ TEST_F(AdaptiveAvgPoolV8StaticShapeInferenceTest, out_spatial_dims_in_const_map)
int32_t spatial_dims[] = {9, 8, 7};
const std::unordered_map<size_t, ov::Tensor> const_data{{1, {element::i32, ov::Shape{3}, spatial_dims}}};

input_shapes = ShapeVector{{1, 3, 10, 2, 4}, {3}};
input_shapes = StaticShapeVector{{1, 3, 10, 2, 4}, {3}};
output_shapes = shape_inference(op.get(), input_shapes, const_data);

EXPECT_EQ(output_shapes.size(), 1);
Expand All @@ -69,7 +69,7 @@ TEST_F(AdaptiveAvgPoolV8StaticShapeInferenceTest, out_spatial_dims_in_const_map_
int32_t spatial_dims[] = {9, 8};
const std::unordered_map<size_t, ov::Tensor> const_data{{1, {element::i32, ov::Shape{2}, spatial_dims}}};

input_shapes = ShapeVector{{1, 3, 10, 2, 4}, {3}};
input_shapes = StaticShapeVector{{1, 3, 10, 2, 4}, {3}};
OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, const_data),
ov::NodeValidationFailure,
HasSubstr("Number of spatial dimensions is not compatible with input data rank"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ TEST_F(AdaptiveMaxPoolV8StaticShapeInferenceTest, default_ctor) {
const std::unordered_map<size_t, Tensor> const_data{{1, {element::i32, ov::Shape{2}, spatial_dims}}};

op = make_op();
input_shapes = ShapeVector{{1, 3, 1, 2}, {2}};
input_shapes = StaticShapeVector{{1, 3, 1, 2}, {2}};
output_shapes = shape_inference(op.get(), input_shapes, const_data);

EXPECT_EQ(output_shapes.size(), 2);
Expand All @@ -37,7 +37,7 @@ TEST_F(AdaptiveMaxPoolV8StaticShapeInferenceTest, out_spatial_dims_as_constant)

op = make_op(data, out_shape);

input_shapes = ShapeVector{{1, 3, 10}, {1}};
input_shapes = StaticShapeVector{{1, 3, 10}, {1}};
output_shapes = shape_inference(op.get(), input_shapes);

EXPECT_EQ(output_shapes.size(), 2);
Expand All @@ -53,7 +53,7 @@ TEST_F(AdaptiveMaxPoolV8StaticShapeInferenceTest, out_spatial_dims_in_const_map)
int32_t spatial_dims[] = {9, 8, 7};
const std::unordered_map<size_t, Tensor> const_data{{1, {element::i32, ov::Shape{3}, spatial_dims}}};

input_shapes = ShapeVector{{1, 3, 10, 2, 4}, {3}};
input_shapes = StaticShapeVector{{1, 3, 10, 2, 4}, {3}};
output_shapes = shape_inference(op.get(), input_shapes, const_data);

EXPECT_EQ(output_shapes.size(), 2);
Expand All @@ -69,7 +69,7 @@ TEST_F(AdaptiveMaxPoolV8StaticShapeInferenceTest, out_spatial_dims_in_const_map_
int32_t spatial_dims[] = {9, 8};
const std::unordered_map<size_t, Tensor> const_data{{1, {element::i32, ov::Shape{2}, spatial_dims}}};

input_shapes = ShapeVector{{1, 3, 10, 2, 4}, {3}};
input_shapes = StaticShapeVector{{1, 3, 10, 2, 4}, {3}};
OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, const_data),
ov::NodeValidationFailure,
HasSubstr("Number of spatial dimensions is not compatible with input data rank"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ TYPED_TEST_P(AvgPoolCommonStaticShapeInferenceTest, default_ctor) {
this->op->set_rounding_type(op::RoundingType::FLOOR);
this->op->set_auto_pad(op::PadType::VALID);

this->input_shapes = ShapeVector{{1, 3, 10, 12}};
this->input_shapes = StaticShapeVector{{1, 3, 10, 12}};
auto shape_infer = make_shape_inference(this->op);
const auto input_shape_refs = make_static_shape_refs(this->input_shapes);
this->output_shapes = *shape_infer->infer(input_shape_refs, make_tensor_accessor());
Expand All @@ -49,7 +49,7 @@ TYPED_TEST_P(AvgPoolCommonStaticShapeInferenceTest, no_auto_pad_round_floor) {

this->op = this->make_op(data, strides, pads_begin, pads_end, kernel_shape, false, rounding_mode, pad_type);

this->input_shapes = ShapeVector{{1, 3, 10, 12}};
this->input_shapes = StaticShapeVector{{1, 3, 10, 12}};
auto shape_infer = make_shape_inference(this->op);
const auto input_shape_refs = make_static_shape_refs(this->input_shapes);
this->output_shapes = *shape_infer->infer(input_shape_refs, make_tensor_accessor());
Expand All @@ -72,7 +72,7 @@ TYPED_TEST_P(AvgPoolCommonStaticShapeInferenceTest, auto_padding_same_lower_roun

this->op = this->make_op(data, strides, pads_begin, pads_end, kernel_shape, false, rounding_mode, pad_type);

this->input_shapes = ShapeVector{{1, 3, 10, 12, 20}};
this->input_shapes = StaticShapeVector{{1, 3, 10, 12, 20}};
auto shape_infer = make_shape_inference(this->op);
const auto input_shape_refs = make_static_shape_refs(this->input_shapes);
this->output_shapes = *shape_infer->infer(input_shape_refs, make_tensor_accessor());
Expand All @@ -95,7 +95,7 @@ TYPED_TEST_P(AvgPoolCommonStaticShapeInferenceTest, auto_padding_same_upper_roun

this->op = this->make_op(data, strides, pads_begin, pads_end, kernel_shape, true, rounding_mode, pad_type);

this->input_shapes = ShapeVector{{1, 3, 10, 12, 20}};
this->input_shapes = StaticShapeVector{{1, 3, 10, 12, 20}};
auto shape_infer = make_shape_inference(this->op);
const auto input_shape_refs = make_static_shape_refs(this->input_shapes);
this->output_shapes = *shape_infer->infer(input_shape_refs, make_tensor_accessor());
Expand All @@ -118,7 +118,7 @@ TYPED_TEST_P(AvgPoolCommonStaticShapeInferenceTest, auto_padding_same_upper_roun

this->op = this->make_op(data, strides, pads_begin, pads_end, kernel_shape, true, rounding_mode, pad_type);

this->input_shapes = ShapeVector{{32, 32, 2, 2, 4}};
this->input_shapes = StaticShapeVector{{32, 32, 2, 2, 4}};
auto shape_infer = make_shape_inference(this->op);
const auto input_shape_refs = make_static_shape_refs(this->input_shapes);
this->output_shapes = *shape_infer->infer(input_shape_refs, make_tensor_accessor());
Expand Down Expand Up @@ -153,7 +153,7 @@ TEST_F(AvgPoolV14StaticShapeInferenceTest, explicit_padding_ceil_torch) {

this->op = this->make_op(data, strides, pads_begin, pads_end, kernel_shape, true, rounding_mode, pad_type);

this->input_shapes = ShapeVector{{1, 3, 9, 9}};
this->input_shapes = StaticShapeVector{{1, 3, 9, 9}};
auto shape_infer = make_shape_inference(this->op);
const auto input_shape_refs = make_static_shape_refs(this->input_shapes);
this->output_shapes = *shape_infer->infer(input_shape_refs, make_tensor_accessor());
Expand All @@ -174,7 +174,7 @@ TEST_F(AvgPoolV14StaticShapeInferenceTest, explicit_padding_ceil_torch_no_stride

this->op = this->make_op(data, strides, pads_begin, pads_end, kernel_shape, false, rounding_mode, pad_type);

this->input_shapes = ShapeVector{{1, 3, 9, 9}};
this->input_shapes = StaticShapeVector{{1, 3, 9, 9}};
auto shape_infer = make_shape_inference(this->op);
const auto input_shape_refs = make_static_shape_refs(this->input_shapes);
this->output_shapes = *shape_infer->infer(input_shape_refs, make_tensor_accessor());
Expand All @@ -195,7 +195,7 @@ TEST_F(AvgPoolV14StaticShapeInferenceTest, auto_padding_ceil_torch) {

this->op = this->make_op(data, strides, pads_begin, pads_end, kernel_shape, false, rounding_mode, pad_type);

this->input_shapes = ShapeVector{{1, 3, 9, 9}};
this->input_shapes = StaticShapeVector{{1, 3, 9, 9}};
auto shape_infer = make_shape_inference(this->op);
const auto input_shape_refs = make_static_shape_refs(this->input_shapes);
this->output_shapes = *shape_infer->infer(input_shape_refs, make_tensor_accessor());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ TEST_F(BatchToSpaceV1StaticShapeInferenceTest, default_ctor) {
int32_t crops_begin_val[] = {0, 2, 0, 0, 0};
int32_t crops_end_val[] = {0, 2, 1, 0, 0};

const auto constant_data = std::unordered_map<size_t, ov::Tensor>{{1, {element::i32, Shape{5}, block_val}},
{2, {element::i32, Shape{5}, crops_begin_val}},
{3, {element::i32, Shape{5}, crops_end_val}}};
const auto constant_data =
std::unordered_map<size_t, ov::Tensor>{{1, {element::i32, ov::Shape{5}, block_val}},
{2, {element::i32, ov::Shape{5}, crops_begin_val}},
{3, {element::i32, ov::Shape{5}, crops_end_val}}};

input_shapes = {{960, 6, 13, 128, 16}, {5}, {5}, {5}};
output_shapes = shape_inference(op.get(), input_shapes, constant_data);
Expand All @@ -52,9 +53,10 @@ TEST_F(BatchToSpaceV1StaticShapeInferenceTest, blocks_crops_in_constant_map) {
int32_t crops_begin_val[] = {0, 2, 0, 0, 0};
int32_t crops_end_val[] = {0, 2, 1, 0, 0};

const auto constant_data = std::unordered_map<size_t, ov::Tensor>{{1, {element::i32, Shape{5}, block_val}},
{2, {element::i32, Shape{5}, crops_begin_val}},
{3, {element::i32, Shape{5}, crops_end_val}}};
const auto constant_data =
std::unordered_map<size_t, ov::Tensor>{{1, {element::i32, ov::Shape{5}, block_val}},
{2, {element::i32, ov::Shape{5}, crops_begin_val}},
{3, {element::i32, ov::Shape{5}, crops_end_val}}};

input_shapes = {{960, 6, 13, 128, 16}, {5}, {5}, {5}};

Expand All @@ -64,9 +66,9 @@ TEST_F(BatchToSpaceV1StaticShapeInferenceTest, blocks_crops_in_constant_map) {

TEST_F(BatchToSpaceV1StaticShapeInferenceTest, blocs_crops_as_constants) {
auto data = std::make_shared<Parameter>(element::f32, PartialShape{-1, -1, -1, -1});
auto block_shape = std::make_shared<Constant>(element::i64, Shape{4}, std::vector<int64_t>{1, 10, 5, 1});
auto crops_begin = std::make_shared<Constant>(element::i64, Shape{4}, std::vector<int64_t>{0, 3, 1, 0});
auto crops_end = std::make_shared<Constant>(element::i64, Shape{4}, std::vector<int64_t>{0, 3, 0, 0});
auto block_shape = std::make_shared<Constant>(element::i64, ov::Shape{4}, std::vector<int64_t>{1, 10, 5, 1});
auto crops_begin = std::make_shared<Constant>(element::i64, ov::Shape{4}, std::vector<int64_t>{0, 3, 1, 0});
auto crops_end = std::make_shared<Constant>(element::i64, ov::Shape{4}, std::vector<int64_t>{0, 3, 0, 0});

op = make_op(data, block_shape, crops_begin, crops_end);
input_shapes = {{100, 7, 13, 3}, {4}, {4}, {4}};
Expand All @@ -81,8 +83,8 @@ TEST_F(BatchToSpaceV1StaticShapeInferenceTest, missing_tensor_data) {
int32_t block_val[] = {1, 6, 5, 1, 16};
int32_t crops_end_val[] = {0, 2, 1, 0, 0};

const auto constant_data = std::unordered_map<size_t, ov::Tensor>{{1, {element::i32, Shape{5}, block_val}},
{3, {element::i32, Shape{5}, crops_end_val}}};
const auto constant_data = std::unordered_map<size_t, ov::Tensor>{{1, {element::i32, ov::Shape{5}, block_val}},
{3, {element::i32, ov::Shape{5}, crops_end_val}}};

input_shapes = {{960, 6, 13, 128, 16}, {5}, {5}, {5}};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ template <class TOp>
class BECStaticShapeInferenceTest : public OpStaticShapeInferenceTest<TOp> {
protected:
void SetUp() override {
this->output_shapes = ShapeVector(1);
this->output_shapes = StaticShapeVector(1);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ template <class TOp>
class BELStaticShapeInferenceTest : public OpStaticShapeInferenceTest<TOp> {
protected:
void SetUp() override {
this->output_shapes = ShapeVector(1);
this->output_shapes = StaticShapeVector(1);
}

element::Type dtype{element::boolean};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ TEST_F(BinaryConvolutionV1StaticShapeInferenceTest, default_ctor) {
op->set_pads_end({2, 1});
op->set_auto_pad(op::PadType::VALID);

input_shapes = ShapeVector{{1, 3, 10, 12}, {2, 3, 5, 5}};
input_shapes = StaticShapeVector{{1, 3, 10, 12}, {2, 3, 5, 5}};
auto shape_infer = make_shape_inference(op);
const auto input_shape_refs = make_static_shape_refs(input_shapes);
output_shapes = *shape_infer->infer(input_shape_refs, make_tensor_accessor());
Expand All @@ -50,7 +50,7 @@ TEST_F(BinaryConvolutionV1StaticShapeInferenceTest, default_ctor_three_input_sha
op->set_auto_pad(op::PadType::VALID);

// Third input shape (bias) can be provided, but is not used
input_shapes = ShapeVector{{1, 3, 10, 12}, {2, 3, 5, 5}, {2}};
input_shapes = StaticShapeVector{{1, 3, 10, 12}, {2, 3, 5, 5}, {2}};
auto shape_infer = make_shape_inference(op);
const auto input_shape_refs = make_static_shape_refs(input_shapes);
output_shapes = *shape_infer->infer(input_shape_refs, make_tensor_accessor());
Expand All @@ -73,7 +73,7 @@ TEST_F(BinaryConvolutionV1StaticShapeInferenceTest, auto_pads_same_lower_inputs_

op = make_op(data, filters, strides, pads_begin, pads_end, dilations, mode, pad_value, auto_pad);

input_shapes = ShapeVector{{3, 6, 5, 5}, {7, 6, 3, 3}};
input_shapes = StaticShapeVector{{3, 6, 5, 5}, {7, 6, 3, 3}};
output_shapes = shape_inference(op.get(), input_shapes);

EXPECT_EQ(output_shapes.size(), 1);
Expand All @@ -92,7 +92,7 @@ TEST_F(BinaryConvolutionV1StaticShapeInferenceTest, auto_pad_same_lower_inputs_s

op = make_op(data, filters, strides, pads_begin, pads_end, dilations, mode, pad_value, auto_pad);

input_shapes = ShapeVector{{3, 6, 5, 5}, {7, 6, 3, 3}};
input_shapes = StaticShapeVector{{3, 6, 5, 5}, {7, 6, 3, 3}};
output_shapes = shape_inference(op.get(), input_shapes);

EXPECT_EQ(output_shapes.size(), 1);
Expand All @@ -111,7 +111,7 @@ TEST_F(BinaryConvolutionV1StaticShapeInferenceTest, data_and_filters_num_channel

op = make_op(data, filters, strides, pads_begin, pads_end, dilations, mode, pad_value, auto_pad);

input_shapes = ShapeVector{{3, 5, 5, 5}, {7, 6, 3, 3}};
input_shapes = StaticShapeVector{{3, 5, 5, 5}, {7, 6, 3, 3}};

OV_EXPECT_THROW(shape_inference(op.get(), input_shapes),
NodeValidationFailure,
Expand All @@ -130,7 +130,7 @@ TEST_F(BinaryConvolutionV1StaticShapeInferenceTest, data_rank_not_4) {

op = make_op(data, filters, strides, pads_begin, pads_end, dilations, mode, pad_value, auto_pad);

input_shapes = ShapeVector{{3, 6, 5}, {7, 6, 3}};
input_shapes = StaticShapeVector{{3, 6, 5}, {7, 6, 3}};

OV_EXPECT_THROW(shape_inference(op.get(), input_shapes),
NodeValidationFailure,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ TEST_F(BucketizeV3StaticShapeInferenceTest, default_ctor) {
op->set_output_type(element::i32);
op->set_with_right_bound(false);

input_shapes = ShapeVector{{3, 2, 7, 89}, {3}};
input_shapes = StaticShapeVector{{3, 2, 7, 89}, {3}};
output_shapes = shape_inference(op.get(), input_shapes);

EXPECT_EQ(output_shapes.size(), 1);
Expand All @@ -33,7 +33,7 @@ TEST_F(BucketizeV3StaticShapeInferenceTest, dynamic_rank_inputs) {
const auto buckets = std::make_shared<op::v0::Parameter>(element::f32, PartialShape::dynamic());
op = make_op(data, buckets, element::i32);

input_shapes = ShapeVector{{10, 12, 1}, {5}};
input_shapes = StaticShapeVector{{10, 12, 1}, {5}};
output_shapes = shape_inference(op.get(), input_shapes);

EXPECT_EQ(output_shapes.size(), 1);
Expand All @@ -45,7 +45,7 @@ TEST_F(BucketizeV3StaticShapeInferenceTest, static_rank_inputs) {
const auto buckets = std::make_shared<op::v0::Parameter>(element::f32, PartialShape{-1});
op = make_op(data, buckets);

input_shapes = ShapeVector{{100, 11}, {1}};
input_shapes = StaticShapeVector{{100, 11}, {1}};
output_shapes = shape_inference(op.get(), input_shapes);

EXPECT_EQ(output_shapes.size(), 1);
Expand All @@ -57,7 +57,7 @@ TEST_F(BucketizeV3StaticShapeInferenceTest, bucket_incorrect_rank) {
const auto buckets = std::make_shared<op::v0::Parameter>(element::f32, PartialShape{-1});
op = make_op(data, buckets, element::i32);

input_shapes = ShapeVector{{100, 11}, {2, 1}};
input_shapes = StaticShapeVector{{100, 11}, {2, 1}};
OV_EXPECT_THROW(shape_inference(op.get(), input_shapes),
NodeValidationFailure,
HasSubstr("Buckets input must be a 1D tensor"));
Expand Down
Loading

0 comments on commit a510f34

Please sign in to comment.