[Func Test] Upgrade func test of QuantConvBackpropDataLayerTest related to 2.0 (#21082)
Signed-off-by: Zhai, Xuejun <xuejun.zhai@intel.com>
This commit is contained in:
+16
-19
@@ -7,28 +7,25 @@
|
||||
#include "subgraph_tests/quantized_convolution_backprop_data.hpp"
|
||||
#include "common_test_utils/test_constants.hpp"
|
||||
|
||||
using namespace SubgraphTestsDefinitions;
|
||||
using namespace ngraph::helpers;
|
||||
using namespace ov::test;
|
||||
using namespace ov::test::utils;
|
||||
|
||||
namespace {
|
||||
|
||||
const std::vector<InferenceEngine::Precision> netPrecisions = {
|
||||
InferenceEngine::Precision::FP32
|
||||
};
|
||||
const std::vector<ov::element::Type> element_types = {ov::element::f32};
|
||||
|
||||
const std::vector<size_t> numOutChannels = {16, 32};
|
||||
|
||||
const std::vector<size_t > levels = {256};
|
||||
const std::vector<QuantizationGranularity > granularity = {QuantizationGranularity::Pertensor, QuantizationGranularity::Perchannel};
|
||||
const std::vector<size_t> levels = {256};
|
||||
const std::vector<QuantizationGranularity> granularity = {QuantizationGranularity::Pertensor, QuantizationGranularity::Perchannel};
|
||||
|
||||
/* ============= 2D GroupConvolutionBackpropData ============= */
|
||||
const std::vector<std::vector<size_t >> inputShapes2D = {{1, 16, 10, 10}, {1, 32, 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, 16, 10, 10}, {1, 32, 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 quantConvBackpropData2DParams = ::testing::Combine(
|
||||
::testing::ValuesIn(kernels2D),
|
||||
@@ -45,18 +42,18 @@ const auto quantConvBackpropData2DParams = ::testing::Combine(
|
||||
INSTANTIATE_TEST_SUITE_P(smoke_QuantConvBackpropData2D, QuantConvBackpropDataLayerTest,
|
||||
::testing::Combine(
|
||||
quantConvBackpropData2DParams,
|
||||
::testing::ValuesIn(netPrecisions),
|
||||
::testing::ValuesIn(element_types),
|
||||
::testing::ValuesIn(inputShapes2D),
|
||||
::testing::Values(ov::test::utils::DEVICE_CPU)),
|
||||
QuantConvBackpropDataLayerTest::getTestCaseName);
|
||||
|
||||
/* ============= 3D ConvolutionBackpropData ============= */
|
||||
const std::vector<std::vector<size_t >> inputShapes3D = {{1, 16, 5, 5, 5}, {1, 32, 5, 5, 5}};
|
||||
const std::vector<std::vector<size_t >> kernels3D = {{1, 1, 1}, {3, 3, 3}};
|
||||
const std::vector<std::vector<size_t >> strides3D = {{1, 1, 1}};
|
||||
const std::vector<ov::Shape> inputShapes3D = {{1, 16, 5, 5, 5}, {1, 32, 5, 5, 5}};
|
||||
const std::vector<ov::Shape> kernels3D = {{1, 1, 1}, {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 quantConvBackpropData3DParams = ::testing::Combine(
|
||||
::testing::ValuesIn(kernels3D),
|
||||
@@ -65,7 +62,7 @@ const auto quantConvBackpropData3DParams = ::testing::Combine(
|
||||
::testing::ValuesIn(padEnds3D),
|
||||
::testing::ValuesIn(dilations3D),
|
||||
::testing::ValuesIn(numOutChannels),
|
||||
::testing::Values(ngraph::op::PadType::AUTO),
|
||||
::testing::Values(ov::op::PadType::AUTO),
|
||||
::testing::ValuesIn(levels),
|
||||
::testing::ValuesIn(granularity)
|
||||
);
|
||||
@@ -73,7 +70,7 @@ const auto quantConvBackpropData3DParams = ::testing::Combine(
|
||||
INSTANTIATE_TEST_SUITE_P(smoke_QuantConvBackpropData3D, QuantConvBackpropDataLayerTest,
|
||||
::testing::Combine(
|
||||
quantConvBackpropData3DParams,
|
||||
::testing::ValuesIn(netPrecisions),
|
||||
::testing::ValuesIn(element_types),
|
||||
::testing::ValuesIn(inputShapes3D),
|
||||
::testing::Values(ov::test::utils::DEVICE_CPU)),
|
||||
QuantConvBackpropDataLayerTest::getTestCaseName);
|
||||
|
||||
+15
-17
@@ -7,27 +7,25 @@
|
||||
#include "subgraph_tests/quantized_convolution_backprop_data.hpp"
|
||||
#include "common_test_utils/test_constants.hpp"
|
||||
|
||||
using namespace SubgraphTestsDefinitions;
|
||||
using namespace ngraph::helpers;
|
||||
using namespace ov::test;
|
||||
using namespace ov::test::utils;
|
||||
|
||||
namespace {
|
||||
|
||||
const std::vector<InferenceEngine::Precision> netPrecisions = {
|
||||
InferenceEngine::Precision::FP32
|
||||
};
|
||||
const std::vector<ov::element::Type> element_types = {ov::element::f32};
|
||||
|
||||
const std::vector<size_t> numOutChannels = {16, 32};
|
||||
|
||||
const std::vector<size_t > levels = {256};
|
||||
const std::vector<QuantizationGranularity > granularity = {QuantizationGranularity::Pertensor, QuantizationGranularity::Perchannel};
|
||||
const std::vector<size_t> levels = {256};
|
||||
const std::vector<QuantizationGranularity> granularity = {QuantizationGranularity::Pertensor, QuantizationGranularity::Perchannel};
|
||||
|
||||
/* ============= 2D GroupConvolutionBackpropData ============= */
|
||||
const std::vector<std::vector<size_t >> inputShapes2D = {{1, 16, 10, 10}, {1, 32, 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, 16, 10, 10}, {1, 32, 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 quantConvBackpropData2DParams = ::testing::Combine(
|
||||
::testing::ValuesIn(kernels2D),
|
||||
@@ -44,18 +42,18 @@ const auto quantConvBackpropData2DParams = ::testing::Combine(
|
||||
INSTANTIATE_TEST_SUITE_P(smoke_QuantConvBackpropData2D, QuantConvBackpropDataLayerTest,
|
||||
::testing::Combine(
|
||||
quantConvBackpropData2DParams,
|
||||
::testing::ValuesIn(netPrecisions),
|
||||
::testing::ValuesIn(element_types),
|
||||
::testing::ValuesIn(inputShapes2D),
|
||||
::testing::Values(ov::test::utils::DEVICE_GPU)),
|
||||
QuantConvBackpropDataLayerTest::getTestCaseName);
|
||||
|
||||
/* ============= 3D ConvolutionBackpropData ============= */
|
||||
const std::vector<std::vector<size_t >> inputShapes3D = {{1, 16, 5, 5, 5}, {1, 32, 5, 5, 5}};
|
||||
const std::vector<std::vector<size_t >> kernels3D = {{1, 1, 1}, {3, 3, 3}};
|
||||
const std::vector<std::vector<size_t >> strides3D = {{1, 1, 1}};
|
||||
const std::vector<ov::Shape> inputShapes3D = {{1, 16, 5, 5, 5}, {1, 32, 5, 5, 5}};
|
||||
const std::vector<ov::Shape> kernels3D = {{1, 1, 1}, {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 quantConvBackpropData3DParams = ::testing::Combine(
|
||||
::testing::ValuesIn(kernels3D),
|
||||
@@ -72,7 +70,7 @@ const auto quantConvBackpropData3DParams = ::testing::Combine(
|
||||
INSTANTIATE_TEST_SUITE_P(smoke_QuantConvBackpropData3D, QuantConvBackpropDataLayerTest,
|
||||
::testing::Combine(
|
||||
quantConvBackpropData3DParams,
|
||||
::testing::ValuesIn(netPrecisions),
|
||||
::testing::ValuesIn(element_types),
|
||||
::testing::ValuesIn(inputShapes3D),
|
||||
::testing::Values(ov::test::utils::DEVICE_GPU)),
|
||||
QuantConvBackpropDataLayerTest::getTestCaseName);
|
||||
|
||||
+5
-3
@@ -6,10 +6,12 @@
|
||||
|
||||
#include "shared_test_classes/subgraph/quantized_convolution_backprop_data.hpp"
|
||||
|
||||
namespace SubgraphTestsDefinitions {
|
||||
namespace ov {
|
||||
namespace test {
|
||||
|
||||
TEST_P(QuantConvBackpropDataLayerTest, CompareWithRefs) {
|
||||
Run();
|
||||
run();
|
||||
}
|
||||
|
||||
} // namespace SubgraphTestsDefinitions
|
||||
} // namespace test
|
||||
} // namespace ov
|
||||
|
||||
+14
-17
@@ -5,34 +5,30 @@
|
||||
#pragma once
|
||||
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include "common_test_utils/test_enums.hpp"
|
||||
#include "shared_test_classes/base/ov_subgraph.hpp"
|
||||
|
||||
#include "shared_test_classes/base/layer_test_utils.hpp"
|
||||
#include "ov_models/builders.hpp"
|
||||
#include "ov_models/utils/ov_helpers.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,
|
||||
ngraph::op::PadType,
|
||||
ov::op::PadType,
|
||||
size_t,
|
||||
ov::test::utils::QuantizationGranularity> quantConvBackpropDataSpecificParams;
|
||||
typedef std::tuple<
|
||||
quantConvBackpropDataSpecificParams,
|
||||
InferenceEngine::Precision,
|
||||
InferenceEngine::SizeVector,
|
||||
LayerTestsUtils::TargetDevice> quantConvBackpropDataLayerTestParamsSet;
|
||||
ov::element::Type,
|
||||
ov::Shape,
|
||||
std::string> quantConvBackpropDataLayerTestParamsSet;
|
||||
|
||||
class QuantConvBackpropDataLayerTest : public testing::WithParamInterface<quantConvBackpropDataLayerTestParamsSet>,
|
||||
virtual public LayerTestsUtils::LayerTestsCommon {
|
||||
virtual public ov::test::SubgraphBaseStaticTest {
|
||||
public:
|
||||
static std::string getTestCaseName(const testing::TestParamInfo<quantConvBackpropDataLayerTestParamsSet>& obj);
|
||||
|
||||
@@ -40,4 +36,5 @@ protected:
|
||||
void SetUp() override;
|
||||
};
|
||||
|
||||
} // namespace SubgraphTestsDefinitions
|
||||
} // namespace test
|
||||
} // namespace ov
|
||||
|
||||
+23
-22
@@ -3,17 +3,20 @@
|
||||
//
|
||||
|
||||
#include "shared_test_classes/subgraph/quantized_convolution_backprop_data.hpp"
|
||||
#include "ov_models/builders.hpp"
|
||||
#include "ov_models/utils/ov_helpers.hpp"
|
||||
|
||||
namespace SubgraphTestsDefinitions {
|
||||
namespace ov {
|
||||
namespace test {
|
||||
|
||||
std::string QuantConvBackpropDataLayerTest::getTestCaseName(const testing::TestParamInfo<quantConvBackpropDataLayerTestParamsSet>& obj) {
|
||||
quantConvBackpropDataSpecificParams groupConvBackpropDataParams;
|
||||
InferenceEngine::Precision netPrecision;
|
||||
InferenceEngine::SizeVector inputShapes;
|
||||
ov::element::Type element_type;
|
||||
ov::Shape inputShapes;
|
||||
std::string targetDevice;
|
||||
std::tie(groupConvBackpropDataParams, netPrecision, inputShapes, targetDevice) = obj.param;
|
||||
std::tie(groupConvBackpropDataParams, element_type, inputShapes, targetDevice) = obj.param;
|
||||
ngraph::op::PadType padType;
|
||||
InferenceEngine::SizeVector kernel, stride, dilation;
|
||||
ov::Shape kernel, stride, dilation;
|
||||
std::vector<ptrdiff_t> padBegin, padEnd;
|
||||
size_t convOutChannels;
|
||||
size_t quantLevels;
|
||||
@@ -31,49 +34,47 @@ std::string QuantConvBackpropDataLayerTest::getTestCaseName(const testing::TestP
|
||||
result << "AP=" << padType << "_";
|
||||
result << "Levels=" << quantLevels << "_";
|
||||
result << "QG=" << quantGranularity << "_";
|
||||
result << "netPRC=" << netPrecision.name() << "_";
|
||||
result << "netPRC=" << element_type.get_type_name() << "_";
|
||||
result << "targetDevice=" << targetDevice;
|
||||
return result.str();
|
||||
}
|
||||
|
||||
void QuantConvBackpropDataLayerTest::SetUp() {
|
||||
threshold = 0.5f;
|
||||
|
||||
quantConvBackpropDataSpecificParams groupConvBackpropDataParams;
|
||||
std::vector<size_t> inputShape;
|
||||
auto netPrecision = InferenceEngine::Precision::UNSPECIFIED;
|
||||
std::tie(groupConvBackpropDataParams, netPrecision, inputShape, targetDevice) = this->GetParam();
|
||||
ngraph::op::PadType padType;
|
||||
ov::Shape inputShape;
|
||||
ov::element::Type element_type = ov::element::undefined;
|
||||
std::tie(groupConvBackpropDataParams, element_type, inputShape, targetDevice) = this->GetParam();
|
||||
ov::op::PadType padType;
|
||||
InferenceEngine::SizeVector kernel, stride, dilation;
|
||||
std::vector<ptrdiff_t> padBegin, padEnd;
|
||||
size_t convOutChannels;
|
||||
size_t quantLevels;
|
||||
ov::test::utils::QuantizationGranularity quantGranularity;
|
||||
std::tie(kernel, stride, padBegin, padEnd, dilation, convOutChannels, padType, quantLevels, quantGranularity) = groupConvBackpropDataParams;
|
||||
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, 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 = {inputShape[1], convOutChannels};
|
||||
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];
|
||||
|
||||
auto weightsFq = ngraph::builder::makeFakeQuantize(weightsNode, ngPrc, quantLevels, weightsFqConstShapes);
|
||||
auto weightsFq = ngraph::builder::makeFakeQuantize(weightsNode, element_type, quantLevels, weightsFqConstShapes);
|
||||
|
||||
auto convBackpropData = std::dynamic_pointer_cast<ngraph::opset1::ConvolutionBackpropData>(
|
||||
ngraph::builder::makeConvolutionBackpropData(dataFq, weightsFq, ngPrc, stride, padBegin, padEnd, dilation, padType));
|
||||
auto convBackpropData = std::dynamic_pointer_cast<ov::op::v1::ConvolutionBackpropData>(
|
||||
ngraph::builder::makeConvolutionBackpropData(dataFq, weightsFq, element_type, stride, padBegin, padEnd, dilation, padType));
|
||||
|
||||
ngraph::ResultVector results{std::make_shared<ngraph::opset1::Result>(convBackpropData)};
|
||||
function = std::make_shared<ngraph::Function>(results, params, "QuantConvolutionBackpropData");
|
||||
ov::ResultVector results{std::make_shared<ov::op::v0::Result>(convBackpropData)};
|
||||
function = std::make_shared<ov::Model>(results, params, "QuantConvolutionBackpropData");
|
||||
}
|
||||
} // namespace SubgraphTestsDefinitions
|
||||
} // namespace test
|
||||
} // namespace ov
|
||||
|
||||
Reference in New Issue
Block a user