[CPU Plugin][Func Test] Upgrade Fuse related to API 2.0 (#21359)

* [CPU Plugin][Func Test] Upgrade Fuse related to API 2.0

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

* Update src/plugins/intel_cpu/tests/functional/subgraph_tests/src/fuse_non0_output_port.cpp

Co-authored-by: River Li <river.li@intel.com>

---------

Signed-off-by: Zhai, Xuejun <xuejun.zhai@intel.com>
Co-authored-by: River Li <river.li@intel.com>
This commit is contained in:
Xuejun Zhai 2023-11-29 18:43:10 +08:00 committed by GitHub
parent 2b14ea97fc
commit a6ea22ad0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 74 additions and 61 deletions

View File

@ -5,15 +5,11 @@
#include "ov_lpt_models/markup_bias.hpp"
#include "ov_models/builders.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 "test_utils/cpu_test_utils.hpp"
#include "test_utils/fusing_test_utils.hpp"
using namespace ngraph;
using namespace ov::test;
using namespace CPUTestUtils;
using namespace InferenceEngine;
/*
* This class tests the order in which biases and dequantization scales are fused to the target operation
@ -28,7 +24,9 @@ using namespace InferenceEngine;
* Result
*/
namespace SubgraphTestsDefinitions {
namespace ov {
namespace test {
using FQLayerDQBiasParams = std::tuple<InputShape, std::string, bool>;
class FQLayerDQBias : virtual public SubgraphBaseTest,
@ -73,7 +71,11 @@ protected:
const auto shapes = layer_type == "MatMul" ? std::vector<InputShape>{input_shape, input_shape}
: std::vector<InputShape>{input_shape};
init_input_shapes(shapes);
function = ngraph::builder::subgraph::MarkupBiasFunction::get(ov::element::f32, inputDynamicShapes[0], {}, layer_type, extra_multiply);
function = ngraph::builder::subgraph::MarkupBiasFunction::get(ov::element::f32,
inputDynamicShapes[0],
{},
layer_type,
extra_multiply);
}
std::string node_type;
@ -85,10 +87,7 @@ TEST_P(FQLayerDQBias, smoke_CompareWithRefs) {
}
namespace {
const std::vector<InputShape> input_shapes_4D_static = {
{{}, {{1, 3, 1, 1}}},
{{}, {{1, 3, 64, 64}}}
};
const std::vector<InputShape> input_shapes_4D_static = {{{}, {{1, 3, 1, 1}}}, {{}, {{1, 3, 64, 64}}}};
const std::vector<std::string> layer_types_4D_static = {
"Convolution",
@ -97,15 +96,14 @@ const std::vector<std::string> layer_types_4D_static = {
"MatMul",
};
INSTANTIATE_TEST_SUITE_P(smoke_FQLayerDQBias_4D_static, FQLayerDQBias,
INSTANTIATE_TEST_SUITE_P(smoke_FQLayerDQBias_4D_static,
FQLayerDQBias,
::testing::Combine(::testing::ValuesIn(input_shapes_4D_static),
::testing::ValuesIn(layer_types_4D_static),
::testing::Values(false)),
FQLayerDQBias::getTestCaseName);
const std::vector<InputShape> input_shapes_4D_dynamic = {
{{-1, 3, -1, -1}, {{1, 3, 64, 64}}}
};
const std::vector<InputShape> input_shapes_4D_dynamic = {{{-1, 3, -1, -1}, {{1, 3, 64, 64}}}};
const std::vector<std::string> layer_types_4D_dynamic = {
"Convolution",
@ -113,30 +111,32 @@ const std::vector<std::string> layer_types_4D_dynamic = {
"MatMul",
};
INSTANTIATE_TEST_SUITE_P(smoke_FQLayerDQBias_4D_dynamic, FQLayerDQBias,
INSTANTIATE_TEST_SUITE_P(smoke_FQLayerDQBias_4D_dynamic,
FQLayerDQBias,
::testing::Combine(::testing::ValuesIn(input_shapes_4D_dynamic),
::testing::ValuesIn(layer_types_4D_dynamic),
::testing::Values(false)),
FQLayerDQBias::getTestCaseName);
const std::vector<InputShape> input_shapes_2D = {
{{-1, 768}, {{1, 768}}}
};
const std::vector<InputShape> input_shapes_2D = {{{-1, 768}, {{1, 768}}}};
const std::vector<std::string> layer_types_2D = {
"MatMulWithConstant",
};
INSTANTIATE_TEST_SUITE_P(smoke_FQLayerDQBias_2D, FQLayerDQBias,
INSTANTIATE_TEST_SUITE_P(smoke_FQLayerDQBias_2D,
FQLayerDQBias,
::testing::Combine(::testing::ValuesIn(input_shapes_2D),
::testing::ValuesIn(layer_types_2D),
::testing::Values(false)),
FQLayerDQBias::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_FQLayerDQExtraMultiplyAdd_2D, FQLayerDQBias,
INSTANTIATE_TEST_SUITE_P(smoke_FQLayerDQExtraMultiplyAdd_2D,
FQLayerDQBias,
::testing::Combine(::testing::ValuesIn(input_shapes_2D),
::testing::ValuesIn(layer_types_2D),
::testing::Values(false)),
FQLayerDQBias::getTestCaseName);
} // namespace
} // namespace SubgraphTestsDefinitions
} // namespace
} // namespace test
} // namespace ov

View File

@ -2,21 +2,18 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "common_test_utils/node_builders/convolution.hpp"
#include "ov_models/builders.hpp"
#include "ov_models/utils/ov_helpers.hpp"
#include "shared_test_classes/base/ov_subgraph.hpp"
#include "test_utils/cpu_test_utils.hpp"
#include "test_utils/fusing_test_utils.hpp"
#include "shared_test_classes/base/ov_subgraph.hpp"
#include "shared_test_classes/base/layer_test_utils.hpp"
#include "ov_models/utils/ov_helpers.hpp"
#include "ov_models/builders.hpp"
using namespace ngraph;
using namespace ov::test;
using namespace CPUTestUtils;
using namespace InferenceEngine;
namespace SubgraphTestsDefinitions {
class ConvAndFQWithSharedConstants : virtual public SubgraphBaseTest,
public CpuTestWithFusing {
namespace ov {
namespace test {
class ConvAndFQWithSharedConstants : virtual public SubgraphBaseTest, public CpuTestWithFusing {
public:
void SetUp() override {
targetDevice = ov::test::utils::DEVICE_CPU;
@ -27,13 +24,19 @@ public:
auto in_shapes = static_shapes_to_test_representation({input_static_shape});
init_input_shapes({in_shapes});
ov::ParameterVector input_params {std::make_shared<ov::op::v0::Parameter>(precision, ov::Shape(input_static_shape))};
ov::ParameterVector input_params{
std::make_shared<ov::op::v0::Parameter>(precision, ov::Shape(input_static_shape))};
auto shared_il = opset1::Constant::create(precision, {1, 1, 1, 1}, {0.f});
auto shared_ih = opset1::Constant::create(precision, {1, 1, 1, 1}, {12.5f});
auto shared_ol = opset1::Constant::create(precision, {1, 1, 1, 1}, {0.f});
auto shared_oh = opset1::Constant::create(precision, {1, 1, 1, 1}, {12.5f});
auto fq_before = std::make_shared<opset1::FakeQuantize>(input_params[0], shared_il, shared_ih, shared_ol, shared_oh, 256);
auto shared_il = ov::op::v0::Constant::create(precision, {1, 1, 1, 1}, {0.f});
auto shared_ih = ov::op::v0::Constant::create(precision, {1, 1, 1, 1}, {12.5f});
auto shared_ol = ov::op::v0::Constant::create(precision, {1, 1, 1, 1}, {0.f});
auto shared_oh = ov::op::v0::Constant::create(precision, {1, 1, 1, 1}, {12.5f});
auto fq_before = std::make_shared<ov::op::v0::FakeQuantize>(input_params[0],
shared_il,
shared_ih,
shared_ol,
shared_oh,
256);
std::shared_ptr<Node> conv;
{
@ -44,18 +47,28 @@ public:
const std::vector<size_t> dilation = {1, 1};
const size_t numOutChannels = 16;
const op::PadType paddingType = op::PadType::EXPLICIT;
conv = builder::makeConvolution(fq_before, precision, kernelSize, strides, padBegin, padEnd, dilation, paddingType, numOutChannels);
conv = ov::test::utils::make_convolution(fq_before,
precision,
kernelSize,
strides,
padBegin,
padEnd,
dilation,
paddingType,
numOutChannels);
}
auto fq_after = std::make_shared<opset1::FakeQuantize>(conv, shared_il, shared_ih, shared_ol, shared_oh, 256);
auto fq_after =
std::make_shared<ov::op::v0::FakeQuantize>(conv, shared_il, shared_ih, shared_ol, shared_oh, 256);
function = makeNgraphFunction(precision, input_params, fq_after, "ConvFQWithSharedContants");
}
};
namespace {
TEST_F(ConvAndFQWithSharedConstants, smoke_ConvAndFQWithSharedConstants_CPU) {
run();
CheckPluginRelatedResults(compiledModel, "Convolution");
}
} // namespace
} // namespace SubgraphTestsDefinitions
TEST_F(ConvAndFQWithSharedConstants, smoke_ConvAndFQWithSharedConstants_CPU) {
run();
CheckPluginRelatedResults(compiledModel, "Convolution");
}
} // namespace
} // namespace test
} // namespace ov

View File

@ -2,23 +2,22 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "shared_test_classes/base/layer_test_utils.hpp"
#include "shared_test_classes/base/ov_subgraph.hpp"
#include "ov_models/utils/ov_helpers.hpp"
#include "ov_models/builders.hpp"
#include "common_test_utils/ov_tensor_utils.hpp"
#include "ngraph/runtime/aligned_buffer.hpp"
#include <common_test_utils/ov_tensor_utils.hpp>
#include "ov_models/builders.hpp"
#include "ov_models/utils/ov_helpers.hpp"
#include "shared_test_classes/base/ov_subgraph.hpp"
using namespace ov::test;
namespace SubgraphTestsDefinitions {
namespace ov {
namespace test {
class FuseNon0OuputPort : public SubgraphBaseTest {
void SetUp() override {
const ov::Shape x_shape = {1, 10};
const ov::Shape y_shape = {1};
const ov::Shape z_shape = {1};
ngraph::ParameterVector params(3);
ov::ParameterVector params(3);
targetStaticShapes = {{x_shape, y_shape, z_shape}};
targetDevice = ov::test::utils::DEVICE_CPU;
params[0] = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, x_shape);
@ -27,14 +26,14 @@ class FuseNon0OuputPort : public SubgraphBaseTest {
// make a sub function
const auto cond = ov::op::v0::Constant::create(ov::element::boolean, {1}, {true});
ngraph::ParameterVector sub_params(3);
ov::ParameterVector sub_params(3);
sub_params[0] = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, x_shape);
sub_params[1] = std::make_shared<ov::op::v0::Parameter>(ov::element::i32, y_shape);
sub_params[2] = std::make_shared<ov::op::v0::Parameter>(ov::element::boolean, y_shape);
ngraph::ResultVector sub_results(3);
sub_results[0] = std::make_shared<ngraph::opset1::Result>(sub_params[0]);
sub_results[1] = std::make_shared<ngraph::opset1::Result>(sub_params[1]);
sub_results[2] = std::make_shared<ngraph::opset1::Result>(sub_params[2]);
ov::ResultVector sub_results(3);
sub_results[0] = std::make_shared<ov::op::v0::Result>(sub_params[0]);
sub_results[1] = std::make_shared<ov::op::v0::Result>(sub_params[1]);
sub_results[2] = std::make_shared<ov::op::v0::Result>(sub_params[2]);
const auto sub_model = std::make_shared<ov::Model>(sub_results, sub_params);
// loop ops
@ -61,4 +60,5 @@ TEST_F(FuseNon0OuputPort, smoke_FuseNon0OuputPort) {
run();
}
} // namespace SubgraphTestsDefinitions
} // namespace test
} // namespace ov