[LPT] FullyConnected & Gemm tests
This commit is contained in:
parent
c7313bab7f
commit
92e5e010b9
@ -22,7 +22,7 @@ const std::vector<InferenceEngine::SizeVector> dimensions = {
|
||||
|
||||
const std::vector<LayerTransformation::Params> trasformationParamValues = {
|
||||
LayerTestsUtils::LayerTransformationParamsFactory::createParams(),
|
||||
// LayerTestsUtils::LayerTransformationParamsFactory::createParamsI8I8(),
|
||||
LayerTestsUtils::LayerTransformationParamsFactory::createParamsI8I8(),
|
||||
LayerTestsUtils::LayerTransformationParamsFactory::createParamsU8I8()
|
||||
};
|
||||
|
||||
|
@ -41,12 +41,16 @@ void FullyConnectedTransformation::SetUp() {
|
||||
auto ngPrecision = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision);
|
||||
|
||||
const auto paramNode = std::make_shared<ngraph::opset1::Parameter>(ngPrecision, ngraph::Shape(inputShape));
|
||||
const std::vector<size_t> constShapes(inputShape.size(), 1ul);
|
||||
const auto fakeQuantizeOnAcitvations = ngraph::builder::makeFakeQuantize(
|
||||
paramNode, ngPrecision, 256ul, { 1ul },
|
||||
paramNode, ngPrecision, 256ul, constShapes,
|
||||
{ 0.f }, { 255.f / 4.f }, { 0.f }, { 255.f / 4.f });
|
||||
fakeQuantizeOnAcitvations->set_friendly_name("fakeQuantizeOnAcitvations");
|
||||
|
||||
auto weightsConst = std::make_shared<ngraph::op::Constant>(ngPrecision, ngraph::Shape{ inputShape[1], inputShape[1] }, std::vector<float>({ 1.f }));
|
||||
auto weightsConst = std::make_shared<ngraph::op::Constant>(
|
||||
ngPrecision,
|
||||
ngraph::Shape { inputShape[inputShape.size() - 1ul], inputShape[inputShape.size() - 1ul] },
|
||||
std::vector<float>({ 1.f }));
|
||||
const auto fakeQuantizeOnWeights = ngraph::builder::makeFakeQuantize(
|
||||
weightsConst, ngPrecision, 256ul, { 1ul, 1ul },
|
||||
{ -128.f / 8.f }, { 127.f / 8.f }, { -128.f / 8.f }, { 127.f / 8.f });
|
||||
@ -90,10 +94,22 @@ void FullyConnectedTransformation::validate() {
|
||||
|
||||
const InferenceEngine::CNNLayerPtr layer = InferenceEngine::details::CNNNetworkHelper::getParent(*outputLayer);
|
||||
if (params.updatePrecisions) {
|
||||
const bool asymmetricQuantizationOnData = std::all_of(
|
||||
params.precisionsOnActivations.begin(),
|
||||
params.precisionsOnActivations.end(),
|
||||
[](const InferenceEngine::Precision precision) { return precision != InferenceEngine::Precision::U8; });
|
||||
|
||||
const bool asymmetricQuantizationOnWeights = std::all_of(
|
||||
params.precisionsOnWeights.begin(),
|
||||
params.precisionsOnWeights.end(),
|
||||
[](const InferenceEngine::Precision precision) { return precision != InferenceEngine::Precision::I8; });
|
||||
|
||||
checkPrecisions(
|
||||
*layer,
|
||||
{ { InferenceEngine::Precision::U8 }, { InferenceEngine::Precision::I8 }, { netPrecision } },
|
||||
{ getDeviceInternalPrecision(netPrecision) });
|
||||
{ { params.precisionsOnActivations[0] }, { params.precisionsOnWeights[0] }, { netPrecision } },
|
||||
{ getDeviceInternalPrecision(netPrecision) },
|
||||
asymmetricQuantizationOnData,
|
||||
asymmetricQuantizationOnWeights);
|
||||
} else {
|
||||
checkPrecisions(*layer, netPrecision);
|
||||
}
|
||||
@ -104,10 +120,6 @@ void FullyConnectedTransformation::validate() {
|
||||
|
||||
TEST_P(FullyConnectedTransformation, CompareWithRefImpl) {
|
||||
Run();
|
||||
|
||||
if (targetDevice == std::string{CommonTestUtils::DEVICE_GPU}) {
|
||||
PluginCache::get().reset();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace LayerTestsDefinitions
|
||||
|
@ -108,35 +108,49 @@ void LayerTransformation::checkPrecisions(const InferenceEngine::CNNLayer& layer
|
||||
void LayerTransformation::checkPrecisions(
|
||||
const InferenceEngine::CNNLayer& layer,
|
||||
const std::vector<std::vector<InferenceEngine::Precision>>& expectedInputPrecisions,
|
||||
const std::vector<InferenceEngine::Precision>& expectedOutputPrecisions) {
|
||||
const std::vector<InferenceEngine::Precision>& expectedOutputPrecisions,
|
||||
const bool asymmetricQuantizationOnData,
|
||||
const bool asymmetricQuantizationOnWeights) {
|
||||
EXPECT_EQ(expectedInputPrecisions.size(), layer.insData.size()) << "insert data count is no expected: " << layer.insData.size();
|
||||
|
||||
for (size_t inputIndex = 0ul; inputIndex < layer.insData.size(); ++inputIndex) {
|
||||
const std::vector<InferenceEngine::Precision>& precisions = expectedInputPrecisions[inputIndex];
|
||||
const InferenceEngine::DataPtr insData = layer.insData[inputIndex].lock();
|
||||
EXPECT_TRUE(insData != nullptr) << "insert data is nullable";
|
||||
const InferenceEngine::Precision actualPrecision = insData->getTensorDesc().getPrecision();
|
||||
const auto checkPrecision = [](
|
||||
const InferenceEngine::CNNLayer& layer,
|
||||
const std::vector<InferenceEngine::Precision>& expectedPrecisions,
|
||||
const size_t index,
|
||||
const bool input) {
|
||||
const InferenceEngine::DataPtr data = input ? layer.insData[index].lock() : layer.outData[index];
|
||||
EXPECT_TRUE(data != nullptr) << "data is nullable";
|
||||
const InferenceEngine::Precision actualPrecision = data->getTensorDesc().getPrecision();
|
||||
|
||||
EXPECT_FALSE(std::all_of(
|
||||
precisions.begin(),
|
||||
precisions.end(),
|
||||
expectedPrecisions.begin(),
|
||||
expectedPrecisions.end(),
|
||||
[&](const InferenceEngine::Precision precision) { return getDeviceInternalPrecision(precision) != actualPrecision; })) <<
|
||||
"expected input precisions on " << inputIndex << " input port " << precisions <<
|
||||
"expected precisions on " << index << (input ? " input" : " output") << " port " << expectedPrecisions <<
|
||||
" actual precision " << actualPrecision;
|
||||
};
|
||||
|
||||
if (asymmetricQuantizationOnData || asymmetricQuantizationOnWeights) {
|
||||
if (asymmetricQuantizationOnData) {
|
||||
const InferenceEngine::CNNLayerPtr parentOnData = InferenceEngine::details::CNNNetworkHelper::getParent(layer, 0);
|
||||
checkPrecision(*parentOnData, expectedInputPrecisions[0], 0, true);
|
||||
} else {
|
||||
checkPrecision(layer, expectedInputPrecisions[0], 0, true);
|
||||
}
|
||||
|
||||
if (asymmetricQuantizationOnWeights) {
|
||||
const InferenceEngine::CNNLayerPtr parentOnWeights = InferenceEngine::details::CNNNetworkHelper::getParent(layer, 1);
|
||||
checkPrecision(*parentOnWeights, expectedInputPrecisions[1], 1, true);
|
||||
} else {
|
||||
checkPrecision(layer, expectedInputPrecisions[1], 1, true);
|
||||
}
|
||||
} else {
|
||||
for (size_t inputIndex = 0ul; inputIndex < layer.insData.size(); ++inputIndex) {
|
||||
checkPrecision(layer, expectedInputPrecisions[inputIndex], inputIndex, true);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const InferenceEngine::DataPtr outData = layer.outData[0];
|
||||
EXPECT_TRUE(outData != nullptr) << "output data is nullable";
|
||||
const InferenceEngine::Precision actualPrecision = outData->getTensorDesc().getPrecision();
|
||||
|
||||
EXPECT_FALSE(std::all_of(
|
||||
expectedOutputPrecisions.begin(),
|
||||
expectedOutputPrecisions.end(),
|
||||
[&](const InferenceEngine::Precision expectedPrecision) { return getDeviceInternalPrecision(expectedPrecision) != actualPrecision; })) <<
|
||||
"expected output precisions " << expectedOutputPrecisions <<
|
||||
" actual precision " << actualPrecision;
|
||||
}
|
||||
checkPrecision(layer, expectedOutputPrecisions, 0, false);
|
||||
}
|
||||
|
||||
std::pair<float, float> LayerTransformation::getQuantizationInterval(const InferenceEngine::Precision precision) {
|
||||
|
@ -56,7 +56,9 @@ protected:
|
||||
static void checkPrecisions(
|
||||
const InferenceEngine::CNNLayer& layer,
|
||||
const std::vector<std::vector<InferenceEngine::Precision>>& expectedInputPrecisions,
|
||||
const std::vector<InferenceEngine::Precision>& expectedOutputPrecisions);
|
||||
const std::vector<InferenceEngine::Precision>& expectedOutputPrecisions,
|
||||
const bool asymmetricQuantizationOnData = false,
|
||||
const bool asymmetricQuantizationOnWeights = false);
|
||||
|
||||
static std::pair<float, float> getQuantizationInterval(const InferenceEngine::Precision precision);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user