[LPT] GPU support3DTensorOnActivations - tests (#4576)

This commit is contained in:
Edward Shogulin 2021-03-04 16:05:02 +03:00 committed by GitHub
parent 932558b403
commit ed8d3b72d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 68 additions and 5 deletions

View File

@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation
// Copyright (C) 2020-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
@ -79,7 +79,10 @@ inline std::ostream& operator << (std::ostream& out, const MatMullTransformation
}
inline std::ostream& operator << (std::ostream& out, const MatMullTransformationTestValues& values) {
return out << "_" << values.actual << "_" << values.expected;
return out << "_" <<
values.params.support3DTensorOnActivations << "_" <<
values.actual << "_" <<
values.expected;
}
typedef std::tuple<
@ -201,6 +204,28 @@ std::vector<MatMullTransformationTestValues> testValues = {
}
},
// support3DTensorOnActivations = false for 3D tensor
{
LayerTransformation::createParamsU8I8().setSupport3DTensorOnActivations(false),
{
{ 1, 384, 1024 },
ngraph::element::u8,
{ ngraph::element::f32, {}, { 0.02f } },
{ std::vector<float>(1024 * 1024, 1.f), ngraph::element::f32, { 1024, 1024 } },
{ 255, { 1, 1 }, {0.f}, {254.f}, {-12.7f}, {12.7} }
},
{
{ 1, 384, 1024 },
ngraph::element::u8,
{ ngraph::element::f32, {}, { 0.02f } },
{ std::vector<float>(1024 * 1024, 1.f), ngraph::element::f32, { 1024, 1024 } },
ngraph::element::i8,
{},
{ 255, { 1, 1 }, {0.f}, {254.f}, {-12.7f}, {12.7} },
{}
}
},
// 3D: U8 & I8
{
LayerTransformation::createParamsU8I8(),
@ -429,6 +454,28 @@ std::vector<MatMullTransformationTestValues> testValues = {
}
},
// support3DTensorOnActivations = false, but 2D tensor is used
{
LayerTransformation::createParamsU8I8().setSupport3DTensorOnActivations(false),
{
{ 1, 2048 },
ngraph::element::u8,
{ ngraph::element::f32, {}, { 0.02f } },
{ std::vector<float>(2048 * 1000, 1.f), ngraph::element::f32, { 2048, 1000 }},
{ 255, { 1, 1 }, {0.f}, {254.f}, {-12.7f}, {12.7} },
{}
},
{
{ 1, 2048 },
ngraph::element::u8,
{},
{ std::vector<float>(2048 * 1000, -126), ngraph::element::i8, { 2048, 1000 }},
ngraph::element::i8,
{ {}, {}, { 0.02f * 0.1f } },
{}
}
},
// 2D: I8 & I8
{
LayerTransformation::createParamsI8I8(),
@ -542,7 +589,7 @@ std::vector<MatMullTransformationTestValues> testValues = {
{},
{}
}
},
}
};
INSTANTIATE_TEST_CASE_P(

View File

@ -20,6 +20,8 @@ std::vector<MatMulWithConstantTransformationTestValues> testValues = {
{ std::vector<float>(4 * 2, 2.f), ngraph::element::f32, ngraph::Shape{ 2, 4 } },
{ 256ul, {{1}, {1}, {2, 1}, {2, 1}}, {-128.f}, {127.f}, {-128.f, -12.8f}, {127.f, 12.7f} },
{ {}, {}, {} },
"result_result",
"FP32"
},
{
{ 2, 3, 4 },
@ -27,6 +29,8 @@ std::vector<MatMulWithConstantTransformationTestValues> testValues = {
{ std::vector<float>(4 * 2, 2.f), ngraph::element::i8, ngraph::Shape{ 2, 4 } },
{},
{ ngraph::element::f32, {}, {0.1f} },
"result_result",
"FP32"
},
{
{ 1, 3, 4 },
@ -34,6 +38,8 @@ std::vector<MatMulWithConstantTransformationTestValues> testValues = {
{ std::vector<float>(4 * 2, 2.f), ngraph::element::f32, ngraph::Shape{ 2, 4 } },
{ 256ul, {{1}, {1}, {2, 1}, {2, 1}}, {-128.f}, {127.f}, {-128.f, -12.8f}, {127.f, 12.7f} },
{ {}, {}, {} },
"result_result",
"FP32"
},
{
{ 1, 1, 3, 4 },
@ -41,6 +47,8 @@ std::vector<MatMulWithConstantTransformationTestValues> testValues = {
{ std::vector<float>(4 * 2, 2.f), ngraph::element::f32, ngraph::Shape{ 2, 4 } },
{ 256ul, {{1}, {1}, {2, 1}, {2, 1}}, {-128.f}, {127.f}, {-128.f, -12.8f}, {127.f, 12.7f} },
{ {}, {}, {} },
"matMul",
"U8"
},
{
{ 1, 1, 3, 4 },
@ -48,6 +56,8 @@ std::vector<MatMulWithConstantTransformationTestValues> testValues = {
{ std::vector<float>(4 * 2, 2.f), ngraph::element::i8, ngraph::Shape{ 2, 4 } },
{},
{ ngraph::element::f32, {}, {{0.1f, 0.01}, ngraph::element::f32, ngraph::Shape{ 2, 1 }} },
"matMul",
"U8"
},
{
{ 1, 3, 4 },
@ -55,6 +65,8 @@ std::vector<MatMulWithConstantTransformationTestValues> testValues = {
{ std::vector<float>(4 * 4, 2.f), ngraph::element::f32, ngraph::Shape{ 4, 4 } },
{ 256ul, {{1}, {1}, {1}, {1}}, {-128.f}, {127.f}, {-128.f}, {127.f} },
{ {}, {}, {} },
"result_result",
"FP32"
},
{
{ 2, 3 },
@ -62,6 +74,8 @@ std::vector<MatMulWithConstantTransformationTestValues> testValues = {
{ std::vector<float>{1, 2, 3, 4, 5, 6}, ngraph::element::f32, ngraph::Shape{ 2, 3 } },
{ 256ul, {{1}, {1}, {1}, {1}}, {-128.f}, {127.f}, {-12.8f}, {12.7f} },
{ {}, {}, {} },
"matMul",
"U8"
},
{
{ 2, 3 },

View File

@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation
// Copyright (C) 2020-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
@ -327,7 +327,9 @@ std::shared_ptr<ngraph::Function> MatMulFunction::getOriginal(
true);
matMul->set_friendly_name("matMul");
const auto result = std::make_shared<ngraph::opset1::Result>(matMul);
const std::shared_ptr<ngraph::opset1::Result> result = std::make_shared<ngraph::opset1::Result>(matMul);
result->set_friendly_name("result");
std::shared_ptr<ngraph::Function> function = std::make_shared<ngraph::Function>(
ngraph::ResultVector{ result },
std::vector<std::shared_ptr<ngraph::op::Parameter>> { input },