[CPU Plugin][Func Test] Upgrade reshape related to API 2.0 (#21361)

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

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 review comments

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-01 13:53:51 +04:00
committed by GitHub
parent 27adf58220
commit 0e2bde2397
8 changed files with 82 additions and 92 deletions
@@ -2,15 +2,13 @@
// SPDX-License-Identifier: Apache-2.0
//
#include <shared_test_classes/base/ov_subgraph.hpp>
#include <ov_models/builders.hpp>
#include <openvino/pass/serialize.hpp>
#include "common_test_utils/common_utils.hpp"
#include "functional_test_utils/skip_tests_config.hpp"
#include "ov_models/builders.hpp"
#include "shared_test_classes/base/ov_subgraph.hpp"
using namespace ov::test;
namespace SubgraphTestsDefinitions {
namespace ov {
namespace test {
class ReshapeChain : public SubgraphBaseTest {
void SetUp() override {
@@ -19,23 +17,23 @@ class ReshapeChain : public SubgraphBaseTest {
InputShape inputShapes{{-1, -1, -1, -1}, {{10, 20, 30, 40}, {16, 24, 16, 24}, {4, 8, 12, 16}}};
init_input_shapes({inputShapes});
auto ngPrc = ngraph::element::f32;
const auto secondInPrc = ngraph::element::Type_t::i32;
auto ngPrc = ov::element::f32;
const auto secondInPrc = ov::element::Type_t::i32;
ov::ParameterVector inputParams;
for (auto&& shape : inputDynamicShapes) {
inputParams.push_back(std::make_shared<ov::op::v0::Parameter>(ngPrc, shape));
}
auto reshapeParam1 = ngraph::builder::makeConstant<int>(secondInPrc, {3}, {0, 0, -1});
auto reshape1 = std::make_shared<ngraph::opset1::Reshape>(inputParams.front(), reshapeParam1, true);
auto reshape1 = std::make_shared<ov::op::v1::Reshape>(inputParams.front(), reshapeParam1, true);
auto reshapeParam2 = ngraph::builder::makeConstant<int>(secondInPrc, {2}, {0, -1});
auto reshape2 = std::make_shared<ngraph::opset1::Reshape>(reshape1, reshapeParam2, true);
auto reshape2 = std::make_shared<ov::op::v1::Reshape>(reshape1, reshapeParam2, true);
auto reshapeParam3 = ngraph::builder::makeConstant<int>(secondInPrc, {1}, {-1});
auto reshape3 = std::make_shared<ngraph::opset1::Reshape>(reshape2, reshapeParam3, true);
auto reshape3 = std::make_shared<ov::op::v1::Reshape>(reshape2, reshapeParam3, true);
auto reshapeParam4 = ngraph::builder::makeConstant<int>(secondInPrc, {2}, {4, -1});
auto reshape4 = std::make_shared<ngraph::opset1::Reshape>(reshape3, reshapeParam4, true);
auto reshape4 = std::make_shared<ov::op::v1::Reshape>(reshape3, reshapeParam4, true);
ngraph::ResultVector results{std::make_shared<ngraph::opset3::Result>(reshape4)};
function = std::make_shared<ngraph::Function>(results, inputParams, "reshapeChain");
ov::ResultVector results{std::make_shared<ov::op::v0::Result>(reshape4)};
function = std::make_shared<ov::Model>(results, inputParams, "reshapeChain");
}
};
@@ -43,4 +41,5 @@ TEST_F(ReshapeChain, smoke_ReshapeChain) {
run();
}
} // namespace SubgraphTestsDefinitions
} // namespace test
} // namespace ov
@@ -2,25 +2,25 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "shared_test_classes/base/ov_subgraph.hpp"
#include <common_test_utils/ov_tensor_utils.hpp>
#include "ov_models/builders.hpp"
#include "shared_test_classes/base/ov_subgraph.hpp"
#include "test_utils/fusing_test_utils.hpp"
using namespace CPUTestUtils;
using namespace ov::test;
namespace ov {
namespace test {
namespace CPULayerTestsDefinitions {
using ReshapeFcSpecParams = std::tuple<std::vector<InputShape>, // input shapes
std::vector<int>, // reshape data
ElementType>; // precision
using ReshapeFcSpecParams = std::tuple<std::vector<InputShape>, // input shapes
std::vector<int>, // reshape data
ElementType>; // precision
using ReshapeFcParams = std::tuple<ReshapeFcSpecParams, fusingSpecificParams, CPUSpecificParams>;
using ReshapeFcParams = std::tuple<ReshapeFcSpecParams,
fusingSpecificParams,
CPUSpecificParams>;
class ReshapeFcCPUTest : public testing::WithParamInterface<ReshapeFcParams>, virtual public SubgraphBaseTest, public CpuTestWithFusing {
class ReshapeFcCPUTest : public testing::WithParamInterface<ReshapeFcParams>,
virtual public SubgraphBaseTest,
public CpuTestWithFusing {
public:
static std::string getTestCaseName(testing::TestParamInfo<ReshapeFcParams> obj) {
std::vector<InputShape> shapes;
@@ -51,7 +51,8 @@ public:
}
result << ")_";
}
result << "DATA=" << "[" << ov::test::utils::vec2str(data) << "]_";
result << "DATA="
<< "[" << ov::test::utils::vec2str(data) << "]_";
result << "PRC=" << prc << "_";
result << CpuTestWithFusing::getTestCaseName(fusingParams);
@@ -83,7 +84,7 @@ protected:
ov::ParameterVector params{std::make_shared<ov::op::v0::Parameter>(prc, inputDynamicShapes.front())};
auto reshapeData = ngraph::builder::makeConstant(ElementType::i32, {data.size()}, data);
auto reshape = std::make_shared<ngraph::opset1::Reshape>(params[0], reshapeData, true);
auto reshape = std::make_shared<ov::op::v1::Reshape>(params[0], reshapeData, true);
auto tensor = ov::test::utils::create_and_fill_tensor(prc, inputDynamicShapes.back().to_shape());
auto weight = std::make_shared<ov::op::v0::Constant>(tensor);
@@ -94,20 +95,14 @@ protected:
};
TEST_P(ReshapeFcCPUTest, CompareWithRefs) {
run();
CheckPluginRelatedResults(compiledModel, "FullyConnected");
run();
CheckPluginRelatedResults(compiledModel, "FullyConnected");
}
const std::vector<ReshapeFcSpecParams> reshFcParams = {
ReshapeFcSpecParams{
{
{{{1, 10}, 160}, {{1, 160}, {1, 160}, {5, 160}, {2, 160}}},
{{32, 3}, {{32, 3}, {32, 3}, {32, 3}, {32, 3}}}
},
std::vector<int>{-1, 5, 32},
ElementType::f32
}
};
const std::vector<ReshapeFcSpecParams> reshFcParams = {ReshapeFcSpecParams{
{{{{1, 10}, 160}, {{1, 160}, {1, 160}, {5, 160}, {2, 160}}}, {{32, 3}, {{32, 3}, {32, 3}, {32, 3}, {32, 3}}}},
std::vector<int>{-1, 5, 32},
ElementType::f32}};
static std::vector<fusingSpecificParams> filterFusingParams(const std::vector<fusingSpecificParams>& orig) {
#ifdef OV_CPU_WITH_MLAS
@@ -117,22 +112,18 @@ static std::vector<fusingSpecificParams> filterFusingParams(const std::vector<fu
#endif
}
std::vector<fusingSpecificParams> fusingParamsSet {
emptyFusingSpec,
fusingBias,
fusingMultiplyPerChannel
};
std::vector<fusingSpecificParams> fusingParamsSet{emptyFusingSpec, fusingBias, fusingMultiplyPerChannel};
#ifdef OV_CPU_WITH_MLAS
const auto gemmParam = CPUSpecificParams{{}, {}, {"gemm_mlas"}, "gemm_mlas"};
#else
const auto gemmParam = CPUSpecificParams{{}, {}, {"jit_gemm"}, "jit_gemm"};
#endif
const auto params = ::testing::Combine(
::testing::ValuesIn(reshFcParams),
::testing::ValuesIn(filterFusingParams(fusingParamsSet)),
::testing::Values(gemmParam));
const auto params = ::testing::Combine(::testing::ValuesIn(reshFcParams),
::testing::ValuesIn(filterFusingParams(fusingParamsSet)),
::testing::Values(gemmParam));
INSTANTIATE_TEST_SUITE_P(smoke_ReshapeFc, ReshapeFcCPUTest, params, ReshapeFcCPUTest::getTestCaseName);
} // namespace CPULayerTestsDefinitions
} // namespace test
} // namespace ov
@@ -2,16 +2,13 @@
// SPDX-License-Identifier: Apache-2.0
//
#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/layer_test_utils.hpp"
#include "shared_test_classes/base/ov_subgraph.hpp"
using namespace InferenceEngine;
using namespace ov::test;
namespace SubgraphTestsDefinitions {
namespace ov {
namespace test {
// Subgraph:
/*
* params[0] params[1]
@@ -49,8 +46,8 @@ protected:
auto c = ngraph::builder::makeConstant<float>(rtPrc, {}, {1.0f});
auto broadcast = std::make_shared<ov::op::v3::Broadcast>(c, shape);
auto reshape = std::make_shared<ov::op::v1::Reshape>(broadcast, params[1], false);
ov::ResultVector results{std::make_shared<ngraph::opset1::Result>(reshape->output(0))};
function = std::make_shared<ngraph::Function>(results, params, "reshape_check");
ov::ResultVector results{std::make_shared<ov::op::v0::Result>(reshape->output(0))};
function = std::make_shared<ov::Model>(results, params, "reshape_check");
}
void generate_inputs(const std::vector<ov::Shape>& targetInputStaticShapes) override {
inputs.clear();
@@ -84,4 +81,5 @@ protected:
TEST_F(InPlaceReshapeFromConstantCheck, smoke_CPU_InPlaceReshapeFromConstantCheck) {
run();
}
} // namespace SubgraphTestsDefinitions
} // namespace test
} // namespace ov
@@ -2,26 +2,28 @@
// SPDX-License-Identifier: Apache-2.0
//
#include <vector>
#include "subgraph_tests/reshape_permute_conv_permute_reshape_act.hpp"
#include <vector>
#include "common_test_utils/test_constants.hpp"
namespace ov {
namespace test {
namespace {
using ov::test::ConvReshapeAct;
std::vector<std::array<size_t, 4>> input_shapes {
std::vector<std::array<size_t, 4>> input_shapes{
{1, 1, 166, 2},
{1, 1, 144, 2},
{1, 1, 288, 2},
{1, 1, 144, 4},
};
std::vector<std::array<size_t, 2>> kernel_shapes {
std::vector<std::array<size_t, 2>> kernel_shapes{
{1, 7},
{1, 15},
};
std::vector<size_t> output_channels {
std::vector<size_t> output_channels{
16,
8,
4,
@@ -32,16 +34,17 @@ std::vector<ov::element::Type> model_types = {
ov::element::f16,
};
std::map<std::string, std::string> additional_config = { };
ov::AnyMap additional_config = {};
INSTANTIATE_TEST_SUITE_P(smoke_basic, ConvReshapeAct,
::testing::Combine(
::testing::ValuesIn(model_types),
::testing::Values(ov::test::utils::DEVICE_CPU),
::testing::ValuesIn(input_shapes),
::testing::ValuesIn(kernel_shapes),
::testing::ValuesIn(output_channels),
::testing::Values(additional_config)),
ConvReshapeAct::getTestCaseName);
} // namespace
INSTANTIATE_TEST_SUITE_P(smoke_basic,
ConvReshapeAct,
::testing::Combine(::testing::ValuesIn(model_types),
::testing::Values(ov::test::utils::DEVICE_CPU),
::testing::ValuesIn(input_shapes),
::testing::ValuesIn(kernel_shapes),
::testing::ValuesIn(output_channels),
::testing::Values(additional_config)),
ConvReshapeAct::getTestCaseName);
} // namespace
} // namespace test
} // namespace ov
@@ -33,9 +33,8 @@ std::vector<ov::element::Type> model_types = {
ov::element::f32,
};
std::vector<std::map<std::string, std::string>> configs = {
{{"GNA_DEVICE_MODE", "GNA_SW_EXACT"}, {"GNA_SCALE_FACTOR_0", "2340"}},
{{"GNA_DEVICE_MODE", "GNA_SW_FP32"}}};
std::vector<ov::AnyMap> configs = {{{"GNA_DEVICE_MODE", "GNA_SW_EXACT"}, {"GNA_SCALE_FACTOR_0", "2340"}},
{{"GNA_DEVICE_MODE", "GNA_SW_FP32"}}};
INSTANTIATE_TEST_SUITE_P(smoke_basic,
ConvReshapeAct,
@@ -32,7 +32,7 @@ std::vector<ov::element::Type> model_types = {
ov::element::f16,
};
std::map<std::string, std::string> additional_config = {};
ov::AnyMap additional_config = {};
INSTANTIATE_TEST_SUITE_P(smoke_basic, ConvReshapeAct,
::testing::Combine(
@@ -15,14 +15,14 @@
namespace ov {
namespace test {
typedef std::tuple<
ov::element::Type, // Network Type
std::string, // Target Device
std::array<size_t, 4>, // Input shape
std::array<size_t, 2>, // Kernel shape
size_t, // Output channels
std::map<std::string, std::string> // Configuration
> ConvReshapeActParams;
typedef std::tuple<ov::element::Type, // Network Type
std::string, // Target Device
std::array<size_t, 4>, // Input shape
std::array<size_t, 2>, // Kernel shape
size_t, // Output channels
ov::AnyMap // Configuration
>
ConvReshapeActParams;
class ConvReshapeAct : public testing::WithParamInterface<ConvReshapeActParams>,
virtual public ov::test::SubgraphBaseStaticTest {
@@ -13,7 +13,7 @@ std::string ConvReshapeAct::getTestCaseName(const testing::TestParamInfo<ConvRes
std::array<size_t, 4> input_shape;
std::array<size_t, 2> kernel_shape;
size_t output_channels;
std::map<std::string, std::string> configuration;
ov::AnyMap configuration;
std::tie(model_type, targetName, input_shape, kernel_shape, output_channels, configuration) = obj.param;
@@ -25,7 +25,7 @@ std::string ConvReshapeAct::getTestCaseName(const testing::TestParamInfo<ConvRes
results << "netPRC=" << model_type.get_type_name() << "_";
results << "targetDevice=" << targetName;
for (auto const& configItem : configuration) {
results << "_configItem=" << configItem.first << "_" << configItem.second;
results << "_configItem=" << configItem.first << "_" << configItem.second.as<std::string>();
}
return results.str();
}
@@ -35,7 +35,7 @@ void ConvReshapeAct::SetUp() {
std::array<size_t, 4> input_shape;
std::array<size_t, 2> kernel_shape;
size_t output_channels;
std::map<std::string, std::string> additional_config;
ov::AnyMap additional_config;
std::tie(model_type, targetDevice, input_shape, kernel_shape, output_channels, additional_config) = this->GetParam();