[CPU Tests] migrate sub_graph test cases - part 2 (#21379)

* [CPU Tests] migrate sub_graph test case - part 2

* remove unused header files

---------

Co-authored-by: Vitaliy Urusovskij <vitaliy.urusovskij@intel.com>
This commit is contained in:
River Li 2023-12-05 22:18:16 +08:00 committed by GitHub
parent f80793e420
commit 65b8bdf892
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 213 additions and 234 deletions

View File

@ -2,28 +2,14 @@
// SPDX-License-Identifier: Apache-2.0
//
#include <tuple>
#include <string>
#include <vector>
#include <memory>
#include <debug.h>
#include <shared_test_classes/base/ov_subgraph.hpp>
#include <ov_models/builders.hpp>
#include "common_test_utils/common_utils.hpp"
#include <common_test_utils/ov_tensor_utils.hpp>
#include "functional_test_utils/skip_tests_config.hpp"
#include "common_test_utils/node_builders/group_convolution.hpp"
#include "shared_test_classes/base/ov_subgraph.hpp"
#include "test_utils/cpu_test_utils.hpp"
#include "cpp_interfaces/interface/ie_internal_plugin_config.hpp"
#include "test_utils/cpu_test_utils.hpp"
#include "test_utils/convolution_params.hpp"
using namespace CPUTestUtils;
using namespace ov::test;
using namespace ngraph;
using namespace ngraph::helpers;
namespace CPUSubgraphTestsDefinitions {
namespace ov {
namespace test {
typedef std::tuple<InputShape> groupConvLayerCPUTestParamsSet;
@ -60,15 +46,23 @@ protected:
ov::ParameterVector inputParams;
for (auto&& shape : inputDynamicShapes) {
inputParams.push_back(std::make_shared<ov::op::v0::Parameter>(ngraph::element::f32, shape));
inputParams.push_back(std::make_shared<ov::op::v0::Parameter>(ov::element::f32, shape));
}
conv = builder::makeGroupConvolution(inputParams[0], element::f32, kernelSize, strides, padBegin, padEnd, dilation,
paddingType, numOutChannels, numOfGroups);
conv = utils::make_group_convolution(inputParams[0],
element::f32,
kernelSize,
strides,
padBegin,
padEnd,
dilation,
paddingType,
numOutChannels,
numOfGroups);
ResultVector results;
results.push_back(std::make_shared<opset5::Result>(conv));
results.push_back(std::make_shared<ov::op::v0::Result>(conv));
function = std::make_shared<ngraph::Function>(results, inputParams, "groupConvolution");
function = std::make_shared<ov::Model>(results, inputParams, "groupConvolution");
}
};
@ -96,5 +90,6 @@ const auto groupConvTransformationParams = ::testing::Combine(::testing::ValuesI
INSTANTIATE_TEST_SUITE_P(smoke_GroupConvToConvTransformationTest, GroupConvToConvTransformationCPUTest,
groupConvTransformationParams, GroupConvToConvTransformationCPUTest::getTestCaseName);
} // namespace
} // namespace CPUSubgraphTestsDefinitions
} // namespace
} // namespace test
} // namespace ov

View File

@ -2,35 +2,23 @@
// SPDX-License-Identifier: Apache-2.0
//
#include <tuple>
#include <string>
#include <vector>
#include <memory>
#include <debug.h>
#include <shared_test_classes/base/ov_subgraph.hpp>
#include <ov_models/builders.hpp>
#include "common_test_utils/common_utils.hpp"
#include <common_test_utils/ov_tensor_utils.hpp>
#include "functional_test_utils/skip_tests_config.hpp"
#include "common_test_utils/node_builders/convolution.hpp"
#include "common_test_utils/node_builders/group_convolution.hpp"
#include "common_test_utils/ov_tensor_utils.hpp"
#include "shared_test_classes/base/ov_subgraph.hpp"
#include "test_utils/cpu_test_utils.hpp"
#include "cpp_interfaces/interface/ie_internal_plugin_config.hpp"
#include "test_utils/cpu_test_utils.hpp"
#include "test_utils/convolution_params.hpp"
using namespace InferenceEngine;
using namespace CPUTestUtils;
using namespace ov::test;
using namespace ngraph;
using namespace ngraph::helpers;
namespace CPUSubgraphTestsDefinitions {
namespace ov {
namespace test {
typedef std::tuple<nodeType,
InputShape> conv1dConvertCPUTestParamsSet;
typedef std::tuple<nodeType, InputShape> conv1dConvertCPUTestParamsSet;
class Conv1dConvertTransformationCPUTest: public testing::WithParamInterface<conv1dConvertCPUTestParamsSet>,
virtual public SubgraphBaseTest, public CPUTestsBase {
class Conv1dConvertTransformationCPUTest : public testing::WithParamInterface<conv1dConvertCPUTestParamsSet>,
virtual public SubgraphBaseTest,
public CPUTestsBase {
public:
static std::string getTestCaseName(testing::TestParamInfo<conv1dConvertCPUTestParamsSet> obj) {
InputShape inputShapes;
@ -65,16 +53,16 @@ protected:
ov::ParameterVector inputParams;
for (auto&& shape : inputDynamicShapes) {
inputParams.push_back(std::make_shared<ov::op::v0::Parameter>(ngraph::element::f32, shape));
inputParams.push_back(std::make_shared<ov::op::v0::Parameter>(ov::element::f32, shape));
}
switch (convType) {
case nodeType::convolution : {
conv = builder::makeConvolution(inputParams[0], element::f32, kernelSize, strides, padBegin, padEnd, dilation,
conv = utils::make_convolution(inputParams[0], element::f32, kernelSize, strides, padBegin, padEnd, dilation,
paddingType, numOutChannels);
break;
}
case nodeType::groupConvolution : {
conv = builder::makeGroupConvolution(inputParams[0], element::f32, kernelSize, strides, padBegin, padEnd, dilation,
conv = utils::make_group_convolution(inputParams[0], element::f32, kernelSize, strides, padBegin, padEnd, dilation,
paddingType, numOutChannels, numOfGroups);
break;
}
@ -84,9 +72,9 @@ protected:
}
ResultVector results;
results.push_back(std::make_shared<opset5::Result>(conv));
results.push_back(std::make_shared<ov::op::v0::Result>(conv));
function = std::make_shared<ngraph::Function>(results, inputParams, "convolution");
function = std::make_shared<ov::Model>(results, inputParams, "convolution");
}
};
@ -132,5 +120,6 @@ const auto groupConvTransformationParams = ::testing::Combine(::testing::ValuesI
INSTANTIATE_TEST_SUITE_P(smoke_GroupConvToConvTransformationTest, Conv1dConvertTransformationCPUTest,
groupConvTransformationParams, Conv1dConvertTransformationCPUTest::getTestCaseName);
} // namespace
} // namespace CPUSubgraphTestsDefinitions
} // namespace
} // namespace test
} // namespace ov

View File

@ -2,35 +2,22 @@
// SPDX-License-Identifier: Apache-2.0
//
#include <tuple>
#include <string>
#include <vector>
#include <memory>
#include <debug.h>
#include <shared_test_classes/base/ov_subgraph.hpp>
#include <ov_models/builders.hpp>
#include "common_test_utils/common_utils.hpp"
#include <common_test_utils/ov_tensor_utils.hpp>
#include "functional_test_utils/skip_tests_config.hpp"
#include "common_test_utils/node_builders/reduce.hpp"
#include "common_test_utils/ov_tensor_utils.hpp"
#include "shared_test_classes/base/ov_subgraph.hpp"
#include "test_utils/cpu_test_utils.hpp"
#include "cpp_interfaces/interface/ie_internal_plugin_config.hpp"
#include "test_utils/cpu_test_utils.hpp"
#include "test_utils/convolution_params.hpp"
using namespace InferenceEngine;
using namespace CPUTestUtils;
using namespace ov::test;
using namespace ngraph;
using namespace ngraph::helpers;
namespace CPUSubgraphTestsDefinitions {
namespace ov {
namespace test {
typedef std::tuple<
std::vector<int>, // Axis to reduce order
ngraph::helpers::ReductionType, // Reduce operation type
std::vector<InputShape> // Input shapes
> reduceConvertCPUTestParamsSet;
typedef std::tuple<std::vector<int>, // Axis to reduce order
ov::test::utils::ReductionType, // Reduce operation type
std::vector<InputShape> // Input shapes
>
reduceConvertCPUTestParamsSet;
class reduceTransformationCPUTest: public testing::WithParamInterface<reduceConvertCPUTestParamsSet>,
virtual public SubgraphBaseTest, public CPUTestsBase {
@ -38,7 +25,7 @@ public:
static std::string getTestCaseName(testing::TestParamInfo<reduceConvertCPUTestParamsSet> obj) {
std::vector<InputShape> inputShapes;
std::vector<int> axes;
ReductionType reductionType;
utils::ReductionType reductionType;
std::tie(axes, reductionType, inputShapes) = obj.param;
std::ostringstream result;
@ -65,18 +52,18 @@ protected:
ov::ParameterVector params;
for (auto&& shape : inputDynamicShapes) {
params.push_back(std::make_shared<ov::op::v0::Parameter>(ngraph::element::f32, shape));
params.push_back(std::make_shared<ov::op::v0::Parameter>(ov::element::f32, shape));
}
std::vector<size_t> shapeAxes;
shapeAxes.push_back(axes.size());
auto reductionAxesNode = std::dynamic_pointer_cast<ngraph::Node>(
std::make_shared<ngraph::opset3::Constant>(ngraph::element::Type_t::i64, ngraph::Shape(shapeAxes), axes));
auto reductionAxesNode = std::dynamic_pointer_cast<ov::Node>(
std::make_shared<ov::op::v0::Constant>(ov::element::Type_t::i64, ov::Shape(shapeAxes), axes));
const auto reduce = ngraph::builder::makeReduce(params[0], reductionAxesNode, keepDims, reductionType);
const auto reduce = utils::make_reduce(params[0], reductionAxesNode, keepDims, reductionType);
function = makeNgraphFunction(ElementType::f32, params, reduce, "Reduce");
}
private:
ngraph::helpers::ReductionType reductionType;
utils::ReductionType reductionType;
};
TEST_P(reduceTransformationCPUTest, CompareWithRefs) {
@ -88,11 +75,11 @@ namespace {
std::vector<std::vector<ov::test::InputShape>> inputShapes = {
{{{}, {{2, 19, 2, 9}}}}
};
const std::vector<ReductionType> reductionTypes = {
ReductionType::Min,
ReductionType::Max,
ReductionType::Sum,
ReductionType::Prod
const std::vector<utils::ReductionType> reductionTypes = {
utils::ReductionType::Min,
utils::ReductionType::Max,
utils::ReductionType::Sum,
utils::ReductionType::Prod
};
const std::vector<std::vector<int>> axes = {
{0, 1},
@ -114,5 +101,6 @@ const auto reduceTransformationParams = ::testing::Combine(::testing::ValuesIn(a
INSTANTIATE_TEST_SUITE_P(smoke_GroupConvToConvTransformationTest, reduceTransformationCPUTest,
reduceTransformationParams, reduceTransformationCPUTest::getTestCaseName);
} // namespace
} // namespace CPUSubgraphTestsDefinitions
} // namespace
} // namespace test
} // namespace ov

View File

@ -32,23 +32,23 @@
// |output|
// --------
#include <tuple>
#include <string>
#include <vector>
#include <memory>
#include <debug.h>
#include <shared_test_classes/base/ov_subgraph.hpp>
#include <ov_models/builders.hpp>
#include "common_test_utils/common_utils.hpp"
#include <common_test_utils/ov_tensor_utils.hpp>
#include "functional_test_utils/skip_tests_config.hpp"
#include "common_test_utils/node_builders/eltwise.hpp"
#include "common_test_utils/ov_tensor_utils.hpp"
#include "ov_models/builders.hpp"
#include "shared_test_classes/base/ov_subgraph.hpp"
#include "test_utils/cpu_test_utils.hpp"
using namespace CPUTestUtils;
using ngraph::helpers::EltwiseTypes;
using namespace ov::test;
#include <memory>
#include <string>
#include <tuple>
#include <vector>
namespace CPUSubgraphTestsDefinitions {
using namespace CPUTestUtils;
namespace ov {
namespace test {
using namespace ov::test::utils;
using InputShapesTuple = std::tuple<
std::vector<InputShape>, // eltwise input shapes
@ -122,7 +122,7 @@ public:
return results.str();
}
void generate_inputs(const std::vector<ngraph::Shape>& targetInputStaticShapes) override {
void generate_inputs(const std::vector<ov::Shape>& targetInputStaticShapes) override {
inputs.clear();
const auto& funcInputs = function->inputs();
for (size_t i = 0; i < funcInputs.size(); ++i) {
@ -155,31 +155,31 @@ protected:
init_input_shapes(eltwiseInputShapes);
ngraph::ParameterVector ngraphParam;
std::vector<std::shared_ptr<ngraph::Node>> ngraphInputs;
ov::ParameterVector paramVec;
std::vector<std::shared_ptr<ov::Node>> inputNodes;
for (size_t i = 0; i < inputDynamicShapes.size(); i++) {
ngraphParam.push_back(std::make_shared<ngraph::opset1::Parameter>(inputPrecisions[i], inputDynamicShapes[i]));
ngraphInputs.push_back(ngraphParam.back());
paramVec.push_back(std::make_shared<ov::op::v0::Parameter>(inputPrecisions[i], inputDynamicShapes[i]));
inputNodes.push_back(paramVec.back());
}
auto lastNode0 = ngraph::builder::makeEltwise(ngraphParam[0], ngraphParam[1], eltwiseOpTypes[0]);
auto lastNode0 = utils::makeEltwise(paramVec[0], paramVec[1], eltwiseOpTypes[0]);
lastNode0->get_rt_info() = getCPUInfo();
auto lastNode1 = ngraph::builder::makeEltwise(ngraphParam[2], ngraphParam[3], eltwiseOpTypes[1]);
auto lastNode1 = utils::makeEltwise(paramVec[2], paramVec[3], eltwiseOpTypes[1]);
lastNode1->get_rt_info() = getCPUInfo();
if (withQuantization) {
lastNode0 = ngraph::builder::makeFakeQuantize(lastNode0, ::ngraph::element::Type(::ngraph::element::Type_t::f32),
lastNode0 = ngraph::builder::makeFakeQuantize(lastNode0, ov::element::Type(ov::element::Type_t::f32),
256, fqInputShapes[0]);
lastNode1 = ngraph::builder::makeFakeQuantize(lastNode1, ::ngraph::element::Type(::ngraph::element::Type_t::f32),
lastNode1 = ngraph::builder::makeFakeQuantize(lastNode1, ov::element::Type(ov::element::Type_t::f32),
256, fqInputShapes[1]);
}
if (needReshape) {
auto reshapeConstNode = ngraph::builder::makeConstant(::ngraph::element::Type(::ngraph::element::Type_t::i32),
auto reshapeConstNode = ngraph::builder::makeConstant(ov::element::Type(ov::element::Type_t::i32),
{reshapeShape.size()}, reshapeShape);
lastNode1 = std::make_shared<ngraph::opset4::Reshape>(lastNode1, reshapeConstNode, false);
lastNode1 = std::make_shared<ov::op::v1::Reshape>(lastNode1, reshapeConstNode, false);
}
auto concat = std::make_shared<ov::op::v0::Concat>(ov::NodeVector{lastNode0, lastNode1}, 0);
function = std::make_shared<ngraph::Function>(concat, ngraphParam, "eltwise_cache");
function = std::make_shared<ov::Model>(concat, paramVec, "eltwise_cache");
}
};
@ -1328,5 +1328,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_EltwiseCache_7D_dyn, EltwiseCacheTest,
::testing::Values(cpuParams_empty)),
EltwiseCacheTest::getTestCaseName);
} // namespace
} // namespace CPUSubgraphTestsDefinitions
} // namespace
} // namespace test
} // namespace ov

View File

@ -6,35 +6,36 @@
#include <string>
#include <vector>
#include <memory>
#include <debug.h>
#include <shared_test_classes/base/ov_subgraph.hpp>
#include <ov_models/builders.hpp>
#include "shared_test_classes/base/ov_subgraph.hpp"
#include "ov_models/builders.hpp"
#include "common_test_utils/common_utils.hpp"
#include <common_test_utils/ov_tensor_utils.hpp>
#include "functional_test_utils/skip_tests_config.hpp"
#include "common_test_utils/ov_tensor_utils.hpp"
#include "test_utils/cpu_test_utils.hpp"
#include "common_test_utils/node_builders/eltwise.hpp"
using namespace CPUTestUtils;
using ngraph::helpers::EltwiseTypes;
using namespace ov::test;
namespace CPUSubgraphTestsDefinitions {
typedef std::tuple<
std::vector<InputShape>, // Input shapes
ngraph::helpers::InputLayerType, // Secondary input type
std::vector<ElementType>, // Input precisions
std::vector<EltwiseTypes>, // Eltwise operations
bool, // With quantization
std::string // Device name
> EltwiseChainTuple;
namespace ov {
namespace test {
using namespace ov::test::utils;
typedef std::tuple<std::vector<InputShape>, // Input shapes
InputLayerType, // Secondary input type
std::vector<ElementType>, // Input precisions
std::vector<EltwiseTypes>, // Eltwise operations
bool, // With quantization
std::string // Device name
>
EltwiseChainTuple;
class EltwiseChainTest : public testing::WithParamInterface<EltwiseChainTuple>,
virtual public SubgraphBaseTest {
public:
static std::string getTestCaseName(const testing::TestParamInfo<EltwiseChainTuple> &obj) {
std::vector<InputShape> inputShapes;
ngraph::helpers::InputLayerType secondaryInputType;
InputLayerType secondaryInputType;
std::vector<ElementType> inputPrecisions;
std::vector<EltwiseTypes> eltwiseOpTypes;
bool withQuantization;
@ -65,7 +66,7 @@ public:
return results.str();
}
void generate_inputs(const std::vector<ngraph::Shape>& targetInputStaticShapes) override {
void generate_inputs(const std::vector<ov::Shape>& targetInputStaticShapes) override {
inputs.clear();
const auto& funcInputs = function->inputs();
for (size_t i = 0; i < funcInputs.size(); ++i) {
@ -81,7 +82,7 @@ protected:
abs_threshold = 0.1f;
std::vector<InputShape> inputShapes;
ngraph::helpers::InputLayerType secondaryInputType;
InputLayerType secondaryInputType;
std::vector<ElementType> inputPrecisions;
std::vector<EltwiseTypes> eltwiseOpTypes;
bool withQuantization;
@ -89,27 +90,27 @@ protected:
init_input_shapes(inputShapes);
ngraph::ParameterVector ngraphParam;
std::vector<std::shared_ptr<ngraph::Node>> ngraphInputs;
ov::ParameterVector paramVec;
std::vector<std::shared_ptr<ov::Node>> inputNodes;
if (secondaryInputType == ngraph::helpers::InputLayerType::PARAMETER) {
for (size_t i = 0; i < inputDynamicShapes.size(); i++) {
ngraphParam.push_back(std::make_shared<ngraph::opset1::Parameter>(inputPrecisions[i], inputDynamicShapes[i]));
ngraphInputs.push_back(ngraphParam.back());
paramVec.push_back(std::make_shared<ov::op::v0::Parameter>(inputPrecisions[i], inputDynamicShapes[i]));
inputNodes.push_back(paramVec.back());
}
} else {
ngraphParam = ov::ParameterVector {std::make_shared<ov::op::v0::Parameter>(inputPrecisions[0], inputDynamicShapes.front())};
paramVec = ov::ParameterVector {std::make_shared<ov::op::v0::Parameter>(inputPrecisions[0], inputDynamicShapes.front())};
for (size_t i = 1; i < inputPrecisions.size(); i++) {
std::vector<float> ngraphInput1Data(ngraph::shape_size(targetStaticShapes[0][i]));
ngraphInputs.push_back(ngraph::builder::makeConstant(inputPrecisions[i], targetStaticShapes[0][i],
ngraphInput1Data, true));
std::vector<float> input1Data(ov::shape_size(targetStaticShapes[0][i]));
inputNodes.push_back(
ngraph::builder::makeConstant(inputPrecisions[i], targetStaticShapes[0][i], input1Data, true));
}
}
if (withQuantization) {
std::vector<std::shared_ptr<ngraph::Node>> eltwiseOps;
eltwiseOps.push_back(ngraph::builder::makeEltwise(ngraphParam[0], ngraphInputs[0], eltwiseOpTypes[0]));
std::vector<std::shared_ptr<ov::Node>> eltwiseOps;
eltwiseOps.push_back(makeEltwise(paramVec[0], inputNodes[0], eltwiseOpTypes[0]));
for (size_t i = 1; i < eltwiseOpTypes.size() - 1; i++) {
eltwiseOps.push_back(ngraph::builder::makeEltwise(eltwiseOps[eltwiseOps.size() - 1], ngraphInputs[i], eltwiseOpTypes[i]));
eltwiseOps.push_back(makeEltwise(eltwiseOps[eltwiseOps.size() - 1], inputNodes[i], eltwiseOpTypes[i]));
}
std::vector<size_t> constShape(targetStaticShapes[0][0].size(), 1);
@ -118,19 +119,19 @@ protected:
::ngraph::element::Type(::ngraph::element::Type_t::f32),
256, constShape);
eltwiseOps.push_back(ngraph::builder::makeEltwise(fq, ngraphInputs[eltwiseOpTypes.size() - 1], eltwiseOpTypes[eltwiseOpTypes.size() - 1]));
eltwiseOps.push_back(makeEltwise(fq, inputNodes[eltwiseOpTypes.size() - 1], eltwiseOpTypes[eltwiseOpTypes.size() - 1]));
ngraph::ResultVector results{std::make_shared<ngraph::opset1::Result>(eltwiseOps[eltwiseOps.size() - 1])};
function = std::make_shared<ngraph::Function>(results, ngraphParam, "eltwise_chain_fq");
ov::ResultVector results{std::make_shared<ov::op::v0::Result>(eltwiseOps[eltwiseOps.size() - 1])};
function = std::make_shared<ov::Model>(results, paramVec, "eltwise_chain_fq");
} else {
std::vector<std::shared_ptr<ngraph::Node>> eltwiseOps;
eltwiseOps.push_back(ngraph::builder::makeEltwise(ngraphParam[0], ngraphInputs[0], eltwiseOpTypes[0]));
std::vector<std::shared_ptr<ov::Node>> eltwiseOps;
eltwiseOps.push_back(makeEltwise(paramVec[0], inputNodes[0], eltwiseOpTypes[0]));
for (size_t i = 1; i < eltwiseOpTypes.size(); i++) {
eltwiseOps.push_back(ngraph::builder::makeEltwise(eltwiseOps[eltwiseOps.size() - 1], ngraphInputs[i], eltwiseOpTypes[i]));
eltwiseOps.push_back(makeEltwise(eltwiseOps[eltwiseOps.size() - 1], inputNodes[i], eltwiseOpTypes[i]));
}
ngraph::ResultVector results{std::make_shared<ngraph::opset1::Result>(eltwiseOps[eltwiseOps.size() - 1])};
function = std::make_shared<ngraph::Function>(results, ngraphParam, "eltwise_chain");
ov::ResultVector results{std::make_shared<ov::op::v0::Result>(eltwiseOps[eltwiseOps.size() - 1])};
function = std::make_shared<ov::Model>(results, paramVec, "eltwise_chain");
}
}
};
@ -141,7 +142,7 @@ TEST_P(EltwiseChainTest, CompareWithRefs) {
namespace {
std::vector<std::vector<ngraph::Shape>> inputShapes = {
std::vector<std::vector<ov::Shape>> inputShapes = {
{{1, 1, 2, 3}, {1, 1, 2, 3}, {1, 1, 2, 3}, {1, 1, 2, 3}},
{{1, 48, 5, 6}, {1, 48, 1, 1}, {1, 48, 5, 6}, {1, 1, 5, 6}},
{{1, 72, 28, 28}, {1, 72, 1, 1}, {1, 72, 1, 1}, {1, 72, 1, 1}},
@ -166,14 +167,14 @@ std::vector<std::vector<EltwiseTypes>> eltwiseOps = {
INSTANTIATE_TEST_SUITE_P(smoke_EltwiseChain, EltwiseChainTest,
::testing::Combine(
::testing::ValuesIn(static_shapes_to_test_representation(inputShapes)),
::testing::Values(ngraph::helpers::InputLayerType::CONSTANT),
::testing::Values(InputLayerType::CONSTANT),
::testing::ValuesIn(inputPrecisions),
::testing::ValuesIn(eltwiseOps),
::testing::Values(false),
::testing::Values(ov::test::utils::DEVICE_CPU)),
EltwiseChainTest::getTestCaseName);
std::vector<std::vector<ngraph::Shape>> inputShapesFQ = {
std::vector<std::vector<ov::Shape>> inputShapesFQ = {
{{1, 2, 2, 3}, {1, 2, 2, 3}, {1, 2, 2, 3}, {1, 2, 2, 3}},
{{2, 33, 5, 5}, {2, 33, 5, 5}, {2, 33, 1, 5}, {2, 33, 5, 5}},
{{2, 33, 5, 17}, {2, 33, 5, 17}, {2, 33, 5, 17}, {2, 33, 5, 17}},
@ -197,7 +198,7 @@ std::vector<std::vector<ElementType>> inputPrecisionsFQ {
INSTANTIATE_TEST_SUITE_P(smoke_EltwiseChainWithFQ, EltwiseChainTest,
::testing::Combine(
::testing::ValuesIn(static_shapes_to_test_representation(inputShapesFQ)),
::testing::Values(ngraph::helpers::InputLayerType::CONSTANT),
::testing::Values(InputLayerType::CONSTANT),
::testing::ValuesIn(inputPrecisionsFQ),
::testing::ValuesIn(eltwiseOps),
::testing::Values(true),
@ -455,12 +456,13 @@ std::vector<std::vector<InputShape>> inputShapes_dyn = {
INSTANTIATE_TEST_SUITE_P(smoke_EltwiseChain_dyn, EltwiseChainTest,
::testing::Combine(
::testing::ValuesIn(inputShapes_dyn),
::testing::Values(ngraph::helpers::InputLayerType::PARAMETER),
::testing::Values(InputLayerType::PARAMETER),
::testing::ValuesIn(inputPrecisions),
::testing::ValuesIn(eltwiseOps),
::testing::Values(false),
::testing::Values(ov::test::utils::DEVICE_CPU)),
EltwiseChainTest::getTestCaseName);
} // namespace
} // namespace CPUSubgraphTestsDefinitions
} // namespace
} // namespace test
} // namespace ov

View File

@ -22,9 +22,11 @@
using namespace CPUTestUtils;
using namespace ov::gen_pattern;
using namespace ov::test;
using namespace ov;
namespace ov {
namespace test {
static ov::OutputVector makeCosSinCache(int max_position_embeddings, int rotary_ndims) {
std::vector<float> lut_sin(max_position_embeddings * rotary_ndims, 0.0f);
std::vector<float> lut_cos(max_position_embeddings * rotary_ndims, 0.0f);
@ -129,8 +131,6 @@ static std::shared_ptr<ov::Model> buildROPE_Llama2(const int batch,
return std::make_shared<ov::Model>(ov::NodeVector{add_Add}, ov::ParameterVector{input, pos_id_end, pos_ids});
}
namespace CPULayerTestsDefinitions {
class RoPECPUTestLlama2 : public SubgraphBaseTest {
public:
ov::Tensor create_i32_tensor(const ov::Shape& shape, int start, int step = 1) {
@ -328,4 +328,5 @@ TEST_F(RoPECPUTestChatGLM, smoke_CompareWithRefs) {
CheckNumberOfNodesWithType(compiledModel, "RoPE", 1);
}
} // namespace CPULayerTestsDefinitions
} // namespace test
} // namespace ov

View File

@ -2,16 +2,19 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "common_test_utils/node_builders/gru_cell.hpp"
#include "common_test_utils/node_builders/lstm_cell.hpp"
#include "common_test_utils/node_builders/rnn_cell.hpp"
#include "shared_test_classes/base/ov_subgraph.hpp"
#include "ov_models/builders.hpp"
#include "test_utils/cpu_test_utils.hpp"
#include "transformations/op_conversions/bidirectional_sequences_decomposition.hpp"
#include "transformations/op_conversions/convert_sequences_to_tensor_iterator.hpp"
using namespace CPUTestUtils;
using namespace ov::test;
using namespace ov::test::utils;
namespace SubgraphTestsDefinitions {
namespace ov {
namespace test {
enum class SEQ_TYPE {
GRU,
@ -34,7 +37,7 @@ using SeqParams = std::tuple<SEQ_TYPE, // node type
bool, // Linear_before_reset
ov::op::RecurrentSequenceDirection, // Direction
ElementType, // Network precision
ngraph::helpers::InputLayerType>; // 'sequence_lengths' input type
InputLayerType>; // 'sequence_lengths' input type
class SequenceCPUTest : public testing::WithParamInterface<SeqParams>, virtual public ov::test::SubgraphBaseTest, public CPUTestsBase {
public:
@ -47,7 +50,7 @@ public:
bool linearBeforeReset;
ov::op::RecurrentSequenceDirection direction;
ElementType netPrecision;
ngraph::helpers::InputLayerType seqInType;
InputLayerType seqInType;
std::tie(seqType, hidden_size, input_size, inShapeParams, activations, clip, linearBeforeReset, direction, netPrecision, seqInType) = obj.param;
@ -141,7 +144,7 @@ protected:
weightShape.push_back(B_shape);
ov::PartialShape seq_len_shape(std::vector<ov::Dimension>{bounds[batch_size_pos]});
if (seqInType == ngraph::helpers::InputLayerType::PARAMETER) {
if (seqInType == InputLayerType::PARAMETER) {
inputDynamicShapes.push_back(seq_len_shape);
} else {
OPENVINO_ASSERT(seq_len_shape.is_static());
@ -160,7 +163,7 @@ protected:
if (seqType == SEQ_TYPE::LSTM) {
currTS.emplace_back(std::vector<size_t>{bs, numDirections, hidden_size});
}
if (seqInType == ngraph::helpers::InputLayerType::PARAMETER) {
if (seqInType == InputLayerType::PARAMETER) {
currTS.emplace_back(std::vector<size_t>{bs});
}
targetStaticShapes.push_back(currTS);
@ -168,7 +171,7 @@ protected:
// funciton creation
std::vector<ov::element::Type> types(inputDynamicShapes.size(), netPrecision);
if (seqInType == ngraph::helpers::InputLayerType::PARAMETER) {
if (seqInType == InputLayerType::PARAMETER) {
types.back() = ElementType::i64;
}
ov::ParameterVector params;
@ -190,45 +193,45 @@ protected:
std::shared_ptr<ov::Node> seq_node;
if (seqType == SEQ_TYPE::GRU) {
seq_node = ngraph::builder::makeGRU(inputs,
weightShape,
hidden_size,
activations,
{},
{},
clip,
linearBeforeReset,
true,
direction,
(seqInType == ngraph::helpers::InputLayerType::CONSTANT ?
ngraph::helpers::SequenceTestsMode::CONVERT_TO_TI_MAX_SEQ_LEN_CONST :
ngraph::helpers::SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_PARAM));
seq_node = utils::make_gru(
inputs,
weightShape,
hidden_size,
activations,
{},
{},
clip,
linearBeforeReset,
true,
direction,
(seqInType == InputLayerType::CONSTANT ? SequenceTestsMode::CONVERT_TO_TI_MAX_SEQ_LEN_CONST
: SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_PARAM));
} else if (seqType == SEQ_TYPE::LSTM) {
seq_node = ngraph::builder::makeLSTM(inputs,
weightShape,
hidden_size,
activations,
{},
{},
clip,
true,
direction,
(seqInType == ngraph::helpers::InputLayerType::CONSTANT ?
ngraph::helpers::SequenceTestsMode::CONVERT_TO_TI_MAX_SEQ_LEN_CONST :
ngraph::helpers::SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_PARAM));
seq_node = utils::make_lstm(
inputs,
weightShape,
hidden_size,
activations,
{},
{},
clip,
true,
direction,
(seqInType == InputLayerType::CONSTANT ? SequenceTestsMode::CONVERT_TO_TI_MAX_SEQ_LEN_CONST
: SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_PARAM));
} else if (seqType == SEQ_TYPE::RNN) {
seq_node = ngraph::builder::makeRNN(inputs,
weightShape,
hidden_size,
activations,
{},
{},
clip,
true,
direction,
(seqInType == ngraph::helpers::InputLayerType::CONSTANT ?
ngraph::helpers::SequenceTestsMode::CONVERT_TO_TI_MAX_SEQ_LEN_CONST :
ngraph::helpers::SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_PARAM));
seq_node = utils::make_rnn(
inputs,
weightShape,
hidden_size,
activations,
{},
{},
clip,
true,
direction,
(seqInType == InputLayerType::CONSTANT ? SequenceTestsMode::CONVERT_TO_TI_MAX_SEQ_LEN_CONST
: SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_PARAM));
} else {
OPENVINO_THROW("Unsupported seq type");
}
@ -254,7 +257,7 @@ protected:
const size_t batchSize = targetInputStaticShapes[0][1];
const int64_t maxSeqLen = targetInputStaticShapes[0][0];
if (seqInType == ngraph::helpers::InputLayerType::PARAMETER) {
if (seqInType == InputLayerType::PARAMETER) {
const auto& funcInputs = function->inputs();
const auto& seqLenInput = inputs.find(funcInputs[seqLengthInIdx].get_node_shared_ptr());
if (seqLenInput == inputs.end())
@ -266,7 +269,7 @@ protected:
}
private:
ngraph::helpers::InputLayerType seqInType;
InputLayerType seqInType;
size_t seqLengthInIdx = 2;
};
@ -326,7 +329,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_SequenceCPUTest_dynamic_lstm_rnn, SequenceCPUTest
::testing::ValuesIn(linearBeforeReset),
::testing::ValuesIn(direction),
::testing::ValuesIn(netPrecisions),
::testing::Values(ngraph::helpers::InputLayerType::PARAMETER)),
::testing::Values(InputLayerType::PARAMETER)),
SequenceCPUTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_SequenceCPUTest_dynamic_gru, SequenceCPUTest,
@ -339,7 +342,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_SequenceCPUTest_dynamic_gru, SequenceCPUTest,
::testing::ValuesIn(linearBeforeReset),
::testing::ValuesIn(direction),
::testing::ValuesIn(netPrecisions),
::testing::Values(ngraph::helpers::InputLayerType::PARAMETER)),
::testing::Values(InputLayerType::PARAMETER)),
SequenceCPUTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_SequenceCPUTest_static_gru, SequenceCPUTest,
@ -352,7 +355,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_SequenceCPUTest_static_gru, SequenceCPUTest,
::testing::ValuesIn(linearBeforeReset),
::testing::ValuesIn(direction),
::testing::ValuesIn(netPrecisions),
::testing::Values(ngraph::helpers::InputLayerType::CONSTANT)),
::testing::Values(InputLayerType::CONSTANT)),
SequenceCPUTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_SequenceCPUTest_static_rnn_lstm, SequenceCPUTest,
@ -365,7 +368,8 @@ INSTANTIATE_TEST_SUITE_P(smoke_SequenceCPUTest_static_rnn_lstm, SequenceCPUTest,
::testing::ValuesIn(linearBeforeReset),
::testing::ValuesIn(direction),
::testing::ValuesIn(netPrecisions),
::testing::Values(ngraph::helpers::InputLayerType::CONSTANT)),
::testing::Values(InputLayerType::CONSTANT)),
SequenceCPUTest::getTestCaseName);
} // namespace SubgraphTestsDefinitions
} // namespace test
} // namespace ov

View File

@ -2,14 +2,12 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "shared_test_classes/base/ov_subgraph.hpp"
#include "common_test_utils/ov_tensor_utils.hpp"
#include "ov_models/builders.hpp"
#include <common_test_utils/ov_tensor_utils.hpp>
#include "functional_test_utils/skip_tests_config.hpp"
#include "shared_test_classes/base/ov_subgraph.hpp"
using namespace ov::test;
namespace SubgraphTestsDefinitions {
namespace ov {
namespace test {
class StaticZeroDims : public SubgraphBaseTest {
protected:
@ -20,26 +18,26 @@ protected:
init_input_shapes({inputShapes});
auto ngPrc = ngraph::element::f32;
auto ngPrc = ov::element::f32;
ov::ParameterVector inputParams;
for (auto&& shape : inputDynamicShapes) {
inputParams.push_back(std::make_shared<ov::op::v0::Parameter>(ngPrc, shape));
}
auto splitAxisOp = std::make_shared<ngraph::opset3::Constant>(ngraph::element::i64, ngraph::Shape{}, std::vector<int64_t>{0});
auto splitAxisOp = std::make_shared<ov::op::v0::Constant>(ov::element::i64, ov::Shape{}, std::vector<int64_t>{0});
std::vector<int> splitLenght = {1, 0, 6};
auto splitLengthsOp = std::make_shared<ngraph::opset3::Constant>(ngraph::element::i32, ngraph::Shape{splitLenght.size()}, splitLenght);
auto varSplit = std::make_shared<ngraph::opset3::VariadicSplit>(inputParams[0], splitAxisOp, splitLengthsOp);
auto splitLengthsOp = std::make_shared<ov::op::v0::Constant>(ov::element::i32, ov::Shape{splitLenght.size()}, splitLenght);
auto varSplit = std::make_shared<ov::op::v1::VariadicSplit>(inputParams[0], splitAxisOp, splitLengthsOp);
auto relu1 = std::make_shared<ngraph::opset5::Relu>(varSplit->output(0));
auto relu1 = std::make_shared<ov::op::v0::Relu>(varSplit->output(0));
auto numInRoi = ngraph::builder::makeConstant(ngPrc, {0}, std::vector<float>{}, false);
auto expDet = std::make_shared<ov::op::v6::ExperimentalDetectronTopKROIs>(varSplit->output(1), numInRoi, 10);
auto relu2 = std::make_shared<ngraph::opset5::Relu>(expDet);
auto relu2 = std::make_shared<ov::op::v0::Relu>(expDet);
auto relu3 = std::make_shared<ngraph::opset5::Relu>(varSplit->output(2));
auto relu3 = std::make_shared<ov::op::v0::Relu>(varSplit->output(2));
ngraph::NodeVector results{relu1, relu2, relu3};
function = std::make_shared<ngraph::Function>(results, inputParams, "StaticZeroDims");
ov::NodeVector results{relu1, relu2, relu3};
function = std::make_shared<ov::Model>(results, inputParams, "StaticZeroDims");
}
void compare(const std::vector<ov::Tensor> &expected, const std::vector<ov::Tensor> &actual) override {
@ -59,4 +57,5 @@ TEST_F(StaticZeroDims, smoke_CompareWithRefs) {
run();
}
} // namespace SubgraphTestsDefinitions
} // namespace test
} // namespace ov