Upgrade CPU func tests to 2.0 (#21384)

* [CPU Plugin][Func Test] Upgrade NonInputInPlaceTest to API 2.0

Signed-off-by: Zhai, Xuejun <xuejun.zhai@intel.com>

* [CPU Plugin][Func Test] Upgrade InputOutputTensorReuse to API 2.0

Signed-off-by: Zhai, Xuejun <xuejun.zhai@intel.com>

* [CPU Plugin][Func Test] Upgrade InputTensorROI to API 2.0

Signed-off-by: Zhai, Xuejun <xuejun.zhai@intel.com>

* [CPU Plugin][Func Test] Upgrade IntertactionCPUTest to API 2.0

Signed-off-by: Zhai, Xuejun <xuejun.zhai@intel.com>

* [CPU Plugin][Func Test] Upgrade EdgeWithSameNameInTwoModels to API 2.0

Signed-off-by: Zhai, Xuejun <xuejun.zhai@intel.com>

* [CPU Plugin][Func Test] Upgrade MHATest to API 2.0

Signed-off-by: Zhai, Xuejun <xuejun.zhai@intel.com>

* [CPU Plugin][Func Test] Upgrade NgramCPUTest to API 2.0

Signed-off-by: Zhai, Xuejun <xuejun.zhai@intel.com>

* [CPU Plugin][Func Test] Upgrade ParameterResultCustomBlobTest to API 2.0

Signed-off-by: Zhai, Xuejun <xuejun.zhai@intel.com>

* [CPU Plugin][Func Test] Upgrade RemoveUselessBF16ConvertCPUTest to API 2.0

Signed-off-by: Zhai, Xuejun <xuejun.zhai@intel.com>

* [CPU Plugin][Func Test] remove ngraph & opset

Signed-off-by: Zhai, Xuejun <xuejun.zhai@intel.com>

* [CPU Plugin][Func Test] fix review comments

Signed-off-by: Zhai, Xuejun <xuejun.zhai@intel.com>

* [CPU Plugin][Func Test] fix snippets mode error

Signed-off-by: Zhai, Xuejun <xuejun.zhai@intel.com>

---------

Signed-off-by: Zhai, Xuejun <xuejun.zhai@intel.com>
This commit is contained in:
Xuejun Zhai 2023-12-05 13:44:42 +08:00 committed by GitHub
parent 0d05f87004
commit 5dda9f333b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 554 additions and 491 deletions

View File

@ -2,16 +2,13 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// //
#include <shared_test_classes/base/ov_subgraph.hpp> #include "common_test_utils/node_builders/eltwise.hpp"
#include "shared_test_classes/base/ov_subgraph.hpp"
#include "test_utils/cpu_test_utils.hpp" #include "test_utils/cpu_test_utils.hpp"
#include "shared_test_classes/base/layer_test_utils.hpp"
#include "ov_models/utils/ov_helpers.hpp"
#include "ov_models/builders.hpp"
using namespace CPUTestUtils; using namespace CPUTestUtils;
using namespace InferenceEngine; namespace ov {
namespace test {
namespace SubgraphTestsDefinitions {
// If a node (CumSum) with constant parents has several non-constant nodes (Eltwises) than the edge is broken. // If a node (CumSum) with constant parents has several non-constant nodes (Eltwises) than the edge is broken.
// The fix is to check node type - is should be Input. // The fix is to check node type - is should be Input.
// Subgraph: // Subgraph:
@ -24,16 +21,13 @@ namespace SubgraphTestsDefinitions {
* \ / \ / * \ / \ /
* \ / \ / * \ / \ /
* Eltwise Eltwise * Eltwise Eltwise
* \ / * \ /
* Eltwise * Eltwise
* | * |
* Result * Result
*/ */
using namespace ov::test; class NonInputInPlaceTest : public testing::WithParamInterface<ElementType>, virtual public SubgraphBaseTest {
class NonInputInPlaceTest : public testing::WithParamInterface<ElementType>,
virtual public SubgraphBaseTest {
public: public:
static std::string getTestCaseName(testing::TestParamInfo<ElementType> obj) { static std::string getTestCaseName(testing::TestParamInfo<ElementType> obj) {
std::ostringstream result; std::ostringstream result;
@ -44,34 +38,36 @@ public:
void SetUp() override { void SetUp() override {
targetDevice = utils::DEVICE_CPU; targetDevice = utils::DEVICE_CPU;
configuration.insert({ov::hint::inference_precision.name(), ov::element::f16.to_string()}); configuration.insert({ov::hint::inference_precision.name(), ov::element::f16.to_string()});
const std::vector<size_t> inputShape = {1, 11, 3, 3}; const ov::Shape inputShape = {1, 11, 3, 3};
targetStaticShapes = {{inputShape, inputShape}}; targetStaticShapes = {{inputShape, inputShape}};
ElementType prc = this->GetParam(); ElementType prc = this->GetParam();
ov::ParameterVector inputParams {std::make_shared<ov::op::v0::Parameter>(prc, ov::Shape(inputShape)), ov::ParameterVector inputParams{std::make_shared<ov::op::v0::Parameter>(prc, ov::Shape(inputShape)),
std::make_shared<ov::op::v0::Parameter>(prc, ov::Shape(inputShape))}; std::make_shared<ov::op::v0::Parameter>(prc, ov::Shape(inputShape))};
auto cumsum_tensor = ngraph::opset8::Constant::create(prc, inputShape, {10.0f}); auto cumsum_tensor = ov::op::v0::Constant::create(prc, inputShape, {10.0f});
auto axis_node = ngraph::opset8::Constant::create(ngraph::element::i32, {}, {0}); auto axis_node = ov::op::v0::Constant::create(ov::element::i32, {}, {0});
const auto cumsum = std::make_shared<ov::op::v0::CumSum>(cumsum_tensor, axis_node); const auto cumsum = std::make_shared<ov::op::v0::CumSum>(cumsum_tensor, axis_node);
auto eltwiseMul = ngraph::builder::makeEltwise(inputParams[0], cumsum, ngraph::helpers::EltwiseTypes::MULTIPLY); auto eltwiseMul = ov::test::utils::makeEltwise(inputParams[0], cumsum, ov::test::utils::EltwiseTypes::MULTIPLY);
auto eltwiseAdd1 = ngraph::builder::makeEltwise(inputParams[1], cumsum, ngraph::helpers::EltwiseTypes::ADD); auto eltwiseAdd1 = ov::test::utils::makeEltwise(inputParams[1], cumsum, ov::test::utils::EltwiseTypes::ADD);
auto eltwiseAdd2 = ngraph::builder::makeEltwise(eltwiseAdd1, eltwiseMul, ngraph::helpers::EltwiseTypes::ADD); auto eltwiseAdd2 = ov::test::utils::makeEltwise(eltwiseAdd1, eltwiseMul, ov::test::utils::EltwiseTypes::ADD);
ngraph::ResultVector results{std::make_shared<ngraph::opset8::Result>(eltwiseAdd2)}; ov::ResultVector results{std::make_shared<ov::op::v0::Result>(eltwiseAdd2)};
function = std::make_shared<ngraph::Function>(results, inputParams, "NonInputInPlaceT"); function = std::make_shared<ov::Model>(results, inputParams, "NonInputInPlaceT");
} }
}; };
namespace { namespace {
TEST_P(NonInputInPlaceTest, CompareWithRefs) { TEST_P(NonInputInPlaceTest, CompareWithRefs) {
run(); run();
} }
INSTANTIATE_TEST_SUITE_P(smoke_NonInputInPlaceTest_CPU, NonInputInPlaceTest, INSTANTIATE_TEST_SUITE_P(smoke_NonInputInPlaceTest_CPU,
testing::Values(ngraph::element::f32, ngraph::element::f16), NonInputInPlaceTest,
NonInputInPlaceTest::getTestCaseName); testing::Values(ov::element::f32, ov::element::f16),
NonInputInPlaceTest::getTestCaseName);
} // namespace } // namespace
} // namespace SubgraphTestsDefinitions } // namespace test
} // namespace ov

View File

@ -3,11 +3,9 @@
// //
#include "shared_test_classes/base/ov_subgraph.hpp" #include "shared_test_classes/base/ov_subgraph.hpp"
#include "ov_models/utils/ov_helpers.hpp"
#include "ov_models/builders.hpp"
using namespace InferenceEngine; namespace ov {
using namespace ov::test; namespace test {
/*This test runs the following subgraph: /*This test runs the following subgraph:
@ -22,14 +20,13 @@ using namespace ov::test;
Softmax Softmax
| |
Output_1 Output_1
Output_1 -> Param_1 Output_1 -> Param_1
The main purpose of this test is checking the code path when the output tensor is reused as an input tensor of the The main purpose of this test is checking the code path when the output tensor is reused as an input tensor of the
next infer request. next infer request.
*/ */
namespace SubgraphTestsDefinitions {
class InputOutputTensorReuse : public SubgraphBaseTest { class InputOutputTensorReuse : public SubgraphBaseTest {
public: public:
void SetUp() override { void SetUp() override {
@ -45,16 +42,17 @@ public:
input_params[1]->set_friendly_name("Param_1"); input_params[1]->set_friendly_name("Param_1");
auto first_soft_max = std::make_shared<ov::op::v1::Softmax>(input_params[1], softmax_axis); auto first_soft_max = std::make_shared<ov::op::v1::Softmax>(input_params[1], softmax_axis);
auto concat = std::make_shared<ov::op::v0::Concat>(ov::NodeVector{input_params[0], first_soft_max}, concat_axis); auto concat =
std::make_shared<ov::op::v0::Concat>(ov::NodeVector{input_params[0], first_soft_max}, concat_axis);
auto last_soft_max = std::make_shared<ov::op::v1::Softmax>(concat, softmax_axis); auto last_soft_max = std::make_shared<ov::op::v1::Softmax>(concat, softmax_axis);
ngraph::ResultVector results; ov::ResultVector results;
for (size_t i = 0; i < last_soft_max->get_output_size(); i++) for (size_t i = 0; i < last_soft_max->get_output_size(); i++)
results.push_back(std::make_shared<ngraph::opset1::Result>(last_soft_max->output(i))); results.push_back(std::make_shared<ov::op::v0::Result>(last_soft_max->output(i)));
results.front()->set_friendly_name("Output_1"); results.front()->set_friendly_name("Output_1");
function = std::make_shared<ngraph::Function>(results, input_params, "InputOutputTensorReuseTest"); function = std::make_shared<ov::Model>(results, input_params, "InputOutputTensorReuseTest");
} }
}; };
@ -68,9 +66,11 @@ TEST_F(InputOutputTensorReuse, smoke_Input_Output_Binding) {
for (size_t i = 0; i < num_iter; i++) { for (size_t i = 0; i < num_iter; i++) {
auto outputTensor = inferRequest.get_output_tensor(0); auto outputTensor = inferRequest.get_output_tensor(0);
inputShapes.back() = outputTensor.get_shape(); inputShapes.back() = outputTensor.get_shape();
auto itr = std::find_if(inputs.begin(), inputs.end(), [](const std::pair<std::shared_ptr<ov::Node>, ov::Tensor>& item) { auto itr = std::find_if(inputs.begin(),
return item.first->get_friendly_name() == "Param_1"; inputs.end(),
}); [](const std::pair<std::shared_ptr<ov::Node>, ov::Tensor>& item) {
return item.first->get_friendly_name() == "Param_1";
});
ASSERT_NE(itr, inputs.end()); ASSERT_NE(itr, inputs.end());
itr->second = outputTensor; itr->second = outputTensor;
const auto& expectedOutputs = calculate_refs(); const auto& expectedOutputs = calculate_refs();
@ -91,9 +91,10 @@ TEST_F(InputOutputTensorReuse, smoke_Input_Output_Bind_Once) {
auto outputTensor = inferRequest.get_output_tensor(0); auto outputTensor = inferRequest.get_output_tensor(0);
inputShapes.back() = outputTensor.get_shape(); inputShapes.back() = outputTensor.get_shape();
auto itr = std::find_if(inputs.begin(), inputs.end(), [](const std::pair<std::shared_ptr<ov::Node>, ov::Tensor>& item) { auto itr =
return item.first->get_friendly_name() == "Param_1"; std::find_if(inputs.begin(), inputs.end(), [](const std::pair<std::shared_ptr<ov::Node>, ov::Tensor>& item) {
}); return item.first->get_friendly_name() == "Param_1";
});
ASSERT_NE(itr, inputs.end()); ASSERT_NE(itr, inputs.end());
itr->second = outputTensor; itr->second = outputTensor;
@ -107,9 +108,11 @@ TEST_F(InputOutputTensorReuse, smoke_Input_Output_Bind_Once) {
inferRequest.infer(); inferRequest.infer();
compare(expectedOutputs, {outputTensor}); compare(expectedOutputs, {outputTensor});
auto itr = std::find_if(inputs.begin(), inputs.end(), [](const std::pair<std::shared_ptr<ov::Node>, ov::Tensor>& item) { auto itr = std::find_if(inputs.begin(),
return item.first->get_friendly_name() == "Param_1"; inputs.end(),
}); [](const std::pair<std::shared_ptr<ov::Node>, ov::Tensor>& item) {
return item.first->get_friendly_name() == "Param_1";
});
ASSERT_NE(itr, inputs.end()); ASSERT_NE(itr, inputs.end());
itr->second = expectedOutputs.front(); itr->second = expectedOutputs.front();
} }
@ -123,9 +126,10 @@ TEST_F(InputOutputTensorReuse, smoke_Input_Output_Bind_Once_Empty_Tensor) {
auto outputTensor = inferRequest.get_output_tensor(0); auto outputTensor = inferRequest.get_output_tensor(0);
inputShapes.back() = outputTensor.get_shape(); inputShapes.back() = outputTensor.get_shape();
auto itr = std::find_if(inputs.begin(), inputs.end(), [](const std::pair<std::shared_ptr<ov::Node>, ov::Tensor>& item) { auto itr =
return item.first->get_friendly_name() == "Param_1"; std::find_if(inputs.begin(), inputs.end(), [](const std::pair<std::shared_ptr<ov::Node>, ov::Tensor>& item) {
}); return item.first->get_friendly_name() == "Param_1";
});
ASSERT_NE(itr, inputs.end()); ASSERT_NE(itr, inputs.end());
itr->second = outputTensor; itr->second = outputTensor;
@ -139,12 +143,15 @@ TEST_F(InputOutputTensorReuse, smoke_Input_Output_Bind_Once_Empty_Tensor) {
inferRequest.infer(); inferRequest.infer();
compare(expectedOutputs, {outputTensor}); compare(expectedOutputs, {outputTensor});
auto itr = std::find_if(inputs.begin(), inputs.end(), [](const std::pair<std::shared_ptr<ov::Node>, ov::Tensor>& item) { auto itr = std::find_if(inputs.begin(),
return item.first->get_friendly_name() == "Param_1"; inputs.end(),
}); [](const std::pair<std::shared_ptr<ov::Node>, ov::Tensor>& item) {
return item.first->get_friendly_name() == "Param_1";
});
ASSERT_NE(itr, inputs.end()); ASSERT_NE(itr, inputs.end());
itr->second = expectedOutputs.front(); itr->second = expectedOutputs.front();
} }
} }
} // namespace SubgraphTestsDefinitions } // namespace test
} // namespace ov

View File

@ -2,16 +2,13 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// //
#include "ov_models/builders.hpp"
#include "test_utils/cpu_test_utils.hpp"
#include "functional_test_utils/ov_plugin_cache.hpp" #include "functional_test_utils/ov_plugin_cache.hpp"
#include "test_utils/cpu_test_utils.hpp"
using namespace ngraph;
using namespace ngraph::op;
using namespace InferenceEngine;
using namespace CPUTestUtils; using namespace CPUTestUtils;
namespace SubgraphTestsDefinitions { namespace ov {
namespace test {
struct InputTensorROIParamType { struct InputTensorROIParamType {
ov::PartialShape shape; ov::PartialShape shape;
@ -30,24 +27,23 @@ public:
} }
protected: protected:
std::shared_ptr<ov::Model> std::shared_ptr<ov::Model> create_test_function(element::Type type,
create_test_function(element::Type type, const ov::PartialShape& shape,
const ov::PartialShape & shape, const ov::Layout& layout) {
const ov::Layout & layout) {
ResultVector res; ResultVector res;
ParameterVector params; ParameterVector params;
auto param = std::make_shared<opset8::Parameter>(type, shape); auto param = std::make_shared<ov::op::v0::Parameter>(type, shape);
param->set_friendly_name("input_0"); param->set_friendly_name("input_0");
param->get_output_tensor(0).set_names({"tensor_input_0"}); param->get_output_tensor(0).set_names({"tensor_input_0"});
param->set_layout(layout); param->set_layout(layout);
auto constant = opset8::Constant::create(type, {1}, {1}); auto constant = ov::op::v0::Constant::create(type, {1}, {1});
auto add = std::make_shared<opset8::Add>(param, constant); auto add = std::make_shared<ov::op::v1::Add>(param, constant);
add->set_friendly_name("Add"); add->set_friendly_name("Add");
auto result = std::make_shared<opset8::Result>(add); auto result = std::make_shared<ov::op::v0::Result>(add);
result->set_friendly_name("result_0"); result->set_friendly_name("result_0");
result->get_output_tensor(0).set_names({"tensor_output_0"}); result->get_output_tensor(0).set_names({"tensor_output_0"});
@ -57,7 +53,7 @@ protected:
return std::make_shared<ov::Model>(res, params); return std::make_shared<ov::Model>(res, params);
} }
template<typename T> template <typename T>
void Run() { void Run() {
std::shared_ptr<ov::Core> ie = ov::test::utils::PluginCache::get().core(); std::shared_ptr<ov::Core> ie = ov::test::utils::PluginCache::get().core();
@ -70,14 +66,14 @@ protected:
ov::InferRequest req = compiled_model.create_infer_request(); ov::InferRequest req = compiled_model.create_infer_request();
// Create input tensor // Create input tensor
auto input_shape = Shape{ 1, 4, 4, 4 }; auto input_shape = Shape{1, 4, 4, 4};
auto input_shape_size = ov::shape_size(input_shape); auto input_shape_size = ov::shape_size(input_shape);
std::vector<T> data(input_shape_size); std::vector<T> data(input_shape_size);
std::iota(data.begin(), data.end(), 0); std::iota(data.begin(), data.end(), 0);
auto input_tensor = ov::Tensor(GetParam().type, input_shape, &data[0]); auto input_tensor = ov::Tensor(GetParam().type, input_shape, &data[0]);
// Set ROI // Set ROI
auto roi = ov::Tensor(input_tensor, { 0, 1, 1, 1 }, { 1, 3, 3, 3 }); auto roi = ov::Tensor(input_tensor, {0, 1, 1, 1}, {1, 3, 3, 3});
req.set_tensor("tensor_input_0", roi); req.set_tensor("tensor_input_0", roi);
// Infer // Infer
@ -99,24 +95,24 @@ protected:
TEST_P(InputTensorROI, SetInputTensorROI) { TEST_P(InputTensorROI, SetInputTensorROI) {
switch (GetParam().type) { switch (GetParam().type) {
case ov::element::Type_t::f32: { case ov::element::Type_t::f32: {
Run<float>(); Run<float>();
break; break;
} }
case ov::element::Type_t::u8: { case ov::element::Type_t::u8: {
Run<uint8_t>(); Run<uint8_t>();
break; break;
} }
default: default:
break; break;
} }
} }
static InputTensorROI::ParamType InputTensorROIParams[] = { static InputTensorROI::ParamType InputTensorROIParams[] = {
{ ov::PartialShape{ 1, 2, 2, 2 }, element::f32, "NCHW" }, {ov::PartialShape{1, 2, 2, 2}, element::f32, "NCHW"},
{ ov::PartialShape{ 1, 2, ov::Dimension::dynamic(), ov::Dimension::dynamic() }, element::f32, "NCHW" }, {ov::PartialShape{1, 2, ov::Dimension::dynamic(), ov::Dimension::dynamic()}, element::f32, "NCHW"},
{ ov::PartialShape{ 1, 2, 2, 2 }, element::u8, "NCHW" }, {ov::PartialShape{1, 2, 2, 2}, element::u8, "NCHW"},
{ ov::PartialShape{ 1, 2, ov::Dimension::dynamic(), ov::Dimension::dynamic() }, element::u8, "NCHW" }, {ov::PartialShape{1, 2, ov::Dimension::dynamic(), ov::Dimension::dynamic()}, element::u8, "NCHW"},
}; };
INSTANTIATE_TEST_SUITE_P(smoke_InputTensorROI, INSTANTIATE_TEST_SUITE_P(smoke_InputTensorROI,
@ -124,4 +120,5 @@ INSTANTIATE_TEST_SUITE_P(smoke_InputTensorROI,
::testing::ValuesIn(InputTensorROIParams), ::testing::ValuesIn(InputTensorROIParams),
InputTensorROI::getTestCaseName); InputTensorROI::getTestCaseName);
} // namespace SubgraphTestsDefinitions } // namespace test
} // namespace ov

View File

@ -2,49 +2,37 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// //
#include "shared_test_classes/base/ov_subgraph.hpp"
#include "ie_precision.hpp"
#include "test_utils/fusing_test_utils.hpp"
#include <openvino/opsets/opset1.hpp>
#include <openvino/opsets/opset8.hpp>
#include <common_test_utils/ov_tensor_utils.hpp>
#include <string>
#include <tuple>
#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/common_utils.hpp"
#include <common_test_utils/ov_tensor_utils.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"
#include "test_utils/cpu_test_utils.hpp" #include "test_utils/cpu_test_utils.hpp"
using namespace CPUTestUtils; using namespace CPUTestUtils;
using namespace ov::test; using namespace ov::test;
using namespace ov;
static std::shared_ptr<opset8::FakeQuantize> createFQ(const std::shared_ptr<ov::Node>& input) { static std::shared_ptr<ov::op::v0::FakeQuantize> createFQ(const std::shared_ptr<ov::Node>& input) {
auto input_low = std::make_shared<opset1::Constant>(element::f32, ov::Shape{1}, std::vector<float>{0}); auto input_low = std::make_shared<ov::op::v0::Constant>(ov::element::f32, ov::Shape{1}, std::vector<float>{0});
auto input_high = std::make_shared<opset1::Constant>(element::f32, ov::Shape{1}, std::vector<float>{49.4914f}); auto input_high = std::make_shared<ov::op::v0::Constant>(ov::element::f32, ov::Shape{1}, std::vector<float>{49.4914f});
auto output_low = std::make_shared<opset1::Constant>(element::f32, ov::Shape{1}, std::vector<float>{0}); auto output_low = std::make_shared<ov::op::v0::Constant>(ov::element::f32, ov::Shape{1}, std::vector<float>{0});
auto output_high = std::make_shared<opset1::Constant>(element::f32, ov::Shape{1}, std::vector<float>{49.4914f}); auto output_high = std::make_shared<ov::op::v0::Constant>(ov::element::f32, ov::Shape{1}, std::vector<float>{49.4914f});
return std::make_shared<opset8::FakeQuantize>(input, input_low, input_high, output_low, output_high, 256); return std::make_shared<ov::op::v0::FakeQuantize>(input, input_low, input_high, output_low, output_high, 256);
} }
static std::shared_ptr<ov::Model> makeInteraction(const ElementType inType, const ov::PartialShape& inputShape) { static std::shared_ptr<ov::Model> makeInteraction(const ElementType inType, const ov::PartialShape& inputShape) {
bool intraFQ = inType == ElementType::i8; bool intraFQ = inType == ElementType::i8;
auto paramType = intraFQ ? ElementType::f32 : inType; auto paramType = intraFQ ? ElementType::f32 : inType;
std::shared_ptr<ov::opset1::Parameter> input = std::make_shared<ov::opset1::Parameter>(paramType, inputShape); std::shared_ptr<ov::op::v0::Parameter> input = std::make_shared<ov::op::v0::Parameter>(paramType, inputShape);
std::shared_ptr<ov::Node> dense_feature = nullptr; std::shared_ptr<ov::Node> dense_feature = nullptr;
if (intraFQ) { if (intraFQ) {
dense_feature = createFQ(input); dense_feature = createFQ(input);
} else { } else {
dense_feature = input; dense_feature = input;
} }
NodeVector features{dense_feature}; ov::NodeVector features{dense_feature};
ParameterVector inputsParams{input}; ov::ParameterVector inputsParams{input};
const size_t sparse_feature_num = 26; const size_t sparse_feature_num = 26;
for (size_t i = 0; i < sparse_feature_num; i++) { for (size_t i = 0; i < sparse_feature_num; i++) {
auto sparse_input = std::make_shared<ov::opset1::Parameter>(paramType, inputShape); auto sparse_input = std::make_shared<ov::op::v0::Parameter>(paramType, inputShape);
std::shared_ptr<ov::Node> sparse_feat = nullptr; std::shared_ptr<ov::Node> sparse_feat = nullptr;
if (intraFQ) { if (intraFQ) {
sparse_feat = createFQ(sparse_input); sparse_feat = createFQ(sparse_input);
@ -55,23 +43,24 @@ static std::shared_ptr<ov::Model> makeInteraction(const ElementType inType, cons
inputsParams.push_back(sparse_input); inputsParams.push_back(sparse_input);
} }
auto shapeof = std::make_shared<ov::op::v3::ShapeOf>(dense_feature); auto shapeof = std::make_shared<ov::op::v3::ShapeOf>(dense_feature);
auto gather_batch_indices = std::make_shared<opset1::Constant>(element::i32, ov::Shape{1}, std::vector<int32_t>{0}); auto gather_batch_indices = std::make_shared<ov::op::v0::Constant>(ov::element::i32, ov::Shape{1}, std::vector<int32_t>{0});
auto gather_batch_axis = std::make_shared<opset1::Constant>(element::i32, ov::Shape{}, 0); auto gather_batch_axis = std::make_shared<ov::op::v0::Constant>(ov::element::i32, ov::Shape{}, 0);
auto gather_batch = std::make_shared<opset8::Gather>(shapeof, gather_batch_indices, gather_batch_axis); auto gather_batch = std::make_shared<ov::op::v8::Gather>(shapeof, gather_batch_indices, gather_batch_axis);
auto gather_feature_indices = std::make_shared<opset1::Constant>(element::i32, ov::Shape{1}, std::vector<int32_t>{1}); auto gather_feature_indices =
auto gather_feature_axis = std::make_shared<opset1::Constant>(element::i32, ov::Shape{1}, 0); std::make_shared<ov::op::v0::Constant>(ov::element::i32, ov::Shape{1}, std::vector<int32_t>{1});
auto gather_feature = std::make_shared<opset8::Gather>(shapeof, gather_feature_indices, gather_feature_axis); auto gather_feature_axis = std::make_shared<ov::op::v0::Constant>(ov::element::i32, ov::Shape{1}, 0);
auto gather_feature = std::make_shared<ov::op::v8::Gather>(shapeof, gather_feature_indices, gather_feature_axis);
auto reshape_dim2 = std::make_shared<opset1::Constant>(element::i64, ov::Shape{1}, std::vector<int64_t>{-1}); auto reshape_dim2 = std::make_shared<ov::op::v0::Constant>(ov::element::i64, ov::Shape{1}, std::vector<int64_t>{-1});
auto reshape_shape = std::make_shared<opset1::Concat>(NodeVector{gather_batch, reshape_dim2, gather_feature}, 0); auto reshape_shape = std::make_shared<ov::op::v0::Concat>(ov::NodeVector{gather_batch, reshape_dim2, gather_feature}, 0);
auto concat1 = std::make_shared<opset1::Concat>(features, 1); auto concat1 = std::make_shared<ov::op::v0::Concat>(features, 1);
auto reshape = std::make_shared<opset1::Reshape>(concat1, reshape_shape, true); auto reshape = std::make_shared<ov::op::v1::Reshape>(concat1, reshape_shape, true);
std::vector<int32_t> transpose1_value = {0, 2, 1}; std::vector<int32_t> transpose1_value = {0, 2, 1};
auto transpose1_shape = std::make_shared<opset1::Constant>(element::i32, ov::Shape{3}, transpose1_value); auto transpose1_shape = std::make_shared<ov::op::v0::Constant>(ov::element::i32, ov::Shape{3}, transpose1_value);
auto transpose1 = std::make_shared<opset1::Transpose>(reshape, transpose1_shape); auto transpose1 = std::make_shared<ov::op::v1::Transpose>(reshape, transpose1_shape);
auto matmul = std::make_shared<opset1::MatMul>(reshape, transpose1); auto matmul = std::make_shared<ov::op::v0::MatMul>(reshape, transpose1);
std::shared_ptr<ov::Node> inter = nullptr; std::shared_ptr<ov::Node> inter = nullptr;
if (intraFQ) { if (intraFQ) {
inter = createFQ(matmul); inter = createFQ(matmul);
@ -79,42 +68,42 @@ static std::shared_ptr<ov::Model> makeInteraction(const ElementType inType, cons
inter = matmul; inter = matmul;
} }
std::vector<int32_t> transpose2_value = {1, 2, 0}; std::vector<int32_t> transpose2_value = {1, 2, 0};
auto transpose2_shape = std::make_shared<opset1::Constant>(element::i32, ov::Shape{3}, transpose2_value); auto transpose2_shape = std::make_shared<ov::op::v0::Constant>(ov::element::i32, ov::Shape{3}, transpose2_value);
auto transpose2 = std::make_shared<opset1::Transpose>(inter, transpose2_shape); auto transpose2 = std::make_shared<ov::op::v1::Transpose>(inter, transpose2_shape);
std::vector<int32_t> reshape2_value = {729, -1}; std::vector<int32_t> reshape2_value = {729, -1};
auto reshape2_shape = std::make_shared<opset1::Constant>(element::i32, ov::Shape{2}, reshape2_value); auto reshape2_shape = std::make_shared<ov::op::v0::Constant>(ov::element::i32, ov::Shape{2}, reshape2_value);
auto reshape2 = std::make_shared<opset1::Reshape>(transpose2, reshape2_shape, true); auto reshape2 = std::make_shared<ov::op::v1::Reshape>(transpose2, reshape2_shape, true);
std::vector<int32_t> gather_indices_value; std::vector<int32_t> gather_indices_value;
for (int i = 1; i < 27; i++) { for (int i = 1; i < 27; i++) {
for (int j = 0; j < i; j ++) { for (int j = 0; j < i; j++) {
gather_indices_value.push_back(i * 27 + j); gather_indices_value.push_back(i * 27 + j);
} }
} }
auto gather_indices = std::make_shared<opset1::Constant>(element::i32, ov::Shape{351}, gather_indices_value); auto gather_indices = std::make_shared<ov::op::v0::Constant>(ov::element::i32, ov::Shape{351}, gather_indices_value);
auto gather_axis = std::make_shared<opset1::Constant>(element::i32, ov::Shape{}, 0); auto gather_axis = std::make_shared<ov::op::v0::Constant>(ov::element::i32, ov::Shape{}, 0);
auto gather = std::make_shared<opset8::Gather>(reshape2, gather_indices, gather_axis); auto gather = std::make_shared<ov::op::v8::Gather>(reshape2, gather_indices, gather_axis);
auto reshape3_dim1 = std::make_shared<opset1::Constant>(element::i64, ov::Shape{1}, std::vector<int64_t>{-1}); auto reshape3_dim1 = std::make_shared<ov::op::v0::Constant>(ov::element::i64, ov::Shape{1}, std::vector<int64_t>{-1});
auto reshape3_shape = std::make_shared<opset1::Concat>(NodeVector{reshape3_dim1, gather_batch}, 0); auto reshape3_shape = std::make_shared<ov::op::v0::Concat>(ov::NodeVector{reshape3_dim1, gather_batch}, 0);
auto reshape3 = std::make_shared<opset1::Reshape>(gather, reshape3_shape, true); auto reshape3 = std::make_shared<ov::op::v1::Reshape>(gather, reshape3_shape, true);
std::vector<int32_t> transpose3_value = {1, 0}; std::vector<int32_t> transpose3_value = {1, 0};
auto transpose3_shape = std::make_shared<opset1::Constant>(element::i32, ov::Shape{2}, transpose3_value); auto transpose3_shape = std::make_shared<ov::op::v0::Constant>(ov::element::i32, ov::Shape{2}, transpose3_value);
auto transpose3 = std::make_shared<opset1::Transpose>(reshape3, transpose3_shape); auto transpose3 = std::make_shared<ov::op::v1::Transpose>(reshape3, transpose3_shape);
std::vector<int32_t> reshape4_value = {-1, 351}; std::vector<int32_t> reshape4_value = {-1, 351};
auto reshape4_shape = std::make_shared<opset1::Constant>(element::i32, ov::Shape{2}, reshape4_value); auto reshape4_shape = std::make_shared<ov::op::v0::Constant>(ov::element::i32, ov::Shape{2}, reshape4_value);
auto reshape4 = std::make_shared<opset1::Reshape>(transpose3, reshape4_shape, true); auto reshape4 = std::make_shared<ov::op::v1::Reshape>(transpose3, reshape4_shape, true);
auto concat2 = std::make_shared<opset1::Concat>(NodeVector{dense_feature, reshape4}, 1); auto concat2 = std::make_shared<ov::op::v0::Concat>(ov::NodeVector{dense_feature, reshape4}, 1);
std::shared_ptr<ov::Model> model; std::shared_ptr<ov::Model> model;
if (intraFQ) { if (intraFQ) {
auto add_const = std::make_shared<opset1::Constant>(element::i8, ov::Shape{355, 1}, 3); auto add_const = std::make_shared<ov::op::v0::Constant>(ov::element::i8, ov::Shape{355, 1}, 3);
auto convert = std::make_shared<opset8::Convert>(add_const, element::f32); auto convert = std::make_shared<ov::op::v0::Convert>(add_const, ov::element::f32);
auto zp_const = std::make_shared<opset1::Constant>(element::f32, ov::Shape{1}, 0); auto zp_const = std::make_shared<ov::op::v0::Constant>(ov::element::f32, ov::Shape{1}, 0);
auto scale_const = std::make_shared<opset1::Constant>(element::f32, ov::Shape{1}, 1); auto scale_const = std::make_shared<ov::op::v0::Constant>(ov::element::f32, ov::Shape{1}, 1);
auto sub = std::make_shared<opset1::Subtract>(convert, zp_const); auto sub = std::make_shared<ov::op::v1::Subtract>(convert, zp_const);
auto multipy = std::make_shared<opset1::Multiply>(sub, scale_const); auto multipy = std::make_shared<ov::op::v1::Multiply>(sub, scale_const);
const auto matmul = std::make_shared<ngraph::opset1::MatMul>(concat2, multipy); const auto matmul = std::make_shared<ov::op::v0::MatMul>(concat2, multipy);
model = std::make_shared<ov::Model>(matmul, inputsParams, "interaction"); model = std::make_shared<ov::Model>(matmul, inputsParams, "interaction");
} else { } else {
model = std::make_shared<ov::Model>(concat2, inputsParams, "interaction"); model = std::make_shared<ov::Model>(concat2, inputsParams, "interaction");
@ -122,7 +111,6 @@ static std::shared_ptr<ov::Model> makeInteraction(const ElementType inType, cons
return model; return model;
} }
namespace CPULayerTestsDefinitions {
using InteractionLayerCPUTestParams = std::tuple<ElementType, InputShape>; using InteractionLayerCPUTestParams = std::tuple<ElementType, InputShape>;
class IntertactionCPUTest : public testing::WithParamInterface<InteractionLayerCPUTestParams>, class IntertactionCPUTest : public testing::WithParamInterface<InteractionLayerCPUTestParams>,
@ -146,7 +134,11 @@ public:
const auto& funcInput = funcInputs[i]; const auto& funcInput = funcInputs[i];
ov::Tensor tensor; ov::Tensor tensor;
tensor = ov::test::utils::create_and_fill_tensor(funcInput.get_element_type(), targetInputStaticShapes[i], 15, 0, 32768); tensor = ov::test::utils::create_and_fill_tensor(funcInput.get_element_type(),
targetInputStaticShapes[i],
15,
0,
32768);
inputs.insert({funcInput.get_node_shared_ptr(), tensor}); inputs.insert({funcInput.get_node_shared_ptr(), tensor});
} }
@ -157,7 +149,7 @@ protected:
ElementType inType; ElementType inType;
InputShape inputShape; InputShape inputShape;
std::tie(inType, inputShape) = this->GetParam(); std::tie(inType, inputShape) = this->GetParam();
bool with_bf16 = InferenceEngine::with_cpu_x86_bfloat16(); bool with_bf16 = ov::with_cpu_x86_bfloat16();
if (with_bf16 && (inType == ov::element::bf16 || inType == ov::element::i32)) { if (with_bf16 && (inType == ov::element::bf16 || inType == ov::element::i32)) {
selectedType = makeSelectedTypeStr("ref_any", ov::element::bf16); selectedType = makeSelectedTypeStr("ref_any", ov::element::bf16);
} else { } else {
@ -166,7 +158,7 @@ protected:
targetDevice = ov::test::utils::DEVICE_CPU; targetDevice = ov::test::utils::DEVICE_CPU;
inputDynamicShapes.push_back(inputShape.first); inputDynamicShapes.push_back(inputShape.first);
const auto& targetInput = inputShape.second; const auto& targetInput = inputShape.second;
for (size_t i = 0; i < targetInput.size(); i++) { for (size_t i = 0; i < targetInput.size(); i++) {
targetStaticShapes.push_back(std::vector<ov::Shape>(27, targetInput[i])); targetStaticShapes.push_back(std::vector<ov::Shape>(27, targetInput[i]));
} }
@ -180,15 +172,10 @@ TEST_P(IntertactionCPUTest, CompareWithRefs) {
} }
namespace { namespace {
const std::vector<ElementType> inPrecisions = { const std::vector<ElementType> inPrecisions = {ElementType::f32, ElementType::bf16, ElementType::i32, ElementType::i8};
ElementType::f32,
ElementType::bf16,
ElementType::i32,
ElementType::i8
};
// the model has 27 inputs with same shape // the model has 27 inputs with same shape
const std::vector<InputShape> input_shapes = { const std::vector<InputShape> input_shapes = {
// temporarily disable dynamic shape for performance issue // temporarily disable dynamic shape for performance issue
// // dynamic batch // // dynamic batch
// { // {
// {-1, 4}, // {-1, 4},
@ -200,22 +187,11 @@ const std::vector<InputShape> input_shapes = {
// {{3, 4}, {5, 6}, {7, 8}} // {{3, 4}, {5, 6}, {7, 8}}
// }, // },
// static shape // static shape
{ {{6, 4}, {{6, 4}}},
{6, 4}, {{3, 4}, {{3, 4}}}};
{{6, 4}}
},
{
{3, 4},
{{3, 4}}
}
};
INSTANTIATE_TEST_SUITE_P(smoke_Interaction, IntertactionCPUTest, INSTANTIATE_TEST_SUITE_P(smoke_Interaction,
::testing::Combine( IntertactionCPUTest,
::testing::ValuesIn(inPrecisions), ::testing::Combine(::testing::ValuesIn(inPrecisions), ::testing::ValuesIn(input_shapes)),
::testing::ValuesIn(input_shapes)), IntertactionCPUTest::getTestCaseName);
IntertactionCPUTest::getTestCaseName); } // namespace
} // namespace
} // namespace CPULayerTestsDefinitions

View File

@ -2,14 +2,15 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// //
#include "common_test_utils/node_builders/convolution.hpp"
#include "openvino/openvino.hpp" #include "openvino/openvino.hpp"
#include "test_utils/cpu_test_utils.hpp"
#include "ov_models/builders.hpp"
#include "test_utils/convolution_params.hpp" #include "test_utils/convolution_params.hpp"
#include "test_utils/cpu_test_utils.hpp"
using namespace CPUTestUtils; using namespace CPUTestUtils;
namespace SubgraphTestsDefinitions { namespace ov {
namespace test {
class EdgeWithSameNameInTwoModels : public ::testing::Test, public CPUTestsBase {}; class EdgeWithSameNameInTwoModels : public ::testing::Test, public CPUTestsBase {};
@ -24,36 +25,52 @@ TEST_F(EdgeWithSameNameInTwoModels, smoke_CompareWithRef) {
const std::vector<ptrdiff_t> padsBegin{0, 0}; const std::vector<ptrdiff_t> padsBegin{0, 0};
const std::vector<ptrdiff_t> padsEnd{0, 0}; const std::vector<ptrdiff_t> padsEnd{0, 0};
const std::vector<size_t> dilations{1, 1}; const std::vector<size_t> dilations{1, 1};
const ngraph::op::PadType autoPad(ngraph::op::PadType::EXPLICIT); const ov::op::PadType autoPad(ov::op::PadType::EXPLICIT);
if (InferenceEngine::with_cpu_x86_avx512f()) { if (ov::with_cpu_x86_avx512f()) {
std::tie(inFmts, outFmts, priority, selectedType) = conv_avx512_2D; std::tie(inFmts, outFmts, priority, selectedType) = conv_avx512_2D;
} else if (InferenceEngine::with_cpu_x86_avx2()) { } else if (ov::with_cpu_x86_avx2()) {
std::tie(inFmts, outFmts, priority, selectedType) = conv_avx2_2D; std::tie(inFmts, outFmts, priority, selectedType) = conv_avx2_2D;
} else if (InferenceEngine::with_cpu_x86_sse42()) { } else if (ov::with_cpu_x86_sse42()) {
std::tie(inFmts, outFmts, priority, selectedType) = conv_sse42_2D; std::tie(inFmts, outFmts, priority, selectedType) = conv_sse42_2D;
} }
// first model // first model
const std::vector<std::vector<size_t>> shapes1{{1, 16, 720, 1280}}; const std::vector<ov::Shape> shapes1{{1, 16, 720, 1280}};
ov::ParameterVector params1; ov::ParameterVector params1;
for (auto&& shape : shapes1) { for (auto&& shape : shapes1) {
params1.push_back(std::make_shared<ov::op::v0::Parameter>(type, ov::Shape(shape))); params1.push_back(std::make_shared<ov::op::v0::Parameter>(type, shape));
} }
const size_t convOutCh1 = 32; const size_t convOutCh1 = 32;
auto conv1 = ngraph::builder::makeConvolution(params1.front(), type, kernel, strides, padsBegin, padsEnd, dilations, autoPad, convOutCh1); auto conv1 = ov::test::utils::make_convolution(params1.front(),
type,
kernel,
strides,
padsBegin,
padsEnd,
dilations,
autoPad,
convOutCh1);
conv1->set_friendly_name(convName); conv1->set_friendly_name(convName);
conv1->get_input_node_shared_ptr(1)->set_friendly_name(weightName); conv1->get_input_node_shared_ptr(1)->set_friendly_name(weightName);
auto model1 = makeNgraphFunction(type, params1, conv1, "Model1"); auto model1 = makeNgraphFunction(type, params1, conv1, "Model1");
// second model // second model
const std::vector<std::vector<size_t>> shapes2{{1, 32, 24, 24}}; const std::vector<ov::Shape> shapes2{{1, 32, 24, 24}};
ov::ParameterVector params2; ov::ParameterVector params2;
for (auto&& shape : shapes2) { for (auto&& shape : shapes2) {
params2.push_back(std::make_shared<ov::op::v0::Parameter>(type, ov::Shape(shape))); params2.push_back(std::make_shared<ov::op::v0::Parameter>(type, shape));
} }
const size_t convOutCh2 = 16; const size_t convOutCh2 = 16;
auto conv2 = ngraph::builder::makeConvolution(params2.front(), type, kernel, strides, padsBegin, padsEnd, dilations, autoPad, convOutCh2); auto conv2 = ov::test::utils::make_convolution(params2.front(),
type,
kernel,
strides,
padsBegin,
padsEnd,
dilations,
autoPad,
convOutCh2);
conv2->set_friendly_name(convName); conv2->set_friendly_name(convName);
conv2->get_input_node_shared_ptr(1)->set_friendly_name(weightName); conv2->get_input_node_shared_ptr(1)->set_friendly_name(weightName);
auto model2 = makeNgraphFunction(type, params2, conv2, "Model2"); auto model2 = makeNgraphFunction(type, params2, conv2, "Model2");
@ -78,4 +95,5 @@ TEST_F(EdgeWithSameNameInTwoModels, smoke_CompareWithRef) {
inferReq2.infer(); inferReq2.infer();
} }
} // namespace SubgraphTestsDefinitions } // namespace test
} // namespace ov

View File

@ -2,49 +2,41 @@
// SPDX-License-Identifier: Apache-2.0 // 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/common_utils.hpp"
#include <common_test_utils/ov_tensor_utils.hpp> #include "common_test_utils/ov_tensor_utils.hpp"
#include "functional_test_utils/skip_tests_config.hpp" #include "functional_test_utils/skip_tests_config.hpp"
#include "ov_models/builders.hpp"
#include "shared_test_classes/base/ov_subgraph.hpp"
#include "test_utils/cpu_test_utils.hpp" #include "test_utils/cpu_test_utils.hpp"
#include "cpp_interfaces/interface/ie_internal_plugin_config.hpp"
using namespace CPUTestUtils; using namespace CPUTestUtils;
using namespace ov::test; using namespace ov::test;
using namespace ngraph::helpers;
namespace CPUSubgraphTestsDefinitions {
using ExpectedNodes = std::vector<std::pair<std::string, size_t>>; using ExpectedNodes = std::vector<std::pair<std::string, size_t>>;
typedef std::tuple< typedef std::tuple<std::vector<InputShape>, // Input shapes
std::vector<InputShape>, // Input shapes std::vector<ElementType>, // Input precisions
std::vector<ElementType>, // Input precisions std::vector<ElementType>, // MatMul input #0 precisions
std::vector<ElementType>, // MatMul input #0 precisions size_t, // pattern type #
size_t, // pattern type # ExpectedNodes, // Expected node -> count
ExpectedNodes, // Expected node -> count std::string // Device name
std::string // Device name >
> MHATuple; MHATuple;
static std::shared_ptr<ov::Model> initMHASubgraph0(std::vector<ov::PartialShape>& inputDynamicShapes, std::vector<ElementType>& inputPrecisions) { static std::shared_ptr<ov::Model> initMHASubgraph0(std::vector<ov::PartialShape>& inputDynamicShapes,
ngraph::ParameterVector ngraphParam; std::vector<ElementType>& inputPrecisions) {
ov::ParameterVector ngraphParam;
auto transpose0Param = std::make_shared<ngraph::opset1::Parameter>(inputPrecisions[0], inputDynamicShapes[0]); auto transpose0Param = std::make_shared<ov::op::v0::Parameter>(inputPrecisions[0], inputDynamicShapes[0]);
ngraphParam.push_back(transpose0Param); ngraphParam.push_back(transpose0Param);
auto transpose1Param = std::make_shared<ngraph::opset1::Parameter>(inputPrecisions[1], inputDynamicShapes[1]); auto transpose1Param = std::make_shared<ov::op::v0::Parameter>(inputPrecisions[1], inputDynamicShapes[1]);
ngraphParam.push_back(transpose1Param); ngraphParam.push_back(transpose1Param);
auto addParam = std::make_shared<ngraph::opset1::Parameter>(inputPrecisions[2], inputDynamicShapes[2]); auto addParam = std::make_shared<ov::op::v0::Parameter>(inputPrecisions[2], inputDynamicShapes[2]);
ngraphParam.push_back(addParam); ngraphParam.push_back(addParam);
auto transpose2Param = std::make_shared<ngraph::opset1::Parameter>(inputPrecisions[3], inputDynamicShapes[3]); auto transpose2Param = std::make_shared<ov::op::v0::Parameter>(inputPrecisions[3], inputDynamicShapes[3]);
ngraphParam.push_back(transpose2Param); ngraphParam.push_back(transpose2Param);
std::vector<ov::Shape> constantShapes; std::vector<ov::Shape> constantShapes;
@ -62,12 +54,13 @@ static std::shared_ptr<ov::Model> initMHASubgraph0(std::vector<ov::PartialShape>
std::vector<int64_t> transpose1ConstData = {0, 2, 3, 1}; std::vector<int64_t> transpose1ConstData = {0, 2, 3, 1};
auto transpose1Const = ngraph::builder::makeConstant(ElementType::i64, constantShapes[1], transpose1ConstData); auto transpose1Const = ngraph::builder::makeConstant(ElementType::i64, constantShapes[1], transpose1ConstData);
std::vector<float> mulConstData(ngraph::shape_size(constantShapes[2])); std::vector<float> mulConstData(ov::shape_size(constantShapes[2]));
auto mulConst = ngraph::builder::makeConstant(inputPrecisions[0], constantShapes[2], mulConstData, true); auto mulConst = ngraph::builder::makeConstant(inputPrecisions[0], constantShapes[2], mulConstData, true);
std::vector<int64_t> reshape0ConstData = {static_cast<int64_t>(inputDynamicShapes[0].get_shape()[0] * std::vector<int64_t> reshape0ConstData = {
inputDynamicShapes[0].get_shape()[1] * inputDynamicShapes[0].get_shape()[2]), static_cast<int64_t>(inputDynamicShapes[0].get_shape()[0] * inputDynamicShapes[0].get_shape()[1] *
-1}; inputDynamicShapes[0].get_shape()[2]),
-1};
auto reshape0Const = ngraph::builder::makeConstant(ElementType::i64, constantShapes[3], reshape0ConstData); auto reshape0Const = ngraph::builder::makeConstant(ElementType::i64, constantShapes[3], reshape0ConstData);
std::vector<int64_t> reshape1ConstData = {static_cast<int64_t>(inputDynamicShapes[0].get_shape()[0]), std::vector<int64_t> reshape1ConstData = {static_cast<int64_t>(inputDynamicShapes[0].get_shape()[0]),
@ -86,33 +79,34 @@ static std::shared_ptr<ov::Model> initMHASubgraph0(std::vector<ov::PartialShape>
float transB = false; float transB = false;
const auto transpose0 = std::make_shared<ov::op::v1::Transpose>(transpose0Param, transpose0Const); const auto transpose0 = std::make_shared<ov::op::v1::Transpose>(transpose0Param, transpose0Const);
const auto transpose1 = std::make_shared<ov::op::v1::Transpose>(transpose1Param, transpose1Const); const auto transpose1 = std::make_shared<ov::op::v1::Transpose>(transpose1Param, transpose1Const);
const auto mul = std::make_shared<ngraph::opset3::Multiply>(transpose1, mulConst); const auto mul = std::make_shared<ov::op::v1::Multiply>(transpose1, mulConst);
const auto matMul0 = std::make_shared<ngraph::opset3::MatMul>(transpose0, mul, transA, transB); const auto matMul0 = std::make_shared<ov::op::v0::MatMul>(transpose0, mul, transA, transB);
const auto add = std::make_shared<ngraph::opset3::Add>(matMul0, addParam); const auto add = std::make_shared<ov::op::v1::Add>(matMul0, addParam);
const auto reshape0 = std::make_shared<ngraph::opset1::Reshape>(add, reshape0Const, true); const auto reshape0 = std::make_shared<ov::op::v1::Reshape>(add, reshape0Const, true);
const auto softMax = std::make_shared<ngraph::opset1::Softmax>(reshape0, 1); const auto softMax = std::make_shared<ov::op::v1::Softmax>(reshape0, 1);
const auto reshape1 = std::make_shared<ngraph::opset1::Reshape>(softMax, reshape1Const, true); const auto reshape1 = std::make_shared<ov::op::v1::Reshape>(softMax, reshape1Const, true);
const auto transpose2 = std::make_shared<ov::op::v1::Transpose>(transpose2Param, transpose2Const); const auto transpose2 = std::make_shared<ov::op::v1::Transpose>(transpose2Param, transpose2Const);
const auto matMul1 = std::make_shared<ngraph::opset3::MatMul>(reshape1, transpose2, transA, transB); const auto matMul1 = std::make_shared<ov::op::v0::MatMul>(reshape1, transpose2, transA, transB);
const auto transpose3 = std::make_shared<ov::op::v1::Transpose>(matMul1, transpose3Const); const auto transpose3 = std::make_shared<ov::op::v1::Transpose>(matMul1, transpose3Const);
ngraph::ResultVector results{std::make_shared<ngraph::opset1::Result>(transpose3)}; ov::ResultVector results{std::make_shared<ov::op::v0::Result>(transpose3)};
return std::make_shared<ngraph::Function>(results, ngraphParam, "mha"); return std::make_shared<ov::Model>(results, ngraphParam, "mha");
} }
static std::shared_ptr<ov::Model> initMHASubgraph1(std::vector<ov::PartialShape>& inputDynamicShapes, std::vector<ElementType>& inputPrecisions) { static std::shared_ptr<ov::Model> initMHASubgraph1(std::vector<ov::PartialShape>& inputDynamicShapes,
ngraph::ParameterVector ngraphParam; std::vector<ElementType>& inputPrecisions) {
ov::ParameterVector ngraphParam;
auto transpose0Param = std::make_shared<ngraph::opset1::Parameter>(inputPrecisions[0], inputDynamicShapes[0]); auto transpose0Param = std::make_shared<ov::op::v0::Parameter>(inputPrecisions[0], inputDynamicShapes[0]);
ngraphParam.push_back(transpose0Param); ngraphParam.push_back(transpose0Param);
auto transpose1Param = std::make_shared<ngraph::opset1::Parameter>(inputPrecisions[1], inputDynamicShapes[1]); auto transpose1Param = std::make_shared<ov::op::v0::Parameter>(inputPrecisions[1], inputDynamicShapes[1]);
ngraphParam.push_back(transpose1Param); ngraphParam.push_back(transpose1Param);
auto addParam = std::make_shared<ngraph::opset1::Parameter>(inputPrecisions[2], inputDynamicShapes[2]); auto addParam = std::make_shared<ov::op::v0::Parameter>(inputPrecisions[2], inputDynamicShapes[2]);
ngraphParam.push_back(addParam); ngraphParam.push_back(addParam);
auto transpose2Param = std::make_shared<ngraph::opset1::Parameter>(inputPrecisions[3], inputDynamicShapes[3]); auto transpose2Param = std::make_shared<ov::op::v0::Parameter>(inputPrecisions[3], inputDynamicShapes[3]);
ngraphParam.push_back(transpose2Param); ngraphParam.push_back(transpose2Param);
std::vector<ov::Shape> constantShapes; std::vector<ov::Shape> constantShapes;
@ -140,21 +134,20 @@ static std::shared_ptr<ov::Model> initMHASubgraph1(std::vector<ov::PartialShape>
float transB = false; float transB = false;
const auto transpose0 = std::make_shared<ov::op::v1::Transpose>(transpose0Param, transpose0Const); const auto transpose0 = std::make_shared<ov::op::v1::Transpose>(transpose0Param, transpose0Const);
const auto transpose1 = std::make_shared<ov::op::v1::Transpose>(transpose1Param, transpose1Const); const auto transpose1 = std::make_shared<ov::op::v1::Transpose>(transpose1Param, transpose1Const);
const auto matMul0 = std::make_shared<ngraph::opset3::MatMul>(transpose0, transpose1, transA, transB); const auto matMul0 = std::make_shared<ov::op::v0::MatMul>(transpose0, transpose1, transA, transB);
const auto add = std::make_shared<ngraph::opset3::Add>(matMul0, addParam); const auto add = std::make_shared<ov::op::v1::Add>(matMul0, addParam);
const auto softMax = std::make_shared<ngraph::opset1::Softmax>(add, 3); const auto softMax = std::make_shared<ov::op::v1::Softmax>(add, 3);
const auto transpose2 = std::make_shared<ov::op::v1::Transpose>(transpose2Param, transpose2Const); const auto transpose2 = std::make_shared<ov::op::v1::Transpose>(transpose2Param, transpose2Const);
const auto matMul1 = std::make_shared<ngraph::opset3::MatMul>(softMax, transpose2, transA, transB); const auto matMul1 = std::make_shared<ov::op::v0::MatMul>(softMax, transpose2, transA, transB);
const auto transpose3 = std::make_shared<ov::op::v1::Transpose>(matMul1, transpose3Const); const auto transpose3 = std::make_shared<ov::op::v1::Transpose>(matMul1, transpose3Const);
ngraph::ResultVector results{std::make_shared<ngraph::opset1::Result>(transpose3)}; ov::ResultVector results{std::make_shared<ov::op::v0::Result>(transpose3)};
return std::make_shared<ngraph::Function>(results, ngraphParam, "mha"); return std::make_shared<ov::Model>(results, ngraphParam, "mha");
} }
class MHATest : public testing::WithParamInterface<MHATuple>, class MHATest : public testing::WithParamInterface<MHATuple>, virtual public SubgraphBaseTest, public CPUTestsBase {
virtual public SubgraphBaseTest, public CPUTestsBase {
public: public:
static std::string getTestCaseName(const testing::TestParamInfo<MHATuple> &obj) { static std::string getTestCaseName(const testing::TestParamInfo<MHATuple>& obj) {
std::vector<InputShape> inputShapes; std::vector<InputShape> inputShapes;
std::vector<ElementType> inputPrecisions; std::vector<ElementType> inputPrecisions;
std::vector<ElementType> matMulIn0Precisions; std::vector<ElementType> matMulIn0Precisions;
@ -180,23 +173,31 @@ public:
results << "patternType=" << patternType; results << "patternType=" << patternType;
results << "expect="; results << "expect=";
for (const auto& node : expectedNodes) { for (const auto& node : expectedNodes) {
results << node.first << "[" << node.second << "]" << "_"; results << node.first << "[" << node.second << "]"
<< "_";
} }
results << "targetDevice=" << targetName; results << "targetDevice=" << targetName;
return results.str(); 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(); inputs.clear();
const auto& funcInputs = function->inputs(); const auto& funcInputs = function->inputs();
for (size_t i = 0; i < funcInputs.size(); ++i) { for (size_t i = 0; i < funcInputs.size(); ++i) {
const auto& funcInput = funcInputs[i]; const auto& funcInput = funcInputs[i];
ov::Tensor tensor; ov::Tensor tensor;
if (funcInput.get_element_type() == ov::element::bf16) if (funcInput.get_element_type() == ov::element::bf16)
tensor = ov::test::utils::create_and_fill_tensor(funcInput.get_element_type(), targetInputStaticShapes[i], 2, -1, 256); tensor = ov::test::utils::create_and_fill_tensor(funcInput.get_element_type(),
targetInputStaticShapes[i],
2,
-1,
256);
else else
tensor = ov::test::utils::create_and_fill_tensor_unique_sequence(funcInput.get_element_type(), targetInputStaticShapes[i], -1, 5); tensor = ov::test::utils::create_and_fill_tensor_unique_sequence(funcInput.get_element_type(),
targetInputStaticShapes[i],
-1,
5);
inputs.insert({funcInput.get_node_shared_ptr(), tensor}); inputs.insert({funcInput.get_node_shared_ptr(), tensor});
inputs.insert({funcInput.get_node_shared_ptr(), tensor}); inputs.insert({funcInput.get_node_shared_ptr(), tensor});
} }
@ -209,7 +210,8 @@ protected:
std::vector<InputShape> inputShapes; std::vector<InputShape> inputShapes;
std::vector<ElementType> inputPrecisions; std::vector<ElementType> inputPrecisions;
std::vector<ElementType> matMulIn0Precisions; std::vector<ElementType> matMulIn0Precisions;
std::tie(inputShapes, inputPrecisions, matMulIn0Precisions, patternType, expectedNodes, targetDevice) = this->GetParam(); std::tie(inputShapes, inputPrecisions, matMulIn0Precisions, patternType, expectedNodes, targetDevice) =
this->GetParam();
init_input_shapes(inputShapes); init_input_shapes(inputShapes);
@ -227,14 +229,14 @@ protected:
abs_threshold = 0.1f; abs_threshold = 0.1f;
rel_threshold = 10.f; rel_threshold = 10.f;
configuration.insert({{ InferenceEngine::PluginConfigParams::KEY_ENFORCE_BF16, InferenceEngine::PluginConfigParams::YES }}); configuration.insert({ov::hint::inference_precision(ov::element::bf16)});
} }
// Snippets MHA tokenization has limitations to avoid performance degradations. These limitations depend on target machine. // Snippets MHA tokenization has limitations to avoid performance degradations. These limitations depend on
// Just for testing, we disable these limitations to allow Snippets to tokenize pattern on all machines for validation. // target machine. Just for testing, we disable these limitations to allow Snippets to tokenize pattern on all
if (!configuration.count(InferenceEngine::PluginConfigInternalParams::KEY_SNIPPETS_MODE)) { // machines for validation.
configuration.insert({InferenceEngine::PluginConfigInternalParams::KEY_SNIPPETS_MODE, if (!configuration.count("SNIPPETS_MODE")) {
InferenceEngine::PluginConfigInternalParams::IGNORE_CALLBACK}); configuration.insert({"SNIPPETS_MODE", "IGNORE_CALLBACK"});
} }
} }
}; };
@ -245,12 +247,13 @@ TEST_P(MHATest, CompareWithRefs) {
std::vector<ElementType> matMulIn0Precisions; std::vector<ElementType> matMulIn0Precisions;
size_t patternType; size_t patternType;
ExpectedNodes expectedNodes; ExpectedNodes expectedNodes;
std::tie(inputShapes, inputPrecisions, matMulIn0Precisions, patternType, expectedNodes, targetDevice) = this->GetParam(); std::tie(inputShapes, inputPrecisions, matMulIn0Precisions, patternType, expectedNodes, targetDevice) =
this->GetParam();
if (inputPrecisions[0] == ElementType::bf16 && !InferenceEngine::with_cpu_x86_bfloat16()) if (inputPrecisions[0] == ElementType::bf16 && !ov::with_cpu_x86_bfloat16())
GTEST_SKIP(); GTEST_SKIP();
if (!InferenceEngine::with_cpu_x86_avx512_core()) if (!ov::with_cpu_x86_avx512_core())
GTEST_SKIP(); GTEST_SKIP();
run(); run();
@ -262,61 +265,66 @@ TEST_P(MHATest, CompareWithRefs) {
namespace { namespace {
std::vector<std::vector<ngraph::Shape>> inputShapes = { std::vector<std::vector<ov::Shape>> inputShapes = {
{{2, 8, 16, 64}, {2, 8, 16, 64}, {2, 1, 1, 8}, {2, 8, 16, 64}}, {{2, 8, 16, 64}, {2, 8, 16, 64}, {2, 1, 1, 8}, {2, 8, 16, 64}},
{{1, 384, 16, 64}, {1, 384, 16, 64}, {1, 1, 1, 384}, {1, 384, 16, 64}}, {{1, 384, 16, 64}, {1, 384, 16, 64}, {1, 1, 1, 384}, {1, 384, 16, 64}},
{{2, 64, 16, 80}, {2, 64, 16, 80}, {2, 1, 1, 64}, {2, 64, 16, 80}}, {{2, 64, 16, 80}, {2, 64, 16, 80}, {2, 1, 1, 64}, {2, 64, 16, 80}},
{{3, 96, 16, 64}, {3, 96, 16, 64}, {3, 1, 1, 96}, {3, 96, 16, 64}}, {{3, 96, 16, 64}, {3, 96, 16, 64}, {3, 1, 1, 96}, {3, 96, 16, 64}},
{{2, 192, 16, 160}, {2, 192, 16, 160}, {2, 1, 1, 192}, {2, 192, 16, 160}}, {{2, 192, 16, 160}, {2, 192, 16, 160}, {2, 1, 1, 192}, {2, 192, 16, 160}},
{{2, 4, 16, 8}, {2, 4, 16, 8}, {2, 1, 1, 4}, {2, 4, 16, 8}}, {{2, 4, 16, 8}, {2, 4, 16, 8}, {2, 1, 1, 4}, {2, 4, 16, 8}},
{{1, 204, 13, 212}, {1, 204, 13, 212}, {1, 1, 1, 204}, {1, 204, 13, 212}}, {{1, 204, 13, 212}, {1, 204, 13, 212}, {1, 1, 1, 204}, {1, 204, 13, 212}},
}; };
std::vector<std::vector<ElementType>> matMulIn0Precisions = { std::vector<std::vector<ElementType>> matMulIn0Precisions = {
{}, {},
}; };
std::vector<size_t> patternTypes = { std::vector<size_t> patternTypes = {0, 1};
0, 1
};
INSTANTIATE_TEST_SUITE_P(smoke_MHA, MHATest, INSTANTIATE_TEST_SUITE_P(smoke_MHA,
::testing::Combine( MHATest,
::testing::ValuesIn(static_shapes_to_test_representation(inputShapes)), ::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation(inputShapes)),
::testing::Values(std::vector<ElementType>{ ElementType::f32, ElementType::f32, ElementType::f32, ElementType::f32 }), ::testing::Values(std::vector<ElementType>{ElementType::f32,
::testing::ValuesIn(matMulIn0Precisions), ElementType::f32,
::testing::ValuesIn(patternTypes), ElementType::f32,
::testing::Values(ExpectedNodes{{"Subgraph", 1}}), ElementType::f32}),
::testing::Values(ov::test::utils::DEVICE_CPU)), ::testing::ValuesIn(matMulIn0Precisions),
MHATest::getTestCaseName); ::testing::ValuesIn(patternTypes),
::testing::Values(ExpectedNodes{{"Subgraph", 1}}),
INSTANTIATE_TEST_SUITE_P(smoke_MHA_BF16, MHATest, ::testing::Values(ov::test::utils::DEVICE_CPU)),
::testing::Combine(
::testing::ValuesIn(static_shapes_to_test_representation(inputShapes)),
::testing::Values(std::vector<ElementType>{ ElementType::bf16, ElementType::bf16, ElementType::bf16, ElementType::bf16 }),
::testing::ValuesIn(matMulIn0Precisions),
::testing::ValuesIn(patternTypes),
::testing::Values(ExpectedNodes{{"Subgraph", 1},
{"Transpose", 1}}), // Plugin disables tokenization of Transpose on output
::testing::Values(ov::test::utils::DEVICE_CPU)),
MHATest::getTestCaseName); MHATest::getTestCaseName);
} // namespace INSTANTIATE_TEST_SUITE_P(
smoke_MHA_BF16,
MHATest,
::testing::Combine(
::testing::ValuesIn(static_shapes_to_test_representation(inputShapes)),
::testing::Values(
std::vector<ElementType>{ElementType::bf16, ElementType::bf16, ElementType::bf16, ElementType::bf16}),
::testing::ValuesIn(matMulIn0Precisions),
::testing::ValuesIn(patternTypes),
::testing::Values(ExpectedNodes{{"Subgraph", 1},
{"Transpose", 1}}), // Plugin disables tokenization of Transpose on output
::testing::Values(ov::test::utils::DEVICE_CPU)),
MHATest::getTestCaseName);
static std::shared_ptr<ov::Model> initMHAQuantSubgraph0(std::vector<ov::PartialShape>& inputDynamicShapes, std::vector<ElementType>& inputPrecisions, } // namespace
static std::shared_ptr<ov::Model> initMHAQuantSubgraph0(std::vector<ov::PartialShape>& inputDynamicShapes,
std::vector<ElementType>& inputPrecisions,
std::vector<ElementType>& matMulIn0Precisions) { std::vector<ElementType>& matMulIn0Precisions) {
ngraph::ParameterVector ngraphParam; ov::ParameterVector ngraphParam;
auto transpose0Param = std::make_shared<ngraph::opset1::Parameter>(inputPrecisions[0], inputDynamicShapes[0]); auto transpose0Param = std::make_shared<ov::op::v0::Parameter>(inputPrecisions[0], inputDynamicShapes[0]);
ngraphParam.push_back(transpose0Param); ngraphParam.push_back(transpose0Param);
auto transpose1Param = std::make_shared<ngraph::opset1::Parameter>(inputPrecisions[1], inputDynamicShapes[1]); auto transpose1Param = std::make_shared<ov::op::v0::Parameter>(inputPrecisions[1], inputDynamicShapes[1]);
ngraphParam.push_back(transpose1Param); ngraphParam.push_back(transpose1Param);
auto addParam = std::make_shared<ngraph::opset1::Parameter>(inputPrecisions[2], inputDynamicShapes[2]); auto addParam = std::make_shared<ov::op::v0::Parameter>(inputPrecisions[2], inputDynamicShapes[2]);
ngraphParam.push_back(addParam); ngraphParam.push_back(addParam);
auto transpose2Param = std::make_shared<ngraph::opset1::Parameter>(inputPrecisions[3], inputDynamicShapes[3]); auto transpose2Param = std::make_shared<ov::op::v0::Parameter>(inputPrecisions[3], inputDynamicShapes[3]);
ngraphParam.push_back(transpose2Param); ngraphParam.push_back(transpose2Param);
std::vector<ov::Shape> constantShapes; std::vector<ov::Shape> constantShapes;
@ -333,9 +341,10 @@ static std::shared_ptr<ov::Model> initMHAQuantSubgraph0(std::vector<ov::PartialS
std::vector<int64_t> transpose1ConstData = {0, 2, 3, 1}; std::vector<int64_t> transpose1ConstData = {0, 2, 3, 1};
auto transpose1Const = ngraph::builder::makeConstant(ElementType::i64, constantShapes[1], transpose1ConstData); auto transpose1Const = ngraph::builder::makeConstant(ElementType::i64, constantShapes[1], transpose1ConstData);
std::vector<int64_t> reshape0ConstData = {static_cast<int64_t>(inputDynamicShapes[0].get_shape()[0] * std::vector<int64_t> reshape0ConstData = {
inputDynamicShapes[0].get_shape()[1] * inputDynamicShapes[0].get_shape()[2]), static_cast<int64_t>(inputDynamicShapes[0].get_shape()[0] * inputDynamicShapes[0].get_shape()[1] *
-1}; inputDynamicShapes[0].get_shape()[2]),
-1};
auto reshape0Const = ngraph::builder::makeConstant(ElementType::i64, constantShapes[2], reshape0ConstData); auto reshape0Const = ngraph::builder::makeConstant(ElementType::i64, constantShapes[2], reshape0ConstData);
std::vector<int64_t> reshape1ConstData = {static_cast<int64_t>(inputDynamicShapes[0].get_shape()[0]), std::vector<int64_t> reshape1ConstData = {static_cast<int64_t>(inputDynamicShapes[0].get_shape()[0]),
@ -355,52 +364,96 @@ static std::shared_ptr<ov::Model> initMHAQuantSubgraph0(std::vector<ov::PartialS
std::shared_ptr<ov::Node> fakeQuantize0; std::shared_ptr<ov::Node> fakeQuantize0;
if (matMulIn0Precisions[0] == ElementType::u8) if (matMulIn0Precisions[0] == ElementType::u8)
fakeQuantize0 = ngraph::builder::makeFakeQuantize(transpose0Param, inputPrecisions[0], 256, {}, {0.0f}, {2.55f}, {0.0f}, {2.55f}); fakeQuantize0 = ngraph::builder::makeFakeQuantize(transpose0Param,
inputPrecisions[0],
256,
{},
{0.0f},
{2.55f},
{0.0f},
{2.55f});
else else
fakeQuantize0 = ngraph::builder::makeFakeQuantize(transpose0Param, inputPrecisions[0], 256, {}, {-1.28f}, {1.27f}, {-1.28f}, {1.27f}); fakeQuantize0 = ngraph::builder::makeFakeQuantize(transpose0Param,
inputPrecisions[0],
256,
{},
{-1.28f},
{1.27f},
{-1.28f},
{1.27f});
const auto fakeQuantize1 = ngraph::builder::makeFakeQuantize(transpose1Param, inputPrecisions[1], 256, {}, {-1.28f}, {1.27f}, {-1.28f}, {1.27f}); const auto fakeQuantize1 = ngraph::builder::makeFakeQuantize(transpose1Param,
const auto fakeQuantize2 = ngraph::builder::makeFakeQuantize(transpose2Param, inputPrecisions[3], 256, {}, {-1.28f}, {1.27f}, {-1.28f}, {1.27f}); inputPrecisions[1],
256,
{},
{-1.28f},
{1.27f},
{-1.28f},
{1.27f});
const auto fakeQuantize2 = ngraph::builder::makeFakeQuantize(transpose2Param,
inputPrecisions[3],
256,
{},
{-1.28f},
{1.27f},
{-1.28f},
{1.27f});
std::shared_ptr<ov::Node> fakeQuantize4; std::shared_ptr<ov::Node> fakeQuantize4;
const auto transpose0 = std::make_shared<ov::op::v1::Transpose>(fakeQuantize0, transpose0Const); const auto transpose0 = std::make_shared<ov::op::v1::Transpose>(fakeQuantize0, transpose0Const);
const auto transpose1 = std::make_shared<ov::op::v1::Transpose>(fakeQuantize1, transpose1Const); const auto transpose1 = std::make_shared<ov::op::v1::Transpose>(fakeQuantize1, transpose1Const);
const auto matMul0 = std::make_shared<ngraph::opset3::MatMul>(transpose0, transpose1, transA, transB); const auto matMul0 = std::make_shared<ov::op::v0::MatMul>(transpose0, transpose1, transA, transB);
const auto fakeQuantize3 = ngraph::builder::makeFakeQuantize(matMul0, inputPrecisions[0], 256, {}, {-1.28f}, {1.27f}, {-1.28f}, {1.27f}); const auto fakeQuantize3 =
const auto add = std::make_shared<ngraph::opset3::Add>(fakeQuantize3, addParam); ngraph::builder::makeFakeQuantize(matMul0, inputPrecisions[0], 256, {}, {-1.28f}, {1.27f}, {-1.28f}, {1.27f});
const auto reshape0 = std::make_shared<ngraph::opset1::Reshape>(add, reshape0Const, true); const auto add = std::make_shared<ov::op::v1::Add>(fakeQuantize3, addParam);
const auto softMax = std::make_shared<ngraph::opset1::Softmax>(reshape0, 1); const auto reshape0 = std::make_shared<ov::op::v1::Reshape>(add, reshape0Const, true);
const auto reshape1 = std::make_shared<ngraph::opset1::Reshape>(softMax, reshape1Const, true); const auto softMax = std::make_shared<ov::op::v1::Softmax>(reshape0, 1);
const auto reshape1 = std::make_shared<ov::op::v1::Reshape>(softMax, reshape1Const, true);
if (matMulIn0Precisions[1] == ElementType::u8) if (matMulIn0Precisions[1] == ElementType::u8)
fakeQuantize4 = ngraph::builder::makeFakeQuantize(reshape1, inputPrecisions[0], 256, {}, {0.0f}, {0.255f}, {0.0f}, {0.255f}); fakeQuantize4 = ngraph::builder::makeFakeQuantize(reshape1,
inputPrecisions[0],
256,
{},
{0.0f},
{0.255f},
{0.0f},
{0.255f});
else else
fakeQuantize4 = ngraph::builder::makeFakeQuantize(reshape1, inputPrecisions[0], 256, {}, {-0.128f}, {0.127f}, {-0.128f}, {0.127f}); fakeQuantize4 = ngraph::builder::makeFakeQuantize(reshape1,
inputPrecisions[0],
256,
{},
{-0.128f},
{0.127f},
{-0.128f},
{0.127f});
const auto transpose2 = std::make_shared<ov::op::v1::Transpose>(fakeQuantize2, transpose2Const); const auto transpose2 = std::make_shared<ov::op::v1::Transpose>(fakeQuantize2, transpose2Const);
const auto matMul1 = std::make_shared<ngraph::opset3::MatMul>(fakeQuantize4, transpose2, transA, transB); const auto matMul1 = std::make_shared<ov::op::v0::MatMul>(fakeQuantize4, transpose2, transA, transB);
const auto fakeQuantize5 = ngraph::builder::makeFakeQuantize(matMul1, inputPrecisions[0], 256, {}, {-1.28f}, {1.27f}, {-1.28f}, {1.27f}); const auto fakeQuantize5 =
ngraph::builder::makeFakeQuantize(matMul1, inputPrecisions[0], 256, {}, {-1.28f}, {1.27f}, {-1.28f}, {1.27f});
const auto transpose3 = std::make_shared<ov::op::v1::Transpose>(fakeQuantize5, transpose3Const); const auto transpose3 = std::make_shared<ov::op::v1::Transpose>(fakeQuantize5, transpose3Const);
ngraph::ResultVector results{std::make_shared<ngraph::opset1::Result>(transpose3)}; ov::ResultVector results{std::make_shared<ov::op::v0::Result>(transpose3)};
return std::make_shared<ngraph::Function>(results, ngraphParam, "mha"); return std::make_shared<ov::Model>(results, ngraphParam, "mha");
} }
static std::shared_ptr<ov::Model> initMHAQuantSubgraph1(const std::vector<ov::PartialShape>& inputDynamicShapes, static std::shared_ptr<ov::Model> initMHAQuantSubgraph1(const std::vector<ov::PartialShape>& inputDynamicShapes,
const std::vector<ElementType>& inputPrecisions, const std::vector<ElementType>& inputPrecisions,
const std::vector<ElementType>& matMulIn0Precisions, const std::vector<ElementType>& matMulIn0Precisions,
const bool fakeQuantize3Exists) { const bool fakeQuantize3Exists) {
ngraph::ParameterVector ngraphParam; ov::ParameterVector ngraphParam;
auto transpose0Param = std::make_shared<ngraph::opset1::Parameter>(inputPrecisions[0], inputDynamicShapes[0]); auto transpose0Param = std::make_shared<ov::op::v0::Parameter>(inputPrecisions[0], inputDynamicShapes[0]);
ngraphParam.push_back(transpose0Param); ngraphParam.push_back(transpose0Param);
auto transpose1Param = std::make_shared<ngraph::opset1::Parameter>(inputPrecisions[1], inputDynamicShapes[1]); auto transpose1Param = std::make_shared<ov::op::v0::Parameter>(inputPrecisions[1], inputDynamicShapes[1]);
ngraphParam.push_back(transpose1Param); ngraphParam.push_back(transpose1Param);
auto addParam = std::make_shared<ngraph::opset1::Parameter>(inputPrecisions[2], inputDynamicShapes[2]); auto addParam = std::make_shared<ov::op::v0::Parameter>(inputPrecisions[2], inputDynamicShapes[2]);
ngraphParam.push_back(addParam); ngraphParam.push_back(addParam);
auto transpose2Param = std::make_shared<ngraph::opset1::Parameter>(inputPrecisions[3], inputDynamicShapes[3]); auto transpose2Param = std::make_shared<ov::op::v0::Parameter>(inputPrecisions[3], inputDynamicShapes[3]);
ngraphParam.push_back(transpose2Param); ngraphParam.push_back(transpose2Param);
std::vector<ov::Shape> constantShapes; std::vector<ov::Shape> constantShapes;
@ -422,7 +475,7 @@ static std::shared_ptr<ov::Model> initMHAQuantSubgraph1(const std::vector<ov::Pa
std::vector<int64_t> transpose3ConstData = {0, 2, 1, 3}; std::vector<int64_t> transpose3ConstData = {0, 2, 1, 3};
auto transpose3Const = ngraph::builder::makeConstant(ElementType::i64, constantShapes[3], transpose3ConstData); auto transpose3Const = ngraph::builder::makeConstant(ElementType::i64, constantShapes[3], transpose3ConstData);
std::vector<float> mulConstData(ngraph::shape_size(constantShapes[4])); std::vector<float> mulConstData(ov::shape_size(constantShapes[4]));
auto mulConst = ngraph::builder::makeConstant(inputPrecisions[0], constantShapes[4], mulConstData, true); auto mulConst = ngraph::builder::makeConstant(inputPrecisions[0], constantShapes[4], mulConstData, true);
float transA = false; float transA = false;
@ -430,33 +483,55 @@ static std::shared_ptr<ov::Model> initMHAQuantSubgraph1(const std::vector<ov::Pa
std::shared_ptr<ov::Node> fakeQuantize0; std::shared_ptr<ov::Node> fakeQuantize0;
if (matMulIn0Precisions[0] == ElementType::u8) if (matMulIn0Precisions[0] == ElementType::u8)
fakeQuantize0 = ngraph::builder::makeFakeQuantize(transpose0Param, inputPrecisions[0], 256, {}, {0.0f}, {2.55f}, {0.0f}, {2.55f}); fakeQuantize0 = ngraph::builder::makeFakeQuantize(transpose0Param,
inputPrecisions[0],
256,
{},
{0.0f},
{2.55f},
{0.0f},
{2.55f});
else else
fakeQuantize0 = ngraph::builder::makeFakeQuantize(transpose0Param, inputPrecisions[0], 256, {}, {-1.28f}, {1.27f}, {-1.28f}, {1.27f}); fakeQuantize0 = ngraph::builder::makeFakeQuantize(transpose0Param,
inputPrecisions[0],
256,
{},
{-1.28f},
{1.27f},
{-1.28f},
{1.27f});
const auto transpose0 = std::make_shared<ov::op::v1::Transpose>(fakeQuantize0, transpose0Const); const auto transpose0 = std::make_shared<ov::op::v1::Transpose>(fakeQuantize0, transpose0Const);
const auto transpose1 = std::make_shared<ov::op::v1::Transpose>(transpose1Param, transpose1Const); const auto transpose1 = std::make_shared<ov::op::v1::Transpose>(transpose1Param, transpose1Const);
const auto fakeQuantize1 = ngraph::builder::makeFakeQuantize(transpose1, inputPrecisions[1], 256, {}, {-1.28f}, {1.27f}, {-1.28f}, {1.27f}); const auto fakeQuantize1 = ngraph::builder::makeFakeQuantize(transpose1,
const auto matMul0 = std::make_shared<ngraph::opset3::MatMul>(transpose0, fakeQuantize1, transA, transB); inputPrecisions[1],
const auto mul = std::make_shared<ngraph::opset3::Multiply>(addParam, mulConst); 256,
const auto add = std::make_shared<ngraph::opset3::Add>(matMul0, mul); {},
const auto softMax = std::make_shared<ngraph::opset1::Softmax>(add, 3); {-1.28f},
{1.27f},
{-1.28f},
{1.27f});
const auto matMul0 = std::make_shared<ov::op::v0::MatMul>(transpose0, fakeQuantize1, transA, transB);
const auto mul = std::make_shared<ov::op::v1::Multiply>(addParam, mulConst);
const auto add = std::make_shared<ov::op::v1::Add>(matMul0, mul);
const auto softMax = std::make_shared<ov::op::v1::Softmax>(add, 3);
const auto transpose2 = std::make_shared<ov::op::v1::Transpose>(transpose2Param, transpose2Const); const auto transpose2 = std::make_shared<ov::op::v1::Transpose>(transpose2Param, transpose2Const);
const auto matMul1 = std::make_shared<ngraph::opset3::MatMul>(softMax, transpose2, transA, transB); const auto matMul1 = std::make_shared<ov::op::v0::MatMul>(softMax, transpose2, transA, transB);
const auto transpose3 = std::make_shared<ov::op::v1::Transpose>( const auto transpose3 = std::make_shared<ov::op::v1::Transpose>(
fakeQuantize3Exists ? fakeQuantize3Exists
ngraph::builder::makeFakeQuantize(matMul1, inputPrecisions[0], 256, {}, { 0.0f }, { 2.55f }, { 0.0f }, { 2.55f }) : ? ngraph::builder::makeFakeQuantize(matMul1, inputPrecisions[0], 256, {}, {0.0f}, {2.55f}, {0.0f}, {2.55f})
matMul1, : matMul1,
transpose3Const); transpose3Const);
ngraph::ResultVector results{std::make_shared<ngraph::opset1::Result>(transpose3)}; ov::ResultVector results{std::make_shared<ov::op::v0::Result>(transpose3)};
return std::make_shared<ngraph::Function>(results, ngraphParam, "mha"); return std::make_shared<ov::Model>(results, ngraphParam, "mha");
} }
class MHAQuantTest : public testing::WithParamInterface<MHATuple>, class MHAQuantTest : public testing::WithParamInterface<MHATuple>,
virtual public SubgraphBaseTest, public CPUTestsBase { virtual public SubgraphBaseTest,
public CPUTestsBase {
public: public:
static std::string getTestCaseName(const testing::TestParamInfo<MHATuple> &obj) { static std::string getTestCaseName(const testing::TestParamInfo<MHATuple>& obj) {
std::vector<InputShape> inputShapes; std::vector<InputShape> inputShapes;
std::vector<ElementType> inputPrecisions; std::vector<ElementType> inputPrecisions;
std::vector<ElementType> matMulIn0Precisions; std::vector<ElementType> matMulIn0Precisions;
@ -485,24 +560,31 @@ public:
results << "patternType=" << patternType; results << "patternType=" << patternType;
results << "expect="; results << "expect=";
for (const auto& node : expectedNodes) { for (const auto& node : expectedNodes) {
results << node.first << "[" << node.second << "]" << "_"; results << node.first << "[" << node.second << "]"
<< "_";
} }
results << "targetDevice=" << targetName; results << "targetDevice=" << targetName;
return results.str(); 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(); inputs.clear();
const auto& funcInputs = function->inputs(); const auto& funcInputs = function->inputs();
for (size_t i = 0; i < funcInputs.size(); ++i) { for (size_t i = 0; i < funcInputs.size(); ++i) {
const auto& funcInput = funcInputs[i]; const auto& funcInput = funcInputs[i];
ov::Tensor tensor; ov::Tensor tensor;
if (funcInput.get_element_type().is_real()) if (funcInput.get_element_type().is_real())
tensor = ov::test::utils::create_and_fill_tensor_normal_distribution(funcInput.get_element_type(), targetInputStaticShapes[i], 0.0f, 1.5f); tensor = ov::test::utils::create_and_fill_tensor_normal_distribution(funcInput.get_element_type(),
targetInputStaticShapes[i],
0.0f,
1.5f);
else else
tensor = ov::test::utils::create_and_fill_tensor(funcInput.get_element_type(), targetInputStaticShapes[i], 255, 0, 1); tensor = ov::test::utils::create_and_fill_tensor(funcInput.get_element_type(),
targetInputStaticShapes[i],
255,
0,
1);
inputs.insert({funcInput.get_node_shared_ptr(), tensor}); inputs.insert({funcInput.get_node_shared_ptr(), tensor});
} }
@ -517,7 +599,8 @@ protected:
std::vector<ElementType> matMulIn0Precisions; std::vector<ElementType> matMulIn0Precisions;
size_t patternType; size_t patternType;
ExpectedNodes expectedNodes; ExpectedNodes expectedNodes;
std::tie(inputShapes, inputPrecisions, matMulIn0Precisions, patternType, expectedNodes, targetDevice) = this->GetParam(); std::tie(inputShapes, inputPrecisions, matMulIn0Precisions, patternType, expectedNodes, targetDevice) =
this->GetParam();
init_input_shapes(inputShapes); init_input_shapes(inputShapes);
@ -531,11 +614,11 @@ protected:
FAIL() << "Unsupported MHA pattern type"; FAIL() << "Unsupported MHA pattern type";
} }
// Snippets MHA tokenization has limitations to avoid performance degradations. These limitations depend on target machine. // Snippets MHA tokenization has limitations to avoid performance degradations. These limitations depend on
// Just for testing, we disable these limitations to allow Snippets to tokenize pattern on all machines for validation. // target machine. Just for testing, we disable these limitations to allow Snippets to tokenize pattern on all
if (!configuration.count(InferenceEngine::PluginConfigInternalParams::KEY_SNIPPETS_MODE)) { // machines for validation.
configuration.insert({InferenceEngine::PluginConfigInternalParams::KEY_SNIPPETS_MODE, if (!configuration.count("SNIPPETS_MODE")) {
InferenceEngine::PluginConfigInternalParams::IGNORE_CALLBACK}); configuration.insert({"SNIPPETS_MODE", "IGNORE_CALLBACK"});
} }
} }
}; };
@ -546,12 +629,13 @@ TEST_P(MHAQuantTest, CompareWithRefs) {
std::vector<ElementType> matMulIn0Precisions; std::vector<ElementType> matMulIn0Precisions;
size_t patternType; size_t patternType;
ExpectedNodes expectedNodes; ExpectedNodes expectedNodes;
std::tie(inputShapes, inputPrecisions, matMulIn0Precisions, patternType, expectedNodes, targetDevice) = this->GetParam(); std::tie(inputShapes, inputPrecisions, matMulIn0Precisions, patternType, expectedNodes, targetDevice) =
this->GetParam();
if (inputPrecisions[0] == ElementType::bf16 && !InferenceEngine::with_cpu_x86_bfloat16()) if (inputPrecisions[0] == ElementType::bf16 && !ov::with_cpu_x86_bfloat16())
GTEST_SKIP(); GTEST_SKIP();
if (!InferenceEngine::with_cpu_x86_avx512_core_vnni()) if (!ov::with_cpu_x86_avx512_core_vnni())
GTEST_SKIP(); GTEST_SKIP();
run(); run();
@ -563,7 +647,7 @@ TEST_P(MHAQuantTest, CompareWithRefs) {
namespace { namespace {
std::vector<std::vector<ngraph::Shape>> inputShapesQuant = { std::vector<std::vector<ov::Shape>> inputShapesQuant = {
{{2, 7, 16, 9}, {2, 7, 16, 9}, {2, 1, 1, 7}, {2, 7, 16, 9}}, {{2, 7, 16, 9}, {2, 7, 16, 9}, {2, 1, 1, 7}, {2, 7, 16, 9}},
{{2, 8, 16, 64}, {2, 8, 16, 64}, {2, 1, 1, 8}, {2, 8, 16, 64}}, {{2, 8, 16, 64}, {2, 8, 16, 64}, {2, 1, 1, 8}, {2, 8, 16, 64}},
{{1, 384, 16, 64}, {1, 384, 16, 64}, {1, 1, 1, 384}, {1, 384, 16, 64}}, {{1, 384, 16, 64}, {1, 384, 16, 64}, {1, 1, 1, 384}, {1, 384, 16, 64}},
@ -571,52 +655,52 @@ std::vector<std::vector<ngraph::Shape>> inputShapesQuant = {
{{3, 96, 16, 64}, {3, 96, 16, 64}, {3, 1, 1, 96}, {3, 96, 16, 64}}, {{3, 96, 16, 64}, {3, 96, 16, 64}, {3, 1, 1, 96}, {3, 96, 16, 64}},
{{2, 192, 16, 160}, {2, 192, 16, 160}, {2, 1, 1, 192}, {2, 192, 16, 160}}, {{2, 192, 16, 160}, {2, 192, 16, 160}, {2, 1, 1, 192}, {2, 192, 16, 160}},
{{2, 4, 16, 8}, {2, 4, 16, 8}, {2, 1, 1, 4}, {2, 4, 16, 8}}, {{2, 4, 16, 8}, {2, 4, 16, 8}, {2, 1, 1, 4}, {2, 4, 16, 8}},
{{1, 204, 13, 212}, {1, 204, 13, 212}, {1, 1, 1, 204}, {1, 204, 13, 212}}, {{1, 204, 13, 212}, {1, 204, 13, 212}, {1, 1, 1, 204}, {1, 204, 13, 212}},
{{1, 207, 13, 211}, {1, 207, 13, 211}, {1, 1, 1, 207}, {1, 207, 13, 211}}, {{1, 207, 13, 211}, {1, 207, 13, 211}, {1, 1, 1, 207}, {1, 207, 13, 211}},
}; };
std::vector<std::vector<ElementType>> inputPrecisionsQuant = { std::vector<std::vector<ElementType>> inputPrecisionsQuant = {
{ ElementType::f32, ElementType::f32, ElementType::f32, ElementType::f32 }, {ElementType::f32, ElementType::f32, ElementType::f32, ElementType::f32},
}; };
std::vector<std::vector<ElementType>> matMulIn0PrecisionsQuant = { std::vector<std::vector<ElementType>> matMulIn0PrecisionsQuant = {
{ ElementType::i8, ElementType::i8 }, {ElementType::i8, ElementType::i8},
{ ElementType::i8, ElementType::u8 }, {ElementType::i8, ElementType::u8},
}; };
INSTANTIATE_TEST_SUITE_P(smoke_MHAQuant_Pattern0, MHAQuantTest, INSTANTIATE_TEST_SUITE_P(smoke_MHAQuant_Pattern0,
::testing::Combine( MHAQuantTest,
::testing::ValuesIn(static_shapes_to_test_representation(inputShapesQuant)), ::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation(inputShapesQuant)),
::testing::ValuesIn(inputPrecisionsQuant), ::testing::ValuesIn(inputPrecisionsQuant),
::testing::ValuesIn(matMulIn0PrecisionsQuant), ::testing::ValuesIn(matMulIn0PrecisionsQuant),
::testing::Values(0), ::testing::Values(0),
::testing::Values(ExpectedNodes{{"Subgraph", 5}, // FQs on inputs x 3 + MHA + Deq Mul ::testing::Values(ExpectedNodes{
{"Transpose", 1}}), // Transpose between MHA and Deq Mul {"Subgraph", 5}, // FQs on inputs x 3 + MHA + Deq Mul
::testing::Values(ov::test::utils::DEVICE_CPU)), {"Transpose", 1}}), // Transpose between MHA and Deq Mul
MHAQuantTest::getTestCaseName); ::testing::Values(ov::test::utils::DEVICE_CPU)),
MHAQuantTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_MHAQuant_Pattern1,
MHAQuantTest,
::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation(inputShapesQuant)),
::testing::ValuesIn(inputPrecisionsQuant),
::testing::ValuesIn(matMulIn0PrecisionsQuant),
::testing::Values(1),
::testing::Values(ExpectedNodes{
{"Subgraph", 3}, // FQ on input + MHA + Deq Mul
{"Transpose", 1}}), // Transpose between MHA and Deq Mul
::testing::Values(ov::test::utils::DEVICE_CPU)),
MHAQuantTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_MHAQuant_Pattern1, MHAQuantTest, INSTANTIATE_TEST_SUITE_P(smoke_MHAQuant_Pattern2,
::testing::Combine( MHAQuantTest,
::testing::ValuesIn(static_shapes_to_test_representation(inputShapesQuant)), ::testing::Combine(::testing::ValuesIn(static_shapes_to_test_representation(inputShapesQuant)),
::testing::ValuesIn(inputPrecisionsQuant), ::testing::ValuesIn(inputPrecisionsQuant),
::testing::ValuesIn(matMulIn0PrecisionsQuant), ::testing::ValuesIn(matMulIn0PrecisionsQuant),
::testing::Values(1), ::testing::Values(2),
::testing::Values(ExpectedNodes{{"Subgraph", 3}, // FQ on input + MHA + Deq Mul ::testing::Values(ExpectedNodes{{"Subgraph", 2}, // MHA + Deq Mul
{"Transpose", 1}}), // Transpose between MHA and Deq Mul {"Transpose", 0}}), // Transpose is fused
::testing::Values(ov::test::utils::DEVICE_CPU)), ::testing::Values(ov::test::utils::DEVICE_CPU)),
MHAQuantTest::getTestCaseName); MHAQuantTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_MHAQuant_Pattern2, MHAQuantTest, } // namespace
::testing::Combine(
::testing::ValuesIn(static_shapes_to_test_representation(inputShapesQuant)),
::testing::ValuesIn(inputPrecisionsQuant),
::testing::ValuesIn(matMulIn0PrecisionsQuant),
::testing::Values(2),
::testing::Values(ExpectedNodes{{"Subgraph", 2}, // MHA + Deq Mul
{"Transpose", 0}}), // Transpose is fused
::testing::Values(ov::test::utils::DEVICE_CPU)),
MHAQuantTest::getTestCaseName);
} // namespace
} // namespace CPUSubgraphTestsDefinitions

View File

@ -2,46 +2,37 @@
// SPDX-License-Identifier: Apache-2.0 // 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/common_utils.hpp"
#include <common_test_utils/ov_tensor_utils.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 "test_utils/cpu_test_utils.hpp"
#include <openvino/opsets/opset1.hpp>
#include "cpp_interfaces/interface/ie_internal_plugin_config.hpp"
using namespace CPUTestUtils; using namespace CPUTestUtils;
using namespace ov::test;
using namespace ngraph::helpers;
namespace CPUSubgraphTestsDefinitions { namespace ov {
namespace test {
typedef std::tuple< typedef std::tuple<std::vector<InputShape>, ElementType, ElementType, size_t> NgramTestParams;
std::vector<InputShape>,
ElementType,
ElementType,
size_t
> NgramTestParams;
static std::shared_ptr<ov::Node> getStridedSlice(const std::shared_ptr<ov::Node>& data, static std::shared_ptr<ov::Node> getStridedSlice(const std::shared_ptr<ov::Node>& data,
const std::shared_ptr<ov::Node>& begin, const std::shared_ptr<ov::Node>& begin,
const std::shared_ptr<ov::Node>& end, const std::shared_ptr<ov::Node>& end,
const std::vector<int64_t>& shrink_axis_mask = {}) { const std::vector<int64_t>& shrink_axis_mask = {}) {
std::vector<int64_t> default_mask(begin->get_shape()[0], 0); std::vector<int64_t> default_mask(begin->get_shape()[0], 0);
return std::make_shared<ov::opset1::StridedSlice>(data, begin, end, default_mask, default_mask, return std::make_shared<ov::op::v1::StridedSlice>(data,
std::vector<int64_t>{}, shrink_axis_mask); begin,
end,
default_mask,
default_mask,
std::vector<int64_t>{},
shrink_axis_mask);
} }
static std::shared_ptr<ov::Node> getReshape(const std::shared_ptr<ov::Node>& data, static std::shared_ptr<ov::Node> getReshape(const std::shared_ptr<ov::Node>& data,
const std::vector<int64_t>& requested_shape, const std::vector<int64_t>& requested_shape,
const ov::element::Type& prc) { const ov::element::Type& prc) {
auto requested_shape_node = ov::opset1::Constant::create(prc, {requested_shape.size()}, requested_shape); auto requested_shape_node = ov::op::v0::Constant::create(prc, {requested_shape.size()}, requested_shape);
return std::make_shared<ov::opset1::Reshape>(data, requested_shape_node, true); return std::make_shared<ov::op::v1::Reshape>(data, requested_shape_node, true);
} }
static std::shared_ptr<ov::Model> initNgram(std::vector<ov::PartialShape>& input_shapes, static std::shared_ptr<ov::Model> initNgram(std::vector<ov::PartialShape>& input_shapes,
@ -58,78 +49,80 @@ static std::shared_ptr<ov::Model> initNgram(std::vector<ov::PartialShape>& input
auto param_node = std::make_shared<ov::op::v0::Parameter>(input_precisions[i], input_shapes[i]); auto param_node = std::make_shared<ov::op::v0::Parameter>(input_precisions[i], input_shapes[i]);
params.push_back(param_node); params.push_back(param_node);
} }
auto shape_of = std::make_shared<ov::opset10::ShapeOf>(params[0], idces_et); auto shape_of = std::make_shared<ov::op::v3::ShapeOf>(params[0], idces_et);
auto shape_ss_begin = ov::opset1::Constant::create(idces_et, {1}, {0}); auto shape_ss_begin = ov::op::v0::Constant::create(idces_et, {1}, {0});
auto shape_ss_end = ov::opset1::Constant::create(idces_et, {1}, {1}); auto shape_ss_end = ov::op::v0::Constant::create(idces_et, {1}, {1});
auto shape_ss = getStridedSlice(shape_of, shape_ss_begin, shape_ss_end, {1}); auto shape_ss = getStridedSlice(shape_of, shape_ss_begin, shape_ss_end, {1});
auto getInputsToPad = [&](const ov::Output<ov::Node> data, const int pad_value) { auto getInputsToPad = [&](const ov::Output<ov::Node> data, const int pad_value) {
const size_t length = data.get_partial_shape()[1].get_length(); const size_t length = data.get_partial_shape()[1].get_length();
ov::OutputVector inputs; ov::OutputVector inputs;
if (left_pad > 0) { if (left_pad > 0) {
inputs.push_back(ov::opset1::Constant::create(data.get_element_type(), {left_pad, length}, {pad_value})); inputs.push_back(ov::op::v0::Constant::create(data.get_element_type(), {left_pad, length}, {pad_value}));
} }
inputs.push_back(data); inputs.push_back(data);
if (right_pad > 0) { if (right_pad > 0) {
inputs.push_back(ov::opset1::Constant::create(data.get_element_type(), {right_pad, length}, {pad_value})); inputs.push_back(ov::op::v0::Constant::create(data.get_element_type(), {right_pad, length}, {pad_value}));
} }
return inputs; return inputs;
}; };
auto data_padded = std::make_shared<ov::opset1::Concat>(getInputsToPad(params[0], 0), 0); auto data_padded = std::make_shared<ov::op::v0::Concat>(getInputsToPad(params[0], 0), 0);
auto idces_padded = std::make_shared<ov::opset1::Concat>(getInputsToPad(params[1], -1), 0); auto idces_padded = std::make_shared<ov::op::v0::Concat>(getInputsToPad(params[1], -1), 0);
std::shared_ptr<ov::Node> as_is_bias = shape_ss; std::shared_ptr<ov::Node> as_is_bias = shape_ss;
if (mid_idx != 0) { if (mid_idx != 0) {
auto bias_const = ov::opset1::Constant::create(idces_et, {}, {mid_idx}); auto bias_const = ov::op::v0::Constant::create(idces_et, {}, {mid_idx});
as_is_bias = std::make_shared<ov::opset1::Add>(shape_ss, bias_const); as_is_bias = std::make_shared<ov::op::v1::Add>(shape_ss, bias_const);
} }
auto as_is_ss_begin = ov::opset1::Constant::create(idces_et, {1}, {mid_idx}); auto as_is_ss_begin = ov::op::v0::Constant::create(idces_et, {1}, {mid_idx});
auto as_is_ss_end = getReshape(as_is_bias, {1}, idces_et); auto as_is_ss_end = getReshape(as_is_bias, {1}, idces_et);
auto as_is_ss = getStridedSlice(data_padded, as_is_ss_begin, as_is_ss_end); auto as_is_ss = getStridedSlice(data_padded, as_is_ss_begin, as_is_ss_end);
auto getSelectBranch = [&](const size_t cur_idx, const size_t mid_idx) { auto getSelectBranch = [&](const size_t cur_idx, const size_t mid_idx) {
std::shared_ptr<ov::Node> eq_left_bias = shape_ss; std::shared_ptr<ov::Node> eq_left_bias = shape_ss;
if (cur_idx != 0) { if (cur_idx != 0) {
auto bias_const = ov::opset1::Constant::create(idces_et, {}, {cur_idx}); auto bias_const = ov::op::v0::Constant::create(idces_et, {}, {cur_idx});
eq_left_bias = std::make_shared<ov::opset1::Add>(shape_ss, bias_const); eq_left_bias = std::make_shared<ov::op::v1::Add>(shape_ss, bias_const);
} }
auto eq_left_reshape = getReshape(eq_left_bias, {1}, idces_et); auto eq_left_reshape = getReshape(eq_left_bias, {1}, idces_et);
auto eq_left_concat_const = ov::opset1::Constant::create(idces_et, {1}, {1}); auto eq_left_concat_const = ov::op::v0::Constant::create(idces_et, {1}, {1});
auto eq_left_concat = std::make_shared<ov::opset1::Concat>(ov::OutputVector{eq_left_reshape, eq_left_concat_const}, 0); auto eq_left_concat =
auto eq_left_ss_begin = ov::opset1::Constant::create(idces_et, {2}, std::vector<size_t>{cur_idx, 0ul}); std::make_shared<ov::op::v0::Concat>(ov::OutputVector{eq_left_reshape, eq_left_concat_const}, 0);
auto eq_left_ss_begin = ov::op::v0::Constant::create(idces_et, {2}, std::vector<size_t>{cur_idx, 0ul});
auto eq_left_ss = getStridedSlice(idces_padded, eq_left_ss_begin, eq_left_concat, {0, 1}); auto eq_left_ss = getStridedSlice(idces_padded, eq_left_ss_begin, eq_left_concat, {0, 1});
std::shared_ptr<ov::Node> eq_right_bias = shape_ss; std::shared_ptr<ov::Node> eq_right_bias = shape_ss;
if (mid_idx != 0) { if (mid_idx != 0) {
auto bias_const = ov::opset1::Constant::create(idces_et, {}, {mid_idx}); auto bias_const = ov::op::v0::Constant::create(idces_et, {}, {mid_idx});
eq_right_bias = std::make_shared<ov::opset1::Add>(shape_ss, bias_const); eq_right_bias = std::make_shared<ov::op::v1::Add>(shape_ss, bias_const);
} }
auto eq_right_reshape = getReshape(eq_right_bias, {1}, idces_et); auto eq_right_reshape = getReshape(eq_right_bias, {1}, idces_et);
auto eq_right_concat_const = ov::opset1::Constant::create(idces_et, {1}, {1}); auto eq_right_concat_const = ov::op::v0::Constant::create(idces_et, {1}, {1});
auto eq_right_concat = std::make_shared<ov::opset1::Concat>(ov::OutputVector{eq_right_reshape, eq_right_concat_const}, 0); auto eq_right_concat =
auto eq_right_ss_begin = ov::opset1::Constant::create(idces_et, {2}, std::vector<size_t>{mid_idx, 0ul}); std::make_shared<ov::op::v0::Concat>(ov::OutputVector{eq_right_reshape, eq_right_concat_const}, 0);
auto eq_right_ss_begin = ov::op::v0::Constant::create(idces_et, {2}, std::vector<size_t>{mid_idx, 0ul});
auto eq_right_ss = getStridedSlice(idces_padded, eq_right_ss_begin, eq_right_concat, {0, 1}); auto eq_right_ss = getStridedSlice(idces_padded, eq_right_ss_begin, eq_right_concat, {0, 1});
auto equal = std::make_shared<ov::opset1::Equal>(eq_left_ss, eq_right_ss); auto equal = std::make_shared<ov::op::v1::Equal>(eq_left_ss, eq_right_ss);
auto cond = getReshape(equal, {-1, 1}, idces_et); auto cond = getReshape(equal, {-1, 1}, idces_et);
std::shared_ptr<ov::Node> then_bias = shape_ss; std::shared_ptr<ov::Node> then_bias = shape_ss;
if (cur_idx != 0) { if (cur_idx != 0) {
auto bias_const = ov::opset1::Constant::create(idces_et, {}, {cur_idx}); auto bias_const = ov::op::v0::Constant::create(idces_et, {}, {cur_idx});
then_bias = std::make_shared<ov::opset1::Add>(shape_ss, bias_const); then_bias = std::make_shared<ov::op::v1::Add>(shape_ss, bias_const);
} }
auto then_reshape = getReshape(then_bias, {1}, idces_et); auto then_reshape = getReshape(then_bias, {1}, idces_et);
auto then_ss_begin = ov::opset1::Constant::create(idces_et, {1}, {cur_idx}); auto then_ss_begin = ov::op::v0::Constant::create(idces_et, {1}, {cur_idx});
auto then = getStridedSlice(data_padded, then_ss_begin, then_reshape); auto then = getStridedSlice(data_padded, then_ss_begin, then_reshape);
auto else_reshape = getReshape(shape_ss, {1}, idces_et); auto else_reshape = getReshape(shape_ss, {1}, idces_et);
auto else_concat_const = ov::opset1::Constant::create(idces_et, {1}, {input_shapes[0][1].get_length()}); auto else_concat_const = ov::op::v0::Constant::create(idces_et, {1}, {input_shapes[0][1].get_length()});
auto else_concat = std::make_shared<ov::opset1::Concat>(ov::OutputVector{else_reshape, else_concat_const}, 0); auto else_concat = std::make_shared<ov::op::v0::Concat>(ov::OutputVector{else_reshape, else_concat_const}, 0);
auto else_bcast_const = ov::opset1::Constant::create(data_et, {}, {0}); auto else_bcast_const = ov::op::v0::Constant::create(data_et, {}, {0});
auto else_bcast = std::make_shared<ov::opset1::Broadcast>(else_bcast_const, else_concat); auto else_bcast = std::make_shared<ov::op::v1::Broadcast>(else_bcast_const, else_concat);
auto select = std::make_shared<ov::opset1::Select>(cond, then, else_bcast); auto select = std::make_shared<ov::op::v1::Select>(cond, then, else_bcast);
return select; return select;
}; };
@ -141,13 +134,15 @@ static std::shared_ptr<ov::Model> initNgram(std::vector<ov::PartialShape>& input
concat_inputs[i] = getSelectBranch(i, mid_idx); concat_inputs[i] = getSelectBranch(i, mid_idx);
} }
auto final_concat = std::make_shared<ov::opset10::Concat>(concat_inputs, 1); auto final_concat = std::make_shared<ov::op::v0::Concat>(concat_inputs, 1);
return std::make_shared<ov::Model>(final_concat, params, "ngram"); return std::make_shared<ov::Model>(final_concat, params, "ngram");
} }
class NgramCPUTest : public testing::WithParamInterface<NgramTestParams>, virtual public SubgraphBaseTest, public CPUTestsBase { class NgramCPUTest : public testing::WithParamInterface<NgramTestParams>,
virtual public SubgraphBaseTest,
public CPUTestsBase {
public: public:
static std::string getTestCaseName(const testing::TestParamInfo<NgramTestParams> &obj) { static std::string getTestCaseName(const testing::TestParamInfo<NgramTestParams>& obj) {
std::vector<InputShape> input_shapes; std::vector<InputShape> input_shapes;
size_t k; size_t k;
ElementType data_et; ElementType data_et;
@ -178,7 +173,6 @@ public:
auto embeddings_tensor = ov::test::utils::create_and_fill_tensor_consistently(data_et, data_shape, 100, 1, 1); auto embeddings_tensor = ov::test::utils::create_and_fill_tensor_consistently(data_et, data_shape, 100, 1, 1);
inputs.insert({model_inputs[0].get_node_shared_ptr(), embeddings_tensor}); inputs.insert({model_inputs[0].get_node_shared_ptr(), embeddings_tensor});
const auto& indices_et = model_inputs[1].get_element_type(); const auto& indices_et = model_inputs[1].get_element_type();
const auto& indices_shape = targetInputStaticShapes[1]; const auto& indices_shape = targetInputStaticShapes[1];
const size_t batch_size = data_shape[0]; const size_t batch_size = data_shape[0];
@ -207,9 +201,8 @@ protected:
init_input_shapes(inputShapes); init_input_shapes(inputShapes);
function = initNgram(inputDynamicShapes, data_et, idces_et, k); function = initNgram(inputDynamicShapes, data_et, idces_et, k);
if (!configuration.count(InferenceEngine::PluginConfigInternalParams::KEY_SNIPPETS_MODE)) { if (!configuration.count("SNIPPETS_MODE")) {
configuration.insert({InferenceEngine::PluginConfigInternalParams::KEY_SNIPPETS_MODE, configuration.insert({"SNIPPETS_MODE", "DISABLE"});
InferenceEngine::PluginConfigInternalParams::DISABLE});
} }
} }
}; };
@ -222,28 +215,21 @@ TEST_P(NgramCPUTest, CompareWithRefs) {
namespace { namespace {
std::vector<std::vector<InputShape>> inputShapes = { std::vector<std::vector<InputShape>> inputShapes = {
{ {InputShape{{-1, 2}, {{3, 2}, {5, 2}, {7, 2}}}, InputShape{{-1, 2}, {{3, 2}, {5, 2}, {7, 2}}}},
InputShape{{-1, 2}, {{3, 2}, {5, 2}, {7, 2}}}, {InputShape{{-1, 256}, {{12, 256}, {25, 256}}}, InputShape{{-1, 2}, {{12, 2}, {25, 2}}}},
InputShape{{-1, 2}, {{3, 2}, {5, 2}, {7, 2}}} {InputShape{{-1, 1}, {{12, 1}}}, InputShape{{-1, 2}, {{12, 2}}}},
},
{
InputShape{{-1, 256}, {{12, 256}, {25, 256}}},
InputShape{{-1, 2}, {{12, 2}, {25, 2}}}
},
{
InputShape{{-1, 1}, {{12, 1}}},
InputShape{{-1, 2}, {{12, 2}}}
},
}; };
std::vector<size_t> k_values = {2, 3, 5, 7}; std::vector<size_t> k_values = {2, 3, 5, 7};
std::vector<ElementType> idces_precisions = {ElementType::i32, ElementType::i64}; std::vector<ElementType> idces_precisions = {ElementType::i32, ElementType::i64};
INSTANTIATE_TEST_SUITE_P(smoke_Ngram, NgramCPUTest, INSTANTIATE_TEST_SUITE_P(smoke_Ngram,
::testing::Combine(::testing::ValuesIn(inputShapes), NgramCPUTest,
::testing::Values(ElementType::f32), ::testing::Combine(::testing::ValuesIn(inputShapes),
::testing::ValuesIn(idces_precisions), ::testing::Values(ElementType::f32),
::testing::ValuesIn(k_values)), ::testing::ValuesIn(idces_precisions),
NgramCPUTest::getTestCaseName); ::testing::ValuesIn(k_values)),
} // namespace NgramCPUTest::getTestCaseName);
} // namespace CPUSubgraphTestsDefinitions } // namespace
} // namespace test
} // namespace ov

View File

@ -6,10 +6,9 @@
#include "shared_test_classes/subgraph/parameter_result.hpp" #include "shared_test_classes/subgraph/parameter_result.hpp"
using namespace SubgraphTestsDefinitions; using namespace SubgraphTestsDefinitions;
using namespace ov::test;
using namespace InferenceEngine;
namespace CPULayerTestsDefinitions { namespace ov {
namespace test {
class ParameterResultCustomBlobTest : public ParameterResultSubgraphTestLegacyApi { class ParameterResultCustomBlobTest : public ParameterResultSubgraphTestLegacyApi {
protected: protected:
@ -21,7 +20,7 @@ protected:
auto inputBlob = inputs.front(); auto inputBlob = inputs.front();
const size_t elementsCount = inputBlob->size(); const size_t elementsCount = inputBlob->size();
for (size_t i = 0; i < inferIterations; ++i) { for (size_t i = 0; i < inferIterations; ++i) {
ov::test::utils::fill_data_random<Precision::FP32>(inputBlob, 10, 0, 1, i); ov::test::utils::fill_data_random<InferenceEngine::Precision::FP32>(inputBlob, 10, 0, 1, i);
auto inputsInfo = cnnNetwork.getInputsInfo().begin()->second; auto inputsInfo = cnnNetwork.getInputsInfo().begin()->second;
std::string inputName = cnnNetwork.getInputsInfo().begin()->first; std::string inputName = cnnNetwork.getInputsInfo().begin()->first;
@ -30,7 +29,7 @@ protected:
std::copy(inpBlobData, inpBlobData + elementsCount, customInpData.begin()); std::copy(inpBlobData, inpBlobData + elementsCount, customInpData.begin());
auto& tensorDesc = inputsInfo->getTensorDesc(); auto& tensorDesc = inputsInfo->getTensorDesc();
auto customBlob = make_shared_blob<float>(tensorDesc, customInpData.data(), elementsCount); auto customBlob = InferenceEngine::make_shared_blob<float>(tensorDesc, customInpData.data(), elementsCount);
inferRequest.SetBlob(inputName, customBlob); inferRequest.SetBlob(inputName, customBlob);
inferRequest.Infer(); inferRequest.Infer();
@ -46,8 +45,8 @@ protected:
TEST_P(ParameterResultCustomBlobTest, CompareWithRefs) { TEST_P(ParameterResultCustomBlobTest, CompareWithRefs) {
// Just to show that it is not possible to set different precisions for inputs and outputs with the same name. // Just to show that it is not possible to set different precisions for inputs and outputs with the same name.
// If it was possible, the input would have I8 precision and couldn't store data from the custom blob. // If it was possible, the input would have I8 precision and couldn't store data from the custom blob.
inPrc = Precision::I8; inPrc = InferenceEngine::Precision::I8;
outPrc = Precision::FP32; outPrc = InferenceEngine::Precision::FP32;
Run(); Run();
} }
@ -84,4 +83,5 @@ INSTANTIATE_TEST_SUITE_P(smoke_Check_Same_Blob,
::testing::Values(ov::test::utils::DEVICE_CPU)), ::testing::Values(ov::test::utils::DEVICE_CPU)),
ParameterResultSubgraphTestBase::getTestCaseName); ParameterResultSubgraphTestBase::getTestCaseName);
} // namespace } // namespace
} // namespace CPULayerTestsDefinitions } // namespace test
} // namespace ov

View File

@ -2,24 +2,20 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// //
#include "ov_models/builders.hpp" #include "common_test_utils/node_builders/activation.hpp"
#include "ov_models/utils/ov_helpers.hpp"
#include "shared_test_classes/base/layer_test_utils.hpp"
#include "shared_test_classes/base/ov_subgraph.hpp" #include "shared_test_classes/base/ov_subgraph.hpp"
#include "test_utils/cpu_test_utils.hpp" #include "test_utils/cpu_test_utils.hpp"
#include "test_utils/fusing_test_utils.hpp" #include "test_utils/fusing_test_utils.hpp"
using namespace ov::test;
using namespace ngraph;
using namespace CPUTestUtils; using namespace CPUTestUtils;
using namespace InferenceEngine;
namespace SubgraphTestsDefinitions { namespace ov {
namespace test {
using RemoveConvertCPUTestParams = std::tuple<ElementType, InputShape>; using RemoveConvertCPUTestParams = std::tuple<ElementType, InputShape>;
class RemoveUselessBF16ConvertCPUTest : public testing::WithParamInterface<RemoveConvertCPUTestParams>, class RemoveUselessBF16ConvertCPUTest : public testing::WithParamInterface<RemoveConvertCPUTestParams>,
virtual public SubgraphBaseTest, virtual public SubgraphBaseTest,
public CPUTestsBase { public CPUTestsBase {
public: public:
static std::string getTestCaseName(const testing::TestParamInfo<RemoveConvertCPUTestParams>& obj) { static std::string getTestCaseName(const testing::TestParamInfo<RemoveConvertCPUTestParams>& obj) {
ElementType inType; ElementType inType;
@ -44,9 +40,9 @@ public:
init_input_shapes({inputShape}); init_input_shapes({inputShape});
auto input_params = std::make_shared<ov::op::v0::Parameter>(inType, inputShape.first); auto input_params = std::make_shared<ov::op::v0::Parameter>(inType, inputShape.first);
auto convert = std::make_shared<ov::op::v0::Convert>(input_params, element::f32); auto convert = std::make_shared<ov::op::v0::Convert>(input_params, element::f32);
auto begin = builder::makeConstant(element::i64, ov::Shape{4}, std::vector<int64_t>{0, 0, 0, 0}); auto begin = ngraph::builder::makeConstant(element::i64, ov::Shape{4}, std::vector<int64_t>{0, 0, 0, 0});
auto end = builder::makeConstant(element::i64, ov::Shape{4}, std::vector<int64_t>{0, 0, 16, 0}); auto end = ngraph::builder::makeConstant(element::i64, ov::Shape{4}, std::vector<int64_t>{0, 0, 16, 0});
auto stride = builder::makeConstant(element::i64, ov::Shape{4}, std::vector<int64_t>{1, 1, 1, 1}); auto stride = ngraph::builder::makeConstant(element::i64, ov::Shape{4}, std::vector<int64_t>{1, 1, 1, 1});
auto slice = std::make_shared<ov::op::v1::StridedSlice>(convert, auto slice = std::make_shared<ov::op::v1::StridedSlice>(convert,
begin, begin,
end, end,
@ -84,17 +80,19 @@ public:
init_input_shapes({inputShape}); init_input_shapes({inputShape});
auto input_params = std::make_shared<ov::op::v0::Parameter>(inType, inputShape.first); auto input_params = std::make_shared<ov::op::v0::Parameter>(inType, inputShape.first);
// Such complicated graph is necessary to cover the case when Convert has several children and connected to non zero output // Such complicated graph is necessary to cover the case when Convert has several children and connected to non
const auto split_axis = builder::makeConstant(element::i64, ov::Shape{}, std::vector<int64_t>{1}); // zero output
const auto split_lengths = builder::makeConstant(element::i64, ov::Shape{2}, std::vector<int64_t>{-1, 1}); const auto split_axis = ngraph::builder::makeConstant(element::i64, ov::Shape{}, std::vector<int64_t>{1});
const auto split = std::make_shared<ov::opset10::VariadicSplit>(input_params, split_axis, split_lengths); const auto split_lengths =
ngraph::builder::makeConstant(element::i64, ov::Shape{2}, std::vector<int64_t>{-1, 1});
const auto split = std::make_shared<ov::op::v1::VariadicSplit>(input_params, split_axis, split_lengths);
auto convert = std::make_shared<ov::op::v0::Convert>(split->output(1), inType); auto convert = std::make_shared<ov::op::v0::Convert>(split->output(1), inType);
auto relu = builder::makeActivation(convert, inType, ::helpers::ActivationTypes::Relu); auto relu = ov::test::utils::make_activation(convert, inType, ov::test::utils::ActivationTypes::Relu);
ov::ResultVector results{ ov::ResultVector results{
std::make_shared<ov::opset10::Result>(split->output(0)), std::make_shared<ov::op::v0::Result>(split->output(0)),
std::make_shared<ov::opset10::Result>(convert), std::make_shared<ov::op::v0::Result>(convert),
std::make_shared<ov::opset10::Result>(relu), std::make_shared<ov::op::v0::Result>(relu),
}; };
function = std::make_shared<ov::Model>(results, ov::ParameterVector{input_params}, "remove_convert"); function = std::make_shared<ov::Model>(results, ov::ParameterVector{input_params}, "remove_convert");
@ -131,4 +129,5 @@ INSTANTIATE_TEST_SUITE_P(smoke_RemoveConvert,
::testing::Combine(::testing::Values(ElementType::f32), ::testing::Values(inputShapes[0])), ::testing::Combine(::testing::Values(ElementType::f32), ::testing::Values(inputShapes[0])),
RemoveUselessConvertCPUTest::getTestCaseName); RemoveUselessConvertCPUTest::getTestCaseName);
} // namespace } // namespace
} // namespace SubgraphTestsDefinitions } // namespace test
} // namespace ov