[Func Test] Upgrade func test of QuantMatMulTest related to 2.0 (#21103)
Signed-off-by: Zhai, Xuejun <xuejun.zhai@intel.com>
This commit is contained in:
+11
-11
@@ -7,20 +7,19 @@
|
||||
|
||||
#include "subgraph_tests/quantized_mat_mul.hpp"
|
||||
|
||||
using namespace SubgraphTestsDefinitions;
|
||||
using namespace ngraph::helpers;
|
||||
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<std::vector<size_t>> shapesA = {
|
||||
const std::vector<ov::Shape> shapesA = {
|
||||
{1, 4, 5, 6}
|
||||
};
|
||||
|
||||
const std::vector<std::vector<size_t>> shapesB = {
|
||||
const std::vector<ov::Shape> shapesB = {
|
||||
{1, 4, 6, 4}
|
||||
};
|
||||
|
||||
@@ -43,14 +42,15 @@ const std::vector<QuantRange> ranges_i32 = {
|
||||
const std::vector<uint64_t> levels_8 = {256};
|
||||
const std::vector<uint64_t> levels_16 = {65536};
|
||||
const std::vector<uint64_t> levels_32 = {4294967296};
|
||||
const std::vector<QuantizationGranularity> granularity = {QuantizationGranularity::Pertensor};
|
||||
const std::vector<ov::test::utils::QuantizationGranularity> granularity = {
|
||||
ov::test::utils::QuantizationGranularity::Pertensor};
|
||||
|
||||
const auto quantParams_i8 = ::testing::Combine(
|
||||
::testing::ValuesIn(levels_8),
|
||||
::testing::ValuesIn(ranges_u8),
|
||||
::testing::ValuesIn(ranges_i8),
|
||||
::testing::ValuesIn(granularity),
|
||||
::testing::Values(InferenceEngine::Precision::I8)
|
||||
::testing::Values(ov::element::i8)
|
||||
);
|
||||
|
||||
const auto quantParams_u8 = ::testing::Combine(
|
||||
@@ -58,7 +58,7 @@ const auto quantParams_u8 = ::testing::Combine(
|
||||
::testing::ValuesIn(ranges_u8),
|
||||
::testing::ValuesIn(ranges_u8),
|
||||
::testing::ValuesIn(granularity),
|
||||
::testing::Values(InferenceEngine::Precision::U8)
|
||||
::testing::Values(ov::element::u8)
|
||||
);
|
||||
|
||||
const auto quantParams_i16 = ::testing::Combine(
|
||||
@@ -66,7 +66,7 @@ const auto quantParams_i16 = ::testing::Combine(
|
||||
::testing::ValuesIn(ranges_i32),
|
||||
::testing::ValuesIn(ranges_i16),
|
||||
::testing::ValuesIn(granularity),
|
||||
::testing::Values(InferenceEngine::Precision::I16)
|
||||
::testing::Values(ov::element::i16)
|
||||
);
|
||||
|
||||
const auto quantParams_i32 = ::testing::Combine(
|
||||
@@ -74,7 +74,7 @@ const auto quantParams_i32 = ::testing::Combine(
|
||||
::testing::ValuesIn(ranges_i32),
|
||||
::testing::ValuesIn(ranges_i32),
|
||||
::testing::ValuesIn(granularity),
|
||||
::testing::Values(InferenceEngine::Precision::I32)
|
||||
::testing::Values(ov::element::i32)
|
||||
);
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(smoke_QuantMatMul_i8i8, QuantMatMulTest,
|
||||
|
||||
@@ -6,10 +6,12 @@
|
||||
|
||||
#include "shared_test_classes/subgraph/quantized_mat_mul.hpp"
|
||||
|
||||
namespace SubgraphTestsDefinitions {
|
||||
namespace ov {
|
||||
namespace test {
|
||||
|
||||
TEST_P(QuantMatMulTest, CompareWithRefs) {
|
||||
Run();
|
||||
run();
|
||||
};
|
||||
|
||||
} // namespace SubgraphTestsDefinitions
|
||||
} // namespace test
|
||||
} // namespace ov
|
||||
|
||||
+13
-16
@@ -4,15 +4,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
#include "common_test_utils/test_enums.hpp"
|
||||
#include "shared_test_classes/base/ov_subgraph.hpp"
|
||||
|
||||
#include "shared_test_classes/base/layer_test_utils.hpp"
|
||||
|
||||
namespace SubgraphTestsDefinitions {
|
||||
namespace ov {
|
||||
namespace test {
|
||||
|
||||
typedef std::pair<float, float> QuantRange;
|
||||
|
||||
@@ -21,22 +17,23 @@ typedef std::tuple<
|
||||
QuantRange,
|
||||
QuantRange,
|
||||
ov::test::utils::QuantizationGranularity,
|
||||
InferenceEngine::Precision> QuantParams;
|
||||
ov::element::Type> QuantParams;
|
||||
|
||||
typedef std::tuple<
|
||||
QuantParams,
|
||||
QuantParams,
|
||||
InferenceEngine::Precision,
|
||||
InferenceEngine::SizeVector,
|
||||
InferenceEngine::SizeVector,
|
||||
LayerTestsUtils::TargetDevice> QuantMatMulLayerTestParamsSet;
|
||||
ov::element::Type,
|
||||
ov::Shape,
|
||||
ov::Shape,
|
||||
std::string> QuantMatMulLayerTestParamsSet;
|
||||
|
||||
class QuantMatMulTest : public testing::WithParamInterface<QuantMatMulLayerTestParamsSet>, virtual public LayerTestsUtils::LayerTestsCommon {
|
||||
class QuantMatMulTest : public testing::WithParamInterface<QuantMatMulLayerTestParamsSet>, virtual public ov::test::SubgraphBaseStaticTest {
|
||||
public:
|
||||
static std::string getTestCaseName(const testing::TestParamInfo<QuantMatMulLayerTestParamsSet> &obj);
|
||||
static std::string getTestCaseName(const testing::TestParamInfo<QuantMatMulLayerTestParamsSet>& obj);
|
||||
|
||||
protected:
|
||||
void SetUp() override;
|
||||
};
|
||||
|
||||
} // namespace SubgraphTestsDefinitions
|
||||
} // namespace test
|
||||
} // namespace ov
|
||||
|
||||
@@ -5,27 +5,28 @@
|
||||
#include "shared_test_classes/subgraph/quantized_mat_mul.hpp"
|
||||
#include "ov_models/builders.hpp"
|
||||
|
||||
namespace SubgraphTestsDefinitions {
|
||||
namespace ov {
|
||||
namespace test {
|
||||
|
||||
std::string QuantMatMulTest::getTestCaseName(const testing::TestParamInfo<QuantMatMulLayerTestParamsSet> &obj) {
|
||||
QuantParams quantParams0;
|
||||
QuantParams quantParams1;
|
||||
InferenceEngine::Precision netPrecision;
|
||||
InferenceEngine::SizeVector inputShape0;
|
||||
InferenceEngine::SizeVector inputShape1;
|
||||
ov::element::Type element_type;
|
||||
ov::Shape inputShape0;
|
||||
ov::Shape inputShape1;
|
||||
QuantRange inputRange0;
|
||||
QuantRange inputRange1;
|
||||
QuantRange outputRange0;
|
||||
QuantRange outputRange1;
|
||||
std::string targetDevice;
|
||||
std::tie(quantParams0, quantParams1, netPrecision, inputShape0, inputShape1, targetDevice) = obj.param;
|
||||
std::tie(quantParams0, quantParams1, element_type, inputShape0, inputShape1, targetDevice) = obj.param;
|
||||
|
||||
size_t quantLevels0;
|
||||
size_t quantLevels1;
|
||||
ov::test::utils::QuantizationGranularity quantGranularity0;
|
||||
ov::test::utils::QuantizationGranularity quantGranularity1;
|
||||
InferenceEngine::Precision fqPrec0;
|
||||
InferenceEngine::Precision fqPrec1;
|
||||
ov::element::Type fqPrec0;
|
||||
ov::element::Type fqPrec1;
|
||||
std::tie(quantLevels0, inputRange0, outputRange0, quantGranularity0, fqPrec0) = quantParams0;
|
||||
std::tie(quantLevels1, inputRange1, outputRange1, quantGranularity1, fqPrec1) = quantParams1;
|
||||
|
||||
@@ -40,9 +41,9 @@ std::string QuantMatMulTest::getTestCaseName(const testing::TestParamInfo<QuantM
|
||||
result << "outputRange1=" << outputRange1.first << "_" << outputRange1.second << "_";
|
||||
result << "QuantGranularity0=" << quantGranularity0 << "_";
|
||||
result << "QuantGranularity1=" << quantGranularity1 << "_";
|
||||
result << "fq0PRC=" << fqPrec0.name() << "_";
|
||||
result << "fq1PRC=" << fqPrec1.name() << "_";
|
||||
result << "netPRC=" << netPrecision.name() << "_";
|
||||
result << "fq0PRC=" << fqPrec0.get_type_name() << "_";
|
||||
result << "fq1PRC=" << fqPrec1.get_type_name() << "_";
|
||||
result << "ET=" << element_type.get_type_name() << "_";
|
||||
result << "targetDevice=" << targetDevice;
|
||||
return result.str();
|
||||
}
|
||||
@@ -50,10 +51,10 @@ std::string QuantMatMulTest::getTestCaseName(const testing::TestParamInfo<QuantM
|
||||
void QuantMatMulTest::SetUp() {
|
||||
QuantParams quantParams0;
|
||||
QuantParams quantParams1;
|
||||
InferenceEngine::SizeVector inputShape0;
|
||||
InferenceEngine::SizeVector inputShape1;
|
||||
auto netPrecision = InferenceEngine::Precision::UNSPECIFIED;
|
||||
std::tie(quantParams0, quantParams1, netPrecision, inputShape0, inputShape1, targetDevice) = this->GetParam();
|
||||
ov::Shape inputShape0;
|
||||
ov::Shape inputShape1;
|
||||
ov::element::Type element_type;
|
||||
std::tie(quantParams0, quantParams1, element_type, inputShape0, inputShape1, targetDevice) = this->GetParam();
|
||||
|
||||
size_t quantLevels0;
|
||||
size_t quantLevels1;
|
||||
@@ -63,22 +64,21 @@ void QuantMatMulTest::SetUp() {
|
||||
QuantRange outputRange1;
|
||||
ov::test::utils::QuantizationGranularity quantGranularity0;
|
||||
ov::test::utils::QuantizationGranularity quantGranularity1;
|
||||
InferenceEngine::Precision fqPrec0;
|
||||
InferenceEngine::Precision fqPrec1;
|
||||
ov::element::Type fqPrec0;
|
||||
ov::element::Type fqPrec1;
|
||||
std::tie(quantLevels0, inputRange0, outputRange0, quantGranularity0, fqPrec0) = quantParams0;
|
||||
std::tie(quantLevels1, inputRange1, outputRange1, quantGranularity1, fqPrec1) = quantParams1;
|
||||
|
||||
auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision);
|
||||
ov::ParameterVector params {std::make_shared<ov::op::v0::Parameter>(ngPrc, ov::Shape(inputShape0)),
|
||||
std::make_shared<ov::op::v0::Parameter>(ngPrc, ov::Shape(inputShape1))};
|
||||
ov::ParameterVector params {std::make_shared<ov::op::v0::Parameter>(element_type, ov::Shape(inputShape0)),
|
||||
std::make_shared<ov::op::v0::Parameter>(element_type, ov::Shape(inputShape1))};
|
||||
|
||||
auto makeFakeQuantizeNode = [ngPrc](size_t quantLevels, QuantRange inputRange, QuantRange outputRange,
|
||||
ov::test::utils::QuantizationGranularity quantGranularity, const ngraph::Output<ngraph::Node> &in, std::vector<size_t> inputShape,
|
||||
InferenceEngine::Precision prec) -> std::shared_ptr<ngraph::Node> {
|
||||
auto makeFakeQuantizeNode = [element_type](size_t quantLevels, QuantRange inputRange, QuantRange outputRange,
|
||||
ov::test::utils::QuantizationGranularity quantGranularity, const ov::Output<ov::Node> &in, ov::Shape inputShape,
|
||||
ov::element::Type prec) -> std::shared_ptr<ngraph::Node> {
|
||||
std::vector<size_t> dataFqConstShapes(inputShape.size(), 1);
|
||||
if (quantGranularity == ov::test::utils::QuantizationGranularity::Perchannel)
|
||||
dataFqConstShapes[1] = inputShape[1];
|
||||
size_t constDataSize = ngraph::shape_size(dataFqConstShapes);
|
||||
size_t constDataSize = ov::shape_size(dataFqConstShapes);
|
||||
std::vector<float> inputLowData(constDataSize), inputHighData(constDataSize), outputLowData(constDataSize), outputHighData(constDataSize);
|
||||
for (int i = 0; i < constDataSize; i++) {
|
||||
inputLowData[i] = inputRange.first;
|
||||
@@ -86,14 +86,15 @@ void QuantMatMulTest::SetUp() {
|
||||
outputLowData[i] = outputRange.first;
|
||||
outputHighData[i] = outputRange.second;
|
||||
}
|
||||
return ngraph::builder::makeFakeQuantize(in, ngPrc, quantLevels, dataFqConstShapes, inputLowData, inputHighData, outputLowData, outputHighData);
|
||||
return ngraph::builder::makeFakeQuantize(in, element_type, quantLevels, dataFqConstShapes, inputLowData, inputHighData, outputLowData, outputHighData);
|
||||
};
|
||||
|
||||
auto dataFq0 = makeFakeQuantizeNode(quantLevels0, inputRange0, outputRange0, quantGranularity0, params[0], inputShape0, fqPrec0);
|
||||
auto dataFq1 = makeFakeQuantizeNode(quantLevels1, inputRange1, outputRange1, quantGranularity1, params[1], inputShape1, fqPrec1);
|
||||
|
||||
auto MatMul = std::make_shared<ov::op::v0::MatMul>(dataFq0, dataFq1);
|
||||
ngraph::ResultVector results{std::make_shared<ngraph::opset1::Result>(MatMul)};
|
||||
function = std::make_shared<ngraph::Function>(results, params, "QuantMatMul");
|
||||
ov::ResultVector results{std::make_shared<ov::op::v0::Result>(MatMul)};
|
||||
function = std::make_shared<ov::Model>(results, params, "QuantMatMul");
|
||||
}
|
||||
} // namespace SubgraphTestsDefinitions
|
||||
} // namespace test
|
||||
} // namespace ov
|
||||
|
||||
Reference in New Issue
Block a user