Refactor GatherLayerTest, GatherElementsLayerTest (#20020)

* Refactor GatherLayerTest

* Refactor GatherElementsLayerTest
This commit is contained in:
Oleg Pipikin
2023-09-25 09:29:57 +02:00
committed by GitHub
parent 2e88aa0770
commit f82c668d28
8 changed files with 517 additions and 218 deletions

View File

@@ -4,47 +4,35 @@
#include <vector>
#include "single_layer_tests/gather.hpp"
#include "ngraph_functions/builders.hpp"
using namespace LayerTestsDefinitions;
#include "single_op_tests/gather.hpp"
namespace {
using ov::test::Gather7LayerTest;
using ov::test::Gather8LayerTest;
const std::vector<InferenceEngine::Precision> netPrecisions = {
InferenceEngine::Precision::FP32,
InferenceEngine::Precision::BF16,
InferenceEngine::Precision::I8
const std::vector<ov::element::Type> model_types = {
ov::element::f32,
ov::element::bf16,
ov::element::i8
};
// Just need to check types transformation.
const std::vector<InferenceEngine::Precision> netPrecisionsTrCheck = {
InferenceEngine::Precision::I64,
InferenceEngine::Precision::FP16
const std::vector<ov::element::Type> model_types_tr_check = {
ov::element::i64,
ov::element::f16
};
const std::vector<std::vector<size_t>> inputShapes_1D = {
std::vector<size_t>{4},
};
const std::vector<ov::Shape> input_shapes_1d = {{4}};
const std::vector<std::vector<size_t>> indicesShapes_1D = {
std::vector<size_t>{1},
std::vector<size_t>{3},
};
const std::vector<ov::Shape> indices_shapes_1d = {{1}, {3}};
const std::vector<std::tuple<int, int>> axes_batchdims_1D = {
std::tuple<int, int>{0, 0}
};
const std::vector<std::tuple<int, int>> axes_batchdims_1d = {{0, 0}};
const auto gather7Params_1D = testing::Combine(
testing::ValuesIn(inputShapes_1D),
testing::ValuesIn(indicesShapes_1D),
testing::ValuesIn(axes_batchdims_1D),
testing::ValuesIn(netPrecisions),
testing::Values(InferenceEngine::Precision::UNSPECIFIED),
testing::Values(InferenceEngine::Precision::UNSPECIFIED),
testing::Values(InferenceEngine::Layout::ANY),
testing::Values(InferenceEngine::Layout::ANY),
testing::Values(ov::test::static_shapes_to_test_representation(input_shapes_1d)),
testing::ValuesIn(indices_shapes_1d),
testing::ValuesIn(axes_batchdims_1d),
testing::ValuesIn(model_types),
testing::Values(ov::test::utils::DEVICE_CPU)
);
@@ -52,174 +40,100 @@ INSTANTIATE_TEST_SUITE_P(smoke_Gather7_1D, Gather7LayerTest, gather7Params_1D, G
INSTANTIATE_TEST_SUITE_P(smoke_TypesTrf, Gather7LayerTest,
testing::Combine(
testing::ValuesIn(inputShapes_1D),
testing::ValuesIn(indicesShapes_1D),
testing::ValuesIn(axes_batchdims_1D),
testing::ValuesIn(netPrecisionsTrCheck),
testing::Values(InferenceEngine::Precision::UNSPECIFIED),
testing::Values(InferenceEngine::Precision::UNSPECIFIED),
testing::Values(InferenceEngine::Layout::ANY),
testing::Values(InferenceEngine::Layout::ANY),
testing::Values(ov::test::static_shapes_to_test_representation(input_shapes_1d)),
testing::ValuesIn(indices_shapes_1d),
testing::ValuesIn(axes_batchdims_1d),
testing::ValuesIn(model_types_tr_check),
testing::Values(ov::test::utils::DEVICE_CPU)),
Gather7LayerTest::getTestCaseName);
const std::vector<std::vector<size_t>> inputShapes_2D = {
std::vector<size_t>{4, 19},
};
const std::vector<ov::Shape> input_shapes_2d = {{4, 19}};
const std::vector<std::vector<size_t>> indicesShapes_2D = {
std::vector<size_t>{4, 1},
std::vector<size_t>{4, 2},
};
const std::vector<ov::Shape> indices_shapes_2d = {{4, 1}, {4, 2}};
const std::vector<std::tuple<int, int>> axes_batchdims_2D = {
std::tuple<int, int>{0, 0},
std::tuple<int, int>{1, 0},
std::tuple<int, int>{1, 1},
std::tuple<int, int>{-1, -1},
};
const std::vector<std::tuple<int, int>> axes_batchdims_2d = {{0, 0}, {1, 0}, {1, 1}, {-1, -1}};
const auto gather7Params_2D = testing::Combine(
testing::ValuesIn(inputShapes_2D),
testing::ValuesIn(indicesShapes_2D),
testing::ValuesIn(axes_batchdims_2D),
testing::ValuesIn(netPrecisions),
testing::Values(InferenceEngine::Precision::UNSPECIFIED),
testing::Values(InferenceEngine::Precision::UNSPECIFIED),
testing::Values(InferenceEngine::Layout::ANY),
testing::Values(InferenceEngine::Layout::ANY),
testing::Values(ov::test::static_shapes_to_test_representation(input_shapes_2d)),
testing::ValuesIn(indices_shapes_2d),
testing::ValuesIn(axes_batchdims_2d),
testing::ValuesIn(model_types),
testing::Values(ov::test::utils::DEVICE_CPU)
);
INSTANTIATE_TEST_SUITE_P(smoke_Gather7_2D, Gather7LayerTest, gather7Params_2D, Gather7LayerTest::getTestCaseName);
const std::vector<std::vector<size_t>> inputShapes4D = {
std::vector<size_t>{4, 5, 6, 7},
};
const std::vector<ov::Shape> input_shapes_4d = {{4, 5, 6, 7}};
const std::vector<std::vector<size_t>> indicesShapes_BD0 = {
std::vector<size_t>{4},
std::vector<size_t>{2, 2},
std::vector<size_t>{3, 3},
std::vector<size_t>{5, 2},
std::vector<size_t>{3, 2, 4},
};
const std::vector<ov::Shape> indices_shapes_bd0 = {{4}, {2, 2}, {3, 3}, {5, 2}, {3, 2, 4}};
const std::vector<std::tuple<int, int>> axes_BD0 = {
std::tuple<int, int>{0, 0},
std::tuple<int, int>{1, 0},
std::tuple<int, int>{2, 0},
std::tuple<int, int>{-1, 0},
};
const std::vector<std::tuple<int, int>> axes_bd0 = {{0, 0}, {1, 0}, {2, 0}, {-1, 0}};
const auto gather7ParamsSubset_BD0 = testing::Combine(
testing::ValuesIn(inputShapes4D),
testing::ValuesIn(indicesShapes_BD0),
testing::ValuesIn(axes_BD0),
testing::ValuesIn(netPrecisions),
testing::Values(InferenceEngine::Precision::UNSPECIFIED),
testing::Values(InferenceEngine::Precision::UNSPECIFIED),
testing::Values(InferenceEngine::Layout::ANY),
testing::Values(InferenceEngine::Layout::ANY),
const auto gather7ParamsSubset_bd0 = testing::Combine(
testing::Values(ov::test::static_shapes_to_test_representation(input_shapes_4d)),
testing::ValuesIn(indices_shapes_bd0),
testing::ValuesIn(axes_bd0),
testing::ValuesIn(model_types),
testing::Values(ov::test::utils::DEVICE_CPU)
);
INSTANTIATE_TEST_SUITE_P(smoke_BD0, Gather7LayerTest, gather7ParamsSubset_BD0, Gather7LayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_BD0, Gather8LayerTest, gather7ParamsSubset_BD0, Gather8LayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_bd0, Gather7LayerTest, gather7ParamsSubset_bd0, Gather7LayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_bd0, Gather8LayerTest, gather7ParamsSubset_bd0, Gather8LayerTest::getTestCaseName);
const std::vector<std::vector<size_t>> indicesShapes_BD1 = {
std::vector<size_t>{4, 2},
std::vector<size_t>{4, 5, 3},
std::vector<size_t>{4, 1, 2, 3},
};
const std::vector<ov::Shape> indices_shapes_bd1 = {{4, 2}, {4, 5, 3}, {4, 1, 2, 3}};
const std::vector<std::tuple<int, int>> axes_BD1 = {
std::tuple<int, int>{1, 1},
std::tuple<int, int>{2, 1},
std::tuple<int, int>{-1, 1},
std::tuple<int, int>{-2, 1},
};
const std::vector<std::tuple<int, int>> axes_bd1 = {{1, 1}, {2, 1}, {-1, 1}, {-2, 1}};
const auto gather7ParamsSubset_BD1 = testing::Combine(
testing::ValuesIn(inputShapes4D),
testing::ValuesIn(indicesShapes_BD1),
testing::ValuesIn(axes_BD1),
testing::ValuesIn(netPrecisions),
testing::Values(InferenceEngine::Precision::UNSPECIFIED),
testing::Values(InferenceEngine::Precision::UNSPECIFIED),
testing::Values(InferenceEngine::Layout::ANY),
testing::Values(InferenceEngine::Layout::ANY),
const auto gather7ParamsSubset_bd1 = testing::Combine(
testing::Values(ov::test::static_shapes_to_test_representation(input_shapes_4d)),
testing::ValuesIn(indices_shapes_bd1),
testing::ValuesIn(axes_bd1),
testing::ValuesIn(model_types),
testing::Values(ov::test::utils::DEVICE_CPU)
);
INSTANTIATE_TEST_SUITE_P(smoke_Gather7_BD1, Gather7LayerTest, gather7ParamsSubset_BD1, Gather7LayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Gather7_bd1, Gather7LayerTest, gather7ParamsSubset_bd1, Gather7LayerTest::getTestCaseName);
const std::vector<std::vector<size_t>> indicesShapes_BD2 = {
std::vector<size_t>{4, 5, 4, 3},
std::vector<size_t>{4, 5, 3, 2}
};
const std::vector<ov::Shape> indices_shapes_bd2 = {{4, 5, 4, 3}, {4, 5, 3, 2}};
const std::vector<std::tuple<int, int>> axes_BD2 = {
std::tuple<int, int>{2, 2},
std::tuple<int, int>{3, -2},
std::tuple<int, int>{-1, 2},
std::tuple<int, int>{-1, -2},
};
const std::vector<std::tuple<int, int>> axes_bd2 = {{2, 2}, {3, -2}, {-1, 2}, {-1, -2}};
const auto gather7ParamsSubset_BD2 = testing::Combine(
testing::ValuesIn(inputShapes4D),
testing::ValuesIn(indicesShapes_BD2),
testing::ValuesIn(axes_BD2),
testing::ValuesIn(netPrecisions),
testing::Values(InferenceEngine::Precision::UNSPECIFIED),
testing::Values(InferenceEngine::Precision::UNSPECIFIED),
testing::Values(InferenceEngine::Layout::ANY),
testing::Values(InferenceEngine::Layout::ANY),
const auto gather7ParamsSubset_bd2 = testing::Combine(
testing::Values(ov::test::static_shapes_to_test_representation(input_shapes_4d)),
testing::ValuesIn(indices_shapes_bd2),
testing::ValuesIn(axes_bd2),
testing::ValuesIn(model_types),
testing::Values(ov::test::utils::DEVICE_CPU)
);
INSTANTIATE_TEST_SUITE_P(smoke_Gather7_BD2, Gather7LayerTest, gather7ParamsSubset_BD2, Gather7LayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Gather7_bd2, Gather7LayerTest, gather7ParamsSubset_bd2, Gather7LayerTest::getTestCaseName);
const std::vector<std::vector<size_t>> indicesShapes_NegativeBD = {
std::vector<size_t>{4, 5, 4},
std::vector<size_t>{4, 5, 3}
};
const std::vector<ov::Shape> indices_shapes_negative_bd = {{4, 5, 4}, {4, 5, 3}};
const std::vector<std::tuple<int, int>> axes_NegativeBD = {
std::tuple<int, int>{0, -3},
std::tuple<int, int>{1, -2},
std::tuple<int, int>{2, -2},
std::tuple<int, int>{-2, -2},
std::tuple<int, int>{-1, -1},
std::tuple<int, int>{-2, -1},
};
const std::vector<std::tuple<int, int>> axes_negative_bd = {{0, -3}, {1, -2}, {2, -2}, {-2, -2}, {-1, -1}, {-2, -1}};
const auto gather7ParamsSubset_NegativeBD = testing::Combine(
testing::ValuesIn(inputShapes4D),
testing::ValuesIn(indicesShapes_NegativeBD),
testing::ValuesIn(axes_NegativeBD),
testing::ValuesIn(netPrecisions),
testing::Values(InferenceEngine::Precision::UNSPECIFIED),
testing::Values(InferenceEngine::Precision::UNSPECIFIED),
testing::Values(InferenceEngine::Layout::ANY),
testing::Values(InferenceEngine::Layout::ANY),
const auto gather7ParamsSubset_negative_bd = testing::Combine(
testing::Values(ov::test::static_shapes_to_test_representation(input_shapes_4d)),
testing::ValuesIn(indices_shapes_negative_bd),
testing::ValuesIn(axes_negative_bd),
testing::ValuesIn(model_types),
testing::Values(ov::test::utils::DEVICE_CPU)
);
INSTANTIATE_TEST_SUITE_P(smoke_Gather7_NegativeBD, Gather7LayerTest, gather7ParamsSubset_NegativeBD, Gather7LayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Gather7_negative_bd, Gather7LayerTest, gather7ParamsSubset_negative_bd, Gather7LayerTest::getTestCaseName);
///// GATHER-8 /////
const std::vector<std::vector<size_t>> dataShapes4DGather8 = {
{10, 3, 1, 2},
{10, 3, 3, 1},
{10, 2, 2, 7},
{10, 2, 2, 2},
{10, 3, 4, 4},
{10, 2, 3, 17}
const std::vector<std::vector<ov::Shape>> data_shapes_4d_gather8 = {
{{10, 3, 1, 2}},
{{10, 3, 3, 1}},
{{10, 2, 2, 7}},
{{10, 2, 2, 2}},
{{10, 3, 4, 4}},
{{10, 2, 3, 17}}
};
const std::vector<std::vector<size_t>> idxShapes4DGather8 = {
const std::vector<ov::Shape> idx_shapes_4d_gather8 = {
{10, 1, 1},
{10, 1, 2},
{10, 1, 3},
@@ -231,7 +145,7 @@ const std::vector<std::vector<size_t>> idxShapes4DGather8 = {
{10, 7, 3},
{10, 8, 7}
};
const std::vector<std::tuple<int, int>> axesBatches4DGather8 = {
const std::vector<std::tuple<int, int>> axes_batches_4d_gather8 = {
{3, 0},
{-1, -2},
{2, -3},
@@ -243,40 +157,47 @@ const std::vector<std::tuple<int, int>> axesBatches4DGather8 = {
INSTANTIATE_TEST_CASE_P(smoke_static_4D, Gather8LayerTest,
testing::Combine(
testing::ValuesIn(dataShapes4DGather8),
testing::ValuesIn(idxShapes4DGather8),
testing::ValuesIn(axesBatches4DGather8),
testing::ValuesIn(netPrecisions),
testing::Values(InferenceEngine::Precision::UNSPECIFIED),
testing::Values(InferenceEngine::Precision::UNSPECIFIED),
testing::Values(InferenceEngine::Layout::ANY),
testing::Values(InferenceEngine::Layout::ANY),
testing::ValuesIn(ov::test::static_shapes_to_test_representation(data_shapes_4d_gather8)),
testing::ValuesIn(idx_shapes_4d_gather8),
testing::ValuesIn(axes_batches_4d_gather8),
testing::ValuesIn(model_types),
testing::Values(ov::test::utils::DEVICE_CPU)),
Gather8LayerTest::getTestCaseName);
const std::vector<std::vector<ov::Shape>> data_shapes_vec2_gather8 = {
{{5, 4}},
{{11, 4}},
{{23, 4}},
{{35, 4}},
{{51, 4}},
{{71, 4}}
};
const std::vector<ov::Shape> idx_shapes_vec2_gather8 = {{1}};
const std::vector<std::tuple<int, int>> axes_batches_vec2_gather8 = {{1, 0}};
const auto gatherParamsVec2 = testing::Combine(
testing::ValuesIn(std::vector<std::vector<size_t>>({{5, 4}, {11, 4}, {23, 4}, {35, 4}, {51, 4}, {71, 4}})),
testing::ValuesIn(std::vector<std::vector<size_t>>({{1}})),
testing::ValuesIn(std::vector<std::tuple<int, int>>{std::tuple<int, int>{1, 0}}),
testing::ValuesIn(netPrecisions),
testing::Values(InferenceEngine::Precision::UNSPECIFIED),
testing::Values(InferenceEngine::Precision::UNSPECIFIED),
testing::Values(InferenceEngine::Layout::ANY),
testing::Values(InferenceEngine::Layout::ANY),
testing::ValuesIn(ov::test::static_shapes_to_test_representation(data_shapes_vec2_gather8)),
testing::ValuesIn(idx_shapes_vec2_gather8),
testing::ValuesIn(axes_batches_vec2_gather8),
testing::ValuesIn(model_types),
testing::Values(ov::test::utils::DEVICE_CPU)
);
INSTANTIATE_TEST_CASE_P(smoke_Vec2, Gather8LayerTest, gatherParamsVec2, Gather8LayerTest::getTestCaseName);
const std::vector<ov::Shape> data_shapes_vec3_gather8 = {{4, 4}};
const std::vector<ov::Shape> idx_shapes_vec3_gather8 = {{5}, {11}, {21}, {35}, {55}, {70}};
const std::vector<std::tuple<int, int>> axes_batches_vec3_gather8 = {{1, 0}};
const auto gatherParamsVec3 = testing::Combine(
testing::ValuesIn(std::vector<std::vector<size_t>>({{4, 4}})),
testing::ValuesIn(std::vector<std::vector<size_t>>({{5}, {11}, {21}, {35}, {55}, {70}})),
testing::ValuesIn(std::vector<std::tuple<int, int>>{std::tuple<int, int>{1, 0}}),
testing::ValuesIn(netPrecisions),
testing::Values(InferenceEngine::Precision::UNSPECIFIED),
testing::Values(InferenceEngine::Precision::UNSPECIFIED),
testing::Values(InferenceEngine::Layout::ANY),
testing::Values(InferenceEngine::Layout::ANY),
testing::Values(ov::test::static_shapes_to_test_representation(data_shapes_vec3_gather8)),
testing::ValuesIn(idx_shapes_vec3_gather8),
testing::ValuesIn(axes_batches_vec3_gather8),
testing::ValuesIn(model_types),
testing::Values(ov::test::utils::DEVICE_CPU)
);

View File

@@ -4,72 +4,71 @@
#include <vector>
#include "single_layer_tests/gather_elements.hpp"
#include "single_op_tests/gather_elements.hpp"
#include "common_test_utils/test_constants.hpp"
using namespace LayerTestsDefinitions;
namespace {
using ov::test::GatherElementsLayerTest;
const std::vector<InferenceEngine::Precision> dPrecisions = {
InferenceEngine::Precision::FP32,
InferenceEngine::Precision::FP16,
InferenceEngine::Precision::I32,
InferenceEngine::Precision::I64,
InferenceEngine::Precision::I16,
const std::vector<ov::element::Type> model_types = {
ov::element::f32,
ov::element::f16,
ov::element::i32,
ov::element::i64,
ov::element::i16,
};
const std::vector<InferenceEngine::Precision> iPrecisions = {
InferenceEngine::Precision::I32,
InferenceEngine::Precision::I64
const std::vector<ov::element::Type> indices_types = {
ov::element::i32,
ov::element::i64
};
INSTANTIATE_TEST_SUITE_P(smoke_set1, GatherElementsLayerTest,
::testing::Combine(
::testing::Values(std::vector<size_t>({2, 2})), // Data shape
::testing::Values(std::vector<size_t>({2, 2})), // Indices shape
::testing::ValuesIn(std::vector<int>({-1, 0, 1})), // Axis
::testing::ValuesIn(dPrecisions),
::testing::ValuesIn(iPrecisions),
::testing::Values(ov::test::static_shapes_to_test_representation({ov::Shape{2, 2}})),
::testing::Values(ov::Shape{2, 2}),
::testing::ValuesIn(std::vector<int>{-1, 0, 1}),
::testing::ValuesIn(model_types),
::testing::ValuesIn(indices_types),
::testing::Values(ov::test::utils::DEVICE_CPU)),
GatherElementsLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_set2, GatherElementsLayerTest,
::testing::Combine(
::testing::Values(std::vector<size_t>({2, 2, 1})), // Data shape
::testing::Values(std::vector<size_t>({4, 2, 1})), // Indices shape
::testing::ValuesIn(std::vector<int>({0, -3})), // Axis
::testing::ValuesIn(dPrecisions),
::testing::ValuesIn(iPrecisions),
::testing::Values(ov::test::static_shapes_to_test_representation({ov::Shape{2, 2, 1}})),
::testing::Values(ov::Shape{4, 2, 1}),
::testing::ValuesIn(std::vector<int>({0, -3})),
::testing::ValuesIn(model_types),
::testing::ValuesIn(indices_types),
::testing::Values(ov::test::utils::DEVICE_CPU)),
GatherElementsLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_set3, GatherElementsLayerTest,
::testing::Combine(
::testing::Values(std::vector<size_t>({2, 2, 3, 5})), // Data shape
::testing::Values(std::vector<size_t>({2, 2, 3, 7})), // Indices shape
::testing::Values(3, -1), // Axis
::testing::ValuesIn(dPrecisions),
::testing::ValuesIn(iPrecisions),
::testing::Values(ov::test::static_shapes_to_test_representation({ov::Shape{2, 2, 3, 5}})),
::testing::Values(ov::Shape{2, 2, 3, 7}),
::testing::Values(3, -1),
::testing::ValuesIn(model_types),
::testing::ValuesIn(indices_types),
::testing::Values(ov::test::utils::DEVICE_CPU)),
GatherElementsLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_set4, GatherElementsLayerTest,
::testing::Combine(
::testing::Values(std::vector<size_t>({3, 2, 3, 8})), // Data shape
::testing::Values(std::vector<size_t>({2, 2, 3, 8})), // Indices shape
::testing::Values(0, -4), // Axis
::testing::ValuesIn(dPrecisions),
::testing::ValuesIn(iPrecisions),
::testing::Values(ov::test::static_shapes_to_test_representation({ov::Shape{3, 2, 3, 8}})),
::testing::Values(ov::Shape{2, 2, 3, 8}),
::testing::Values(0, -4),
::testing::ValuesIn(model_types),
::testing::ValuesIn(indices_types),
::testing::Values(ov::test::utils::DEVICE_CPU)),
GatherElementsLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_set5, GatherElementsLayerTest,
::testing::Combine(
::testing::Values(std::vector<size_t>({3, 2, 3, 4, 8})), // Data shape
::testing::Values(std::vector<size_t>({3, 2, 3, 5, 8})), // Indices shape
::testing::Values(3, -2), // Axis
::testing::ValuesIn(dPrecisions),
::testing::ValuesIn(iPrecisions),
::testing::Values(ov::test::static_shapes_to_test_representation({ov::Shape{3, 2, 3, 4, 8}})),
::testing::Values(ov::Shape{3, 2, 3, 5, 8}),
::testing::Values(3, -2),
::testing::ValuesIn(model_types),
::testing::ValuesIn(indices_types),
::testing::Values(ov::test::utils::DEVICE_CPU)),
GatherElementsLayerTest::getTestCaseName);
} // namespace

View File

@@ -0,0 +1,27 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include "shared_test_classes/single_op/gather.hpp"
namespace ov {
namespace test {
TEST_P(GatherLayerTest, Inference) {
run();
};
TEST_P(Gather7LayerTest, Inference) {
run();
};
TEST_P(Gather8LayerTest, Inference) {
run();
};
TEST_P(Gather8IndiceScalarLayerTest, Inference) {
run();
};
} // namespace test
} // namespace ov

View File

@@ -0,0 +1,15 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include "shared_test_classes/single_op/gather_elements.hpp"
namespace ov {
namespace test {
TEST_P(GatherElementsLayerTest, Inference) {
run();
}
} // namespace test
} // namespace ov

View File

@@ -0,0 +1,67 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include <tuple>
#include <string>
#include <vector>
#include "shared_test_classes/base/ov_subgraph.hpp"
namespace ov {
namespace test {
typedef std::tuple<
std::vector<int>, // Indices
ov::Shape, // Indices shape
int, // Gather axis
std::vector<InputShape>, // Input shapes
ov::element::Type, // Model type
std::string // Device name
> gatherParamsTuple;
class GatherLayerTest : public testing::WithParamInterface<gatherParamsTuple>,
virtual public ov::test::SubgraphBaseTest {
public:
static std::string getTestCaseName(const testing::TestParamInfo<gatherParamsTuple> &obj);
protected:
void SetUp() override;
};
typedef std::tuple<
std::vector<InputShape>, // Input shapes
ov::Shape, // Indices shape
std::tuple<int, int>, // Gather axis and batch
ov::element::Type, // Model type
std::string // Device name
> gather7ParamsTuple;
class Gather7LayerTest : public testing::WithParamInterface<gather7ParamsTuple>,
virtual public ov::test::SubgraphBaseTest {
public:
static std::string getTestCaseName(const testing::TestParamInfo<gather7ParamsTuple>& obj);
protected:
void SetUp() override;
};
class Gather8LayerTest : public testing::WithParamInterface<gather7ParamsTuple>,
virtual public ov::test::SubgraphBaseTest {
public:
static std::string getTestCaseName(const testing::TestParamInfo<gather7ParamsTuple>& obj);
protected:
void SetUp() override;
};
class Gather8IndiceScalarLayerTest : public testing::WithParamInterface<gather7ParamsTuple>,
virtual public ov::test::SubgraphBaseTest {
public:
static std::string getTestCaseName(const testing::TestParamInfo<gather7ParamsTuple>& obj);
protected:
void SetUp() override;
};
} // namespace test
} // namespace ov

View File

@@ -0,0 +1,34 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include <string>
#include <tuple>
#include <vector>
#include "shared_test_classes/base/ov_subgraph.hpp"
namespace ov {
namespace test {
typedef std::tuple<
std::vector<InputShape>, // Input shapes
ov::Shape, // Indices shape
int, // Axis
ov::element::Type, // Model type
ov::element::Type, // Indices type
std::string // Device name
> GatherElementsParams;
class GatherElementsLayerTest : public testing::WithParamInterface<GatherElementsParams>,
virtual public ov::test::SubgraphBaseTest {
public:
static std::string getTestCaseName(const testing::TestParamInfo<GatherElementsParams>& obj);
protected:
void SetUp() override;
};
} // namespace test
} // namespace ov

View File

@@ -0,0 +1,171 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include "shared_test_classes/single_op/gather.hpp"
#include "common_test_utils/ov_tensor_utils.hpp"
#include "openvino/op/parameter.hpp"
#include "openvino/op/constant.hpp"
#include "openvino/op/result.hpp"
#include "openvino/op/gather.hpp"
namespace ov {
namespace test {
std::string GatherLayerTest::getTestCaseName(const testing::TestParamInfo<gatherParamsTuple> &obj) {
int axis;
std::vector<int> indices;
ov::Shape indices_shape;
std::vector<InputShape> shapes;
ov::element::Type model_type;
std::string device_name;
std::tie(indices, indices_shape, axis, shapes, model_type, device_name) = obj.param;
std::ostringstream result;
result << "IS=(";
for (size_t i = 0lu; i < shapes.size(); i++) {
result << ov::test::utils::partialShape2str({shapes[i].first}) << (i < shapes.size() - 1lu ? "_" : "");
}
result << ")_TS=";
for (size_t i = 0lu; i < shapes.front().second.size(); i++) {
result << "{";
for (size_t j = 0lu; j < shapes.size(); j++) {
result << ov::test::utils::vec2str(shapes[j].second[i]) << (j < shapes.size() - 1lu ? "_" : "");
}
result << "}_";
}
result << "axis=" << axis << "_";
result << "indices=" << ov::test::utils::vec2str(indices) << "_";
result << "indices_shape=" << ov::test::utils::vec2str(indices_shape) << "_";
result << "netPRC=" << model_type.get_type_name() << "_";
result << "trgDev=" << device_name << "_";
return result.str();
}
void GatherLayerTest::SetUp() {
int axis;
std::vector<int> indices;
ov::Shape indices_shape;
std::vector<InputShape> shapes;
ov::element::Type model_type;
std::tie(indices, indices_shape, axis, shapes, model_type, targetDevice) = GetParam();
init_input_shapes(shapes);
ASSERT_EQ(ov::shape_size(indices_shape), indices.size()) << "Indices vector size and provided indices shape doesn't fit each other";
auto param = std::make_shared<ov::op::v0::Parameter>(model_type, inputDynamicShapes.front());
auto indices_node = ov::op::v0::Constant::create(ov::element::i64, indices_shape, indices);
auto axis_node = ov::op::v0::Constant::create(ov::element::i64, ov::Shape(), {axis});
auto gather = std::make_shared<ov::op::v1::Gather>(param, indices_node, axis_node);
auto result = std::make_shared<ov::op::v0::Result>(gather);
function = std::make_shared<ov::Model>(result, ov::ParameterVector{param}, "gather");
}
std::string Gather7LayerTest::getTestCaseName(const testing::TestParamInfo<gather7ParamsTuple>& obj) {
std::tuple<int, int> axis_batch_idx;
std::vector<int> indices;
ov::Shape indices_shape;
std::vector<InputShape> shapes;
ov::element::Type model_type;
std::string device_name;
std::tie(shapes, indices_shape, axis_batch_idx, model_type, device_name) = obj.param;
std::ostringstream result;
result << "IS=(";
for (size_t i = 0lu; i < shapes.size(); i++) {
result << ov::test::utils::partialShape2str({shapes[i].first}) << (i < shapes.size() - 1lu ? "_" : "");
}
result << ")_TS=";
for (size_t i = 0lu; i < shapes.front().second.size(); i++) {
result << "{";
for (size_t j = 0lu; j < shapes.size(); j++) {
result << ov::test::utils::vec2str(shapes[j].second[i]) << (j < shapes.size() - 1lu ? "_" : "");
}
result << "}_";
}
result << "axis=" << std::get<0>(axis_batch_idx) << "_";
result << "batch_idx=" << std::get<1>(axis_batch_idx) << "_";
result << "indices_shape=" << ov::test::utils::vec2str(indices_shape) << "_";
result << "netPRC=" << model_type.get_type_name() << "_";
result << "trgDev=" << device_name << "_";
return result.str();
}
void Gather7LayerTest::SetUp() {
std::tuple<int, int> axis_batch_idx;
ov::Shape indices_shape;
std::vector<InputShape> shapes;
ov::element::Type model_type;
std::tie(shapes, indices_shape, axis_batch_idx, model_type, targetDevice) = GetParam();
init_input_shapes(shapes);
int axis = std::get<0>(axis_batch_idx);
int batch_idx = std::get<1>(axis_batch_idx);
auto param = std::make_shared<ov::op::v0::Parameter>(model_type, inputDynamicShapes.front());
int axis_dim = targetStaticShapes[0][0][axis < 0 ? axis + targetStaticShapes[0][0].size() : axis];
auto indices_node_tensor = ov::test::utils::create_and_fill_tensor(ov::element::i64, indices_shape, axis_dim - 1);
auto indices_node = std::make_shared<ov::op::v0::Constant>(indices_node_tensor);
auto axis_node = ov::op::v0::Constant::create(ov::element::i64, ov::Shape(), {axis});
auto gather = std::make_shared<ov::op::v7::Gather>(param, indices_node, axis_node, batch_idx);
auto result = std::make_shared<ov::op::v0::Result>(gather);
function = std::make_shared<ov::Model>(result, ov::ParameterVector{param}, "gather");
}
std::string Gather8LayerTest::getTestCaseName(const testing::TestParamInfo<gather7ParamsTuple>& obj) {
return Gather7LayerTest::getTestCaseName(obj);
}
void Gather8LayerTest::SetUp() {
std::tuple<int, int> axis_batch_idx;
ov::Shape indices_shape;
std::vector<InputShape> shapes;
ov::element::Type model_type;
std::tie(shapes, indices_shape, axis_batch_idx, model_type, targetDevice) = GetParam();
init_input_shapes(shapes);
int axis = std::get<0>(axis_batch_idx);
int batch_idx = std::get<1>(axis_batch_idx);
auto param = std::make_shared<ov::op::v0::Parameter>(model_type, inputDynamicShapes.front());
int axis_dim = targetStaticShapes[0][0][axis < 0 ? axis + targetStaticShapes[0][0].size() : axis];
auto indices_node_tensor = ov::test::utils::create_and_fill_tensor(ov::element::i64, indices_shape, 2 * axis_dim, -axis_dim);
auto indices_node = std::make_shared<ov::op::v0::Constant>(indices_node_tensor);
auto axis_node = ov::op::v0::Constant::create(ov::element::i64, ov::Shape(), {axis});
auto gather = std::make_shared<ov::op::v8::Gather>(param, indices_node, axis_node, batch_idx);
auto result = std::make_shared<ov::op::v0::Result>(gather);
function = std::make_shared<ov::Model>(result, ov::ParameterVector{param}, "gather");
}
std::string Gather8IndiceScalarLayerTest::getTestCaseName(const testing::TestParamInfo<gather7ParamsTuple>& obj) {
return Gather7LayerTest::getTestCaseName(obj);
}
void Gather8IndiceScalarLayerTest::SetUp() {
std::tuple<int, int> axis_batch_idx;
ov::Shape indices_shape;
std::vector<InputShape> shapes;
ov::element::Type model_type;
std::tie(shapes, indices_shape, axis_batch_idx, model_type, targetDevice) = GetParam();
init_input_shapes(shapes);
int axis = std::get<0>(axis_batch_idx);
int batch_idx = std::get<1>(axis_batch_idx);
auto param = std::make_shared<ov::op::v0::Parameter>(model_type, inputDynamicShapes.front());
auto indices_node = ov::op::v0::Constant::create(ov::element::i64, ov::Shape(), {targetStaticShapes[0][0][axis] - 1});
auto axis_node = ov::op::v0::Constant::create(ov::element::i64, ov::Shape(), {axis});
auto gather = std::make_shared<ov::op::v8::Gather>(param, indices_node, axis_node, batch_idx);
auto result = std::make_shared<ov::op::v0::Result>(gather);
function = std::make_shared<ov::Model>(result, ov::ParameterVector{param}, "gather");
}
} // namespace test
} // namespace ov

View File

@@ -0,0 +1,65 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include "shared_test_classes/single_op/gather_elements.hpp"
#include "common_test_utils/ov_tensor_utils.hpp"
#include "openvino/op/parameter.hpp"
#include "openvino/op/constant.hpp"
#include "openvino/op/result.hpp"
#include "openvino/op/gather_elements.hpp"
namespace ov {
namespace test {
std::string GatherElementsLayerTest::getTestCaseName(const testing::TestParamInfo<GatherElementsParams>& obj) {
ov::Shape indices_shape;
std::vector<InputShape> shapes;
ov::element::Type model_type, indices_type;
int axis;
std::string device;
std::tie(shapes, indices_shape, axis, model_type, indices_type, device) = obj.param;
std::ostringstream result;
result << "IS=(";
for (size_t i = 0lu; i < shapes.size(); i++) {
result << ov::test::utils::partialShape2str({shapes[i].first}) << (i < shapes.size() - 1lu ? "_" : "");
}
result << ")_TS=";
for (size_t i = 0lu; i < shapes.front().second.size(); i++) {
result << "{";
for (size_t j = 0lu; j < shapes.size(); j++) {
result << ov::test::utils::vec2str(shapes[j].second[i]) << (j < shapes.size() - 1lu ? "_" : "");
}
result << "}_";
}
result << "IS=" << ov::test::utils::vec2str(indices_shape) << "_";
result << "Ax=" << axis << "_";
result << "DP=" << model_type.get_type_name() << "_";
result << "IP=" << indices_type.get_type_name() << "_";
result << "device=" << device;
return result.str();
}
void GatherElementsLayerTest::SetUp() {
ov::Shape indices_shape;
std::vector<InputShape> shapes;
ov::element::Type model_type, indices_type;
int axis;
std::tie(shapes, indices_shape, axis, model_type, indices_type, targetDevice) = this->GetParam();
init_input_shapes(shapes);
auto param = std::make_shared<ov::op::v0::Parameter>(model_type, inputDynamicShapes.front());
auto axis_dim = targetStaticShapes[0][0][axis < 0 ? axis + targetStaticShapes[0][0].size() : axis];
auto indices_node_tensor = ov::test::utils::create_and_fill_tensor(indices_type, indices_shape, axis_dim - 1);
auto indices_node = std::make_shared<ov::op::v0::Constant>(indices_node_tensor);
auto gather_el = std::make_shared<ov::op::v6::GatherElements>(param, indices_node, axis);
gather_el->set_friendly_name("GatherElements");
auto result = std::make_shared<ov::op::v0::Result>(gather_el);
function = std::make_shared<ov::Model>(result, ov::ParameterVector{param}, "gatherEl");
}
} // namespace test
} // namespace ov