[Func Test] Upgrade func test of QuantGroupConvLayerTest related to 2.0 (#21092)
Signed-off-by: Zhai, Xuejun <xuejun.zhai@intel.com>
This commit is contained in:
parent
7e5f491459
commit
6755a7e3a8
@ -7,14 +7,11 @@
|
||||
#include "subgraph_tests/quantized_group_convolution.hpp"
|
||||
#include "common_test_utils/test_constants.hpp"
|
||||
|
||||
using namespace SubgraphTestsDefinitions;
|
||||
using namespace ov::test;
|
||||
|
||||
namespace {
|
||||
|
||||
const std::vector<InferenceEngine::Precision> netPrecisions = {
|
||||
InferenceEngine::Precision::FP32
|
||||
};
|
||||
|
||||
const std::vector<ov::element::Type> netPrecisions = {ov::element::f32};
|
||||
|
||||
const std::vector<size_t> numOutChannels = {3, 24, 48};
|
||||
const std::vector<size_t> numGroups = {3};
|
||||
@ -26,12 +23,12 @@ const std::vector<ov::test::utils::QuantizationGranularity> granularity = {
|
||||
const std::vector<bool> quantizeWeights = {false, true};
|
||||
|
||||
/* ============= 2D GroupConvolution ============= */
|
||||
const std::vector<std::vector<size_t >> inputShapes2D = {{1, 3, 10, 10}, {1, 24, 10, 10}};
|
||||
const std::vector<std::vector<size_t >> kernels2D = {{1, 1}, {3, 3}};
|
||||
const std::vector<std::vector<size_t >> strides2D = {{1, 1}};
|
||||
const std::vector<ov::Shape> inputShapes2D = {{1, 3, 10, 10}, {1, 24, 10, 10}};
|
||||
const std::vector<ov::Shape> kernels2D = {{1, 1}, {3, 3}};
|
||||
const std::vector<ov::Shape> strides2D = {{1, 1}};
|
||||
const std::vector<std::vector<ptrdiff_t>> padBegins2D = {{0, 0}};
|
||||
const std::vector<std::vector<ptrdiff_t>> padEnds2D = {{0, 0}};
|
||||
const std::vector<std::vector<size_t >> dilations2D = {{1, 1}};
|
||||
const std::vector<ov::Shape> dilations2D = {{1, 1}};
|
||||
|
||||
|
||||
const auto quantGroupConv2DParams = ::testing::Combine(
|
||||
@ -56,12 +53,12 @@ INSTANTIATE_TEST_SUITE_P(smoke_QuantGroupConv2D, QuantGroupConvLayerTest,
|
||||
QuantGroupConvLayerTest::getTestCaseName);
|
||||
|
||||
/* ============= 3D GroupConvolution ============= */
|
||||
const std::vector<std::vector<size_t >> inputShapes3D = {{1, 3, 5, 5, 5}, {1, 24, 5, 5, 5}};
|
||||
const std::vector<std::vector<size_t >> kernels3D = {{3, 3, 3}};
|
||||
const std::vector<std::vector<size_t >> strides3D = {{1, 1, 1}};
|
||||
const std::vector<ov::Shape> inputShapes3D = {{1, 3, 5, 5, 5}, {1, 24, 5, 5, 5}};
|
||||
const std::vector<ov::Shape> kernels3D = {{3, 3, 3}};
|
||||
const std::vector<ov::Shape> strides3D = {{1, 1, 1}};
|
||||
const std::vector<std::vector<ptrdiff_t>> padBegins3D = {{0, 0, 0}};
|
||||
const std::vector<std::vector<ptrdiff_t>> padEnds3D = {{0, 0, 0}};
|
||||
const std::vector<std::vector<size_t >> dilations3D = {{1, 1, 1}};
|
||||
const std::vector<ov::Shape> dilations3D = {{1, 1, 1}};
|
||||
|
||||
const auto quantGroupConv3DParams = ::testing::Combine(
|
||||
::testing::ValuesIn(kernels3D),
|
||||
|
@ -6,10 +6,12 @@
|
||||
|
||||
#include "shared_test_classes/subgraph/quantized_group_convolution.hpp"
|
||||
|
||||
namespace SubgraphTestsDefinitions {
|
||||
namespace ov {
|
||||
namespace test {
|
||||
|
||||
TEST_P(QuantGroupConvLayerTest, CompareWithRefs) {
|
||||
Run();
|
||||
run();
|
||||
}
|
||||
|
||||
} // namespace SubgraphTestsDefinitions
|
||||
} // namespace test
|
||||
} // namespace ov
|
||||
|
@ -9,18 +9,18 @@
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
#include "shared_test_classes/base/layer_test_utils.hpp"
|
||||
#include "ov_models/builders.hpp"
|
||||
#include "ov_models/utils/ov_helpers.hpp"
|
||||
#include "common_test_utils/test_enums.hpp"
|
||||
#include "shared_test_classes/base/ov_subgraph.hpp"
|
||||
|
||||
namespace SubgraphTestsDefinitions {
|
||||
namespace ov {
|
||||
namespace test {
|
||||
|
||||
typedef std::tuple<
|
||||
InferenceEngine::SizeVector,
|
||||
InferenceEngine::SizeVector,
|
||||
ov::Shape,
|
||||
ov::Shape,
|
||||
std::vector<ptrdiff_t>,
|
||||
std::vector<ptrdiff_t>,
|
||||
InferenceEngine::SizeVector,
|
||||
ov::Shape,
|
||||
size_t,
|
||||
size_t,
|
||||
size_t,
|
||||
@ -28,12 +28,12 @@ typedef std::tuple<
|
||||
bool> quantGroupConvSpecificParams;
|
||||
typedef std::tuple<
|
||||
quantGroupConvSpecificParams,
|
||||
InferenceEngine::Precision,
|
||||
InferenceEngine::SizeVector,
|
||||
LayerTestsUtils::TargetDevice> quantGroupConvLayerTestParamsSet;
|
||||
ov::element::Type,
|
||||
ov::Shape,
|
||||
std::string> quantGroupConvLayerTestParamsSet;
|
||||
|
||||
class QuantGroupConvLayerTest : public testing::WithParamInterface<quantGroupConvLayerTestParamsSet>,
|
||||
virtual public LayerTestsUtils::LayerTestsCommon {
|
||||
virtual public ov::test::SubgraphBaseStaticTest {
|
||||
public:
|
||||
static std::string getTestCaseName(const testing::TestParamInfo<quantGroupConvLayerTestParamsSet>& obj);
|
||||
|
||||
@ -41,4 +41,5 @@ protected:
|
||||
void SetUp() override;
|
||||
};
|
||||
|
||||
} // namespace SubgraphTestsDefinitions
|
||||
} // namespace test
|
||||
} // namespace ov
|
||||
|
@ -3,17 +3,20 @@
|
||||
//
|
||||
|
||||
#include "shared_test_classes/subgraph/quantized_group_convolution.hpp"
|
||||
#include "ov_models/builders.hpp"
|
||||
#include "ov_models/utils/ov_helpers.hpp"
|
||||
|
||||
namespace SubgraphTestsDefinitions {
|
||||
namespace ov {
|
||||
namespace test {
|
||||
|
||||
std::string QuantGroupConvLayerTest::getTestCaseName(const testing::TestParamInfo<quantGroupConvLayerTestParamsSet>& obj) {
|
||||
quantGroupConvSpecificParams groupConvParams;
|
||||
InferenceEngine::Precision netPrecision;
|
||||
InferenceEngine::SizeVector inputShapes;
|
||||
ov::element::Type element_type;
|
||||
ov::Shape inputShapes;
|
||||
std::string targetDevice;
|
||||
std::tie(groupConvParams, netPrecision, inputShapes, targetDevice) = obj.param;
|
||||
ngraph::op::PadType padType = ngraph::op::PadType::AUTO;
|
||||
InferenceEngine::SizeVector kernel, stride, dilation;
|
||||
std::tie(groupConvParams, element_type, inputShapes, targetDevice) = obj.param;
|
||||
ov::op::PadType padType = ov::op::PadType::AUTO;
|
||||
ov::Shape kernel, stride, dilation;
|
||||
std::vector<ptrdiff_t> padBegin, padEnd;
|
||||
size_t convOutChannels, numGroups;
|
||||
size_t quantLevels;
|
||||
@ -34,33 +37,30 @@ std::string QuantGroupConvLayerTest::getTestCaseName(const testing::TestParamInf
|
||||
result << "Levels=" << quantLevels << "_";
|
||||
result << "QG=" << quantGranularity << "_";
|
||||
result << "QW=" << quantizeWeights << "_";
|
||||
result << "netPRC=" << netPrecision.name() << "_";
|
||||
result << "ET=" << element_type.get_type_name() << "_";
|
||||
result << "targetDevice=" << targetDevice;
|
||||
return result.str();
|
||||
}
|
||||
|
||||
void QuantGroupConvLayerTest::SetUp() {
|
||||
threshold = 0.5f;
|
||||
|
||||
quantGroupConvSpecificParams groupConvParams;
|
||||
std::vector<size_t> inputShape;
|
||||
auto netPrecision = InferenceEngine::Precision::UNSPECIFIED;
|
||||
std::tie(groupConvParams, netPrecision, inputShape, targetDevice) = this->GetParam();
|
||||
ngraph::op::PadType padType = ngraph::op::PadType::AUTO;
|
||||
InferenceEngine::SizeVector kernel, stride, dilation;
|
||||
ov::Shape inputShape;
|
||||
ov::element::Type element_type = ov::element::undefined;
|
||||
std::tie(groupConvParams, element_type, inputShape, targetDevice) = this->GetParam();
|
||||
ov::op::PadType padType = ov::op::PadType::AUTO;
|
||||
ov::Shape kernel, stride, dilation;
|
||||
std::vector<ptrdiff_t> padBegin, padEnd;
|
||||
size_t convOutChannels, numGroups;
|
||||
size_t quantLevels;
|
||||
ov::test::utils::QuantizationGranularity quantGranularity;
|
||||
bool quantizeWeights;
|
||||
std::tie(kernel, stride, padBegin, padEnd, dilation, convOutChannels, numGroups, quantLevels, quantGranularity, quantizeWeights) = groupConvParams;
|
||||
auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision);
|
||||
ov::ParameterVector params{std::make_shared<ov::op::v0::Parameter>(ngPrc, ov::Shape(inputShape))};
|
||||
ov::ParameterVector params{std::make_shared<ov::op::v0::Parameter>(element_type, ov::Shape(inputShape))};
|
||||
|
||||
std::vector<size_t> dataFqConstShapes(inputShape.size(), 1);
|
||||
if (quantGranularity == ov::test::utils::QuantizationGranularity::Perchannel)
|
||||
dataFqConstShapes[1] = inputShape[1];
|
||||
auto dataFq = ngraph::builder::makeFakeQuantize(params[0], ngPrc, quantLevels, dataFqConstShapes);
|
||||
auto dataFq = ngraph::builder::makeFakeQuantize(params[0], element_type, quantLevels, dataFqConstShapes);
|
||||
|
||||
std::vector<size_t> weightsShapes = {convOutChannels, inputShape[1]};
|
||||
if (weightsShapes[0] % numGroups || weightsShapes[1] % numGroups)
|
||||
@ -71,23 +71,24 @@ void QuantGroupConvLayerTest::SetUp() {
|
||||
weightsShapes.insert(weightsShapes.end(), kernel.begin(), kernel.end());
|
||||
|
||||
std::vector<float> weightsData;
|
||||
auto weightsNode = ngraph::builder::makeConstant(ngPrc, weightsShapes, weightsData, weightsData.empty());
|
||||
auto weightsNode = ngraph::builder::makeConstant(element_type, weightsShapes, weightsData, weightsData.empty());
|
||||
|
||||
std::vector<size_t> weightsFqConstShapes(weightsShapes.size(), 1);
|
||||
if (quantGranularity == ov::test::utils::QuantizationGranularity::Perchannel)
|
||||
weightsFqConstShapes[0] = weightsShapes[0];
|
||||
|
||||
std::shared_ptr<ngraph::Node> weights;
|
||||
std::shared_ptr<ov::Node> weights;
|
||||
if (quantizeWeights) {
|
||||
weights = ngraph::builder::makeFakeQuantize(weightsNode, ngPrc, quantLevels, weightsFqConstShapes);
|
||||
weights = ngraph::builder::makeFakeQuantize(weightsNode, element_type, quantLevels, weightsFqConstShapes);
|
||||
} else {
|
||||
weights = weightsNode;
|
||||
}
|
||||
|
||||
auto groupConv = std::dynamic_pointer_cast<ngraph::opset1::GroupConvolution>(
|
||||
ngraph::builder::makeGroupConvolution(dataFq, weights, ngPrc, stride, padBegin, padEnd, dilation, padType));
|
||||
auto groupConv = std::dynamic_pointer_cast<ov::op::v1::GroupConvolution>(
|
||||
ngraph::builder::makeGroupConvolution(dataFq, weights, element_type, stride, padBegin, padEnd, dilation, padType));
|
||||
|
||||
ngraph::ResultVector results{std::make_shared<ngraph::opset1::Result>(groupConv)};
|
||||
function = std::make_shared<ngraph::Function>(results, params, "QuantGroupConvolution");
|
||||
ov::ResultVector results{std::make_shared<ov::op::v0::Result>(groupConv)};
|
||||
function = std::make_shared<ov::Model>(results, params, "QuantGroupConvolution");
|
||||
}
|
||||
} // namespace SubgraphTestsDefinitions
|
||||
} // namespace test
|
||||
} // namespace ov
|
||||
|
Loading…
Reference in New Issue
Block a user