LPT opset12::Pad negative indexes support (#19430)

* changed unit tests

* add unit tests; fixed

* code review fixes

* remove debugging

* remove debug code

* add tests to ov_cpu_func_tests

* add negative padding tests to ov_gpu_func_tests

* code review fixes: change point to check positive indexes; check Pad mode in the list of currently supported

* code review fix: move check in canBeTransformed
This commit is contained in:
Evgeny Kotov authored and GitHub committed 2023-09-25 18:59:16 +00:00
1 parent 999e9ef9ad
commit d6d6888d7a
7 files changed
+523 -99

No files matched your search

@@ -37,6 +37,18 @@ PadTransformation::PadTransformation(const Params& params) : LayerTransformation
this->register_matcher(m, callback);
}
namespace {
bool hasPositiveIndexes(const std::shared_ptr<ov::op::util::PadBase>& pad) {
const auto padsBegin = pad->get_pads_begin();
const auto padsEnd = pad->get_pads_end();
auto pred = [](int64_t a) {
return a > 0;
};
return std::any_of(padsBegin.begin(), padsBegin.end(), pred) ||
std::any_of(padsEnd.begin(), padsEnd.end(), pred);
}
} // namespace
bool PadTransformation::transform(TransformationContext& context, ov::pass::pattern::Matcher& m) {
if (!canBeTransformed(context, m.get_match_root())) {
return false;
@@ -52,7 +64,7 @@ bool PadTransformation::transform(TransformationContext& context, ov::pass::patt
auto dequantization = NetworkHelper::getDequantization(pad, defaultPrecisions);
if (padMode == op::PadMode::CONSTANT) {
if (padMode == op::PadMode::CONSTANT && hasPositiveIndexes(pad)) {
auto bcastConstant = [&](const std::shared_ptr<ov::opset1::Constant> &constant) {
size_t padIdx = 0;
for (size_t i = 0; i < padsBegin.size(); ++i) {
@@ -94,8 +106,8 @@ bool PadTransformation::transform(TransformationContext& context, ov::pass::patt
return NetworkHelper::toScalar(constant);
}
std::vector<size_t> padsForConstantBegin(constantShape.size(), 0ul);
std::vector<size_t> padsForConstantEnd(constantShape.size(), 0ul);
std::vector<int64_t> padsForConstantBegin(constantShape.size(), 0ul);
std::vector<int64_t> padsForConstantEnd(constantShape.size(), 0ul);
bool foldingIsNecessary = false;
// folding is necessary when dequantization and padding by the same dimension
@@ -112,9 +124,10 @@ bool PadTransformation::transform(TransformationContext& context, ov::pass::patt
}
if (foldingIsNecessary) {
const auto beginConst = ov::opset1::Constant::create(element::u32, { padsForConstantBegin.size() }, padsForConstantBegin);
const auto endConst = ov::opset1::Constant::create(element::u32, { padsForConstantEnd.size() }, padsForConstantEnd);
const auto beginConst = ov::opset1::Constant::create(element::i32, { padsForConstantBegin.size() }, padsForConstantBegin);
const auto endConst = ov::opset1::Constant::create(element::i32, { padsForConstantEnd.size() }, padsForConstantEnd);
const auto padValueConstant = ov::opset1::Constant::create(constant->get_element_type(), Shape{}, { padVal });
const auto foldedConstant = fold<ov::opset12::Pad>(constant, beginConst, endConst, padValueConstant, padMode);
return ov::as_type_ptr<ov::opset1::Constant>(foldedConstant);
} else {
@@ -151,24 +164,10 @@ bool PadTransformation::transform(TransformationContext& context, ov::pass::patt
pad->set_argument(3, convertedZero);
moveDequantizationAfter(context, pad, dequantization, true);
return true;
}
namespace {
bool hasNegativeIndexes(const std::shared_ptr<ov::op::util::PadBase>& pad) {
const auto padsBegin = pad->get_pads_begin();
const auto padsEnd = pad->get_pads_end();
auto pred = [](int64_t a) {
return a < 0;
};
if (std::any_of(padsBegin.begin(), padsBegin.end(), pred) ||
std::any_of(padsEnd.begin(), padsEnd.end(), pred)) {
return true;
}
return false;
}
} // namespace
bool PadTransformation::canBeTransformed(const TransformationContext& context, std::shared_ptr<Node> op) const {
if (!LayerTransformation::canBeTransformedSpatialDimension(context, op)) {
return false;
@@ -179,7 +178,11 @@ bool PadTransformation::canBeTransformed(const TransformationContext& context, s
return false;
}
if (hasNegativeIndexes(pad)) {
const auto mode = pad->get_pad_mode();
if (mode != op::PadMode::CONSTANT &&
mode != op::PadMode::EDGE &&
mode != op::PadMode::REFLECT &&
mode != op::PadMode::SYMMETRIC) {
return false;
}
@@ -188,7 +191,9 @@ bool PadTransformation::canBeTransformed(const TransformationContext& context, s
return false;
}
const auto mode = pad->get_pad_mode();
if (!hasPositiveIndexes(pad))
return true;
if (mode == op::PadMode::CONSTANT) {
auto padAndDqByTheSameDimension = [&](const std::shared_ptr<ov::opset1::Constant>& deqConst) {
const auto padsBegin = pad->get_pads_begin();
@@ -16,7 +16,6 @@
#include "lpt_ngraph_functions/pad_function.hpp"
#include "simple_low_precision_transformer.hpp"
namespace {
using namespace testing;
using namespace ov;
@@ -45,8 +44,8 @@ public:
typedef std::tuple <
ov::PartialShape, // input Shape
std::pair<std::vector<uint64_t>, std::vector<uint64_t>>, // pads begin, pads end
ngraph::op::PadMode, // pads mode
std::pair<std::vector<int64_t>, std::vector<int64_t>>, // pads begin, pads end
ov::op::PadMode, // pads mode
float, // pads value (used if mode == CONSTANT)
PadTransformationTestValues> PadTransformationParams;
@@ -55,7 +54,7 @@ public:
void SetUp() override {
const ov::PartialShape inputShape = std::get<0>(GetParam());
const auto pads = std::get<1>(GetParam());
const ngraph::op::PadMode padsMode = std::get<2>(GetParam());
const ov::op::PadMode padsMode = std::get<2>(GetParam());
const float padsValue = std::get<3>(GetParam());
const PadTransformationTestValues testValues = std::get<4>(GetParam());
@@ -92,13 +91,13 @@ public:
static std::string getTestCaseName(testing::TestParamInfo<PadTransformationParams> obj) {
const ov::PartialShape inputShape = std::get<0>(obj.param);
const auto pads = std::get<1>(obj.param);
const ngraph::op::PadMode padsMode = std::get<2>(obj.param);
const ov::op::PadMode padsMode = std::get<2>(obj.param);
const float padsValue = std::get<3>(obj.param);
const PadTransformationTestValues testValues = std::get<4>(obj.param);
std::ostringstream result;
result << "mode_" << padsMode << "_";
if (padsMode == ngraph::op::PadMode::CONSTANT) {
if (padsMode == ov::op::PadMode::CONSTANT) {
result << "pad_value_{ " << padsValue << " }";
}
@@ -106,8 +105,9 @@ public:
toString(testValues.params) << "_" <<
inputShape << "_" << pads.first << "_" << pads.second << "_" <<
testValues.actual.precisionBeforeDequantization << "_" <<
testValues.actual.dequantization << "_" <<
testValues.expected.dequantizationBefore;
testValues.actual.dequantization << "_expected_dequantizationBefore_" <<
testValues.expected.dequantizationBefore << "_expected_dequantizationAfter_" <<
testValues.expected.dequantizationAfter;
return result.str();
}
@@ -127,11 +127,24 @@ const std::vector<ov::PartialShape> inputShapes = {
{-1, 3, 6, -1}
};
const std::pair<std::vector<uint64_t>, std::vector<uint64_t>> padsBySpatialDimensions = {
{0, 0, 2, 1},
{0, 0, 1, 2}
const std::vector<std::pair<std::vector<int64_t>, std::vector<int64_t>>> padsBySpatialDimensions = {
{{0, 0, 2, 1}, {0, 0, 1, 2}},
{{0, 0, -1, -1}, {0, 0, 2, 2}}
};
const std::pair<std::vector<int64_t>, std::vector<int64_t>> padsPositiveBySpatialDimensions = {
{0, 0, 2, 1}, {0, 0, 1, 2}
};
const std::pair<std::vector<int64_t>, std::vector<int64_t>> padsNegativeBySpatialDimensions = {
{0, 0, -2, -1}, {0, 0, -1, -2}
};
const std::pair<std::vector<int64_t>, std::vector<int64_t>> padsMixedBySpatialDimensions = {
{0, 0, 2, -1}, {0, 0, -1, 2}
};
// test-cases with common logic for all modes
// (per-tensor & per-channel quantizations without subtracts, pads by spatial dimensions)
// and test-case without dequantization
@@ -141,11 +154,11 @@ const std::vector<ov::PartialShape> commonInputShapes = {
{-1, -1, -1, -1}
};
std::vector<ngraph::op::PadMode> allModes = {
ngraph::op::PadMode::EDGE,
ngraph::op::PadMode::REFLECT,
ngraph::op::PadMode::SYMMETRIC,
ngraph::op::PadMode::CONSTANT,
std::vector<ov::op::PadMode> allModes = {
ov::op::PadMode::EDGE,
ov::op::PadMode::REFLECT,
ov::op::PadMode::SYMMETRIC,
ov::op::PadMode::CONSTANT,
};
const std::vector<PadTransformationTestValues> deqWithoutSub = {
@@ -247,7 +260,7 @@ INSTANTIATE_TEST_SUITE_P(
PadTransformation,
::testing::Combine(
::testing::ValuesIn(commonInputShapes),
::testing::Values(padsBySpatialDimensions),
::testing::ValuesIn(padsBySpatialDimensions),
::testing::ValuesIn(allModes),
::testing::Values(0.f),
::testing::ValuesIn(deqWithoutSub)),
@@ -257,10 +270,10 @@ INSTANTIATE_TEST_SUITE_P(
// test-cases with common logic for "EDGE", "REFLECT", and "SYMMETRIC" modes:
// pads by spatial dimensions, dequantization with subtract
namespace dqWithSubtract {
std::vector<ngraph::op::PadMode> modesInWhichSubPropagated = {
ngraph::op::PadMode::EDGE,
ngraph::op::PadMode::REFLECT,
ngraph::op::PadMode::SYMMETRIC,
std::vector<ov::op::PadMode> modesInWhichSubPropagated = {
ov::op::PadMode::EDGE,
ov::op::PadMode::REFLECT,
ov::op::PadMode::SYMMETRIC,
};
const std::vector<PadTransformationTestValues> deqWithSub = {
@@ -345,7 +358,7 @@ INSTANTIATE_TEST_SUITE_P(
PadTransformation,
::testing::Combine(
::testing::ValuesIn(inputShapes),
::testing::Values(padsBySpatialDimensions),
::testing::ValuesIn(padsBySpatialDimensions),
::testing::ValuesIn(modesInWhichSubPropagated),
::testing::Values(0.f),
::testing::ValuesIn(deqWithSub)),
@@ -354,6 +367,7 @@ INSTANTIATE_TEST_SUITE_P(
// dequantization with subtract and "CONSTANT" mode, also dequantization and padding by the same dimension
namespace testCasesForConstantMode {
namespace positive {
const std::vector<PadTransformationTestValues> testValuesForConstantMode = {
{
LayerTransformation::createParamsI8I8(),
@@ -393,8 +407,24 @@ const std::vector<PadTransformationTestValues> testValuesForConstantMode = {
ov::element::f32,
{{}, {}, {}}
}
},
{
}
};
INSTANTIATE_TEST_SUITE_P(
smoke_LPT,
PadTransformation,
::testing::Combine(
::testing::ValuesIn(inputShapes),
::testing::Values(padsPositiveBySpatialDimensions),
::testing::Values(ov::op::PadMode::CONSTANT),
::testing::Values(0.f),
::testing::ValuesIn(testValuesForConstantMode)),
PadTransformation::getTestCaseName);
} // namespace positive
namespace negative {
const std::vector<PadTransformationTestValues> testValuesForConstantMode = {
{
LayerTransformation::createParamsU8I8(),
{
ov::element::u8,
@@ -404,27 +434,58 @@ const std::vector<PadTransformationTestValues> testValuesForConstantMode = {
ov::element::u8,
{{}, {}, {}},
ov::element::u8,
{{ov::element::f32}, {}, {{1.f, 1.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 1.f}, ov::element::f32, {1, 1, 9, 1}}}
{{ov::element::f32}, {}, {{3.f, 4.f, 5.f}, ov::element::f32, {1, 1, 3, 1}}}
}
}
};
}
};
INSTANTIATE_TEST_SUITE_P(
INSTANTIATE_TEST_SUITE_P(
smoke_LPT,
PadTransformation,
::testing::Combine(
::testing::ValuesIn(inputShapes),
::testing::Values(padsBySpatialDimensions),
::testing::Values(ngraph::op::PadMode::CONSTANT),
::testing::Values(padsNegativeBySpatialDimensions),
::testing::Values(ov::op::PadMode::CONSTANT),
::testing::Values(0.f),
::testing::ValuesIn(testValuesForConstantMode)),
PadTransformation::getTestCaseName);
}
namespace mixed {
const std::vector<PadTransformationTestValues> testValuesForConstantMode = {
{
LayerTransformation::createParamsU8I8(),
{
ov::element::u8,
{{ov::element::f32}, {}, {{1.f, 2.f, 3.f, 4.f, 5.f, 6.f}, ov::element::f32, {1, 1, 6, 1}}}
},
{
ov::element::u8,
{{}, {}, {}},
ov::element::u8,
{{ov::element::f32}, {}, {{1.f, 1.f, 1.f, 2.f, 3.f, 4.f, 5.f}, ov::element::f32, {1, 1, 7, 1}}}
}
}
};
INSTANTIATE_TEST_SUITE_P(
smoke_LPT,
PadTransformation,
::testing::Combine(
::testing::ValuesIn(inputShapes),
::testing::Values(padsMixedBySpatialDimensions),
::testing::Values(ov::op::PadMode::CONSTANT),
::testing::Values(0.f),
::testing::ValuesIn(testValuesForConstantMode)),
PadTransformation::getTestCaseName);
}
} // namespace testCasesForConstantMode
// dequantization with "CONSTANT" mode (non zero value) and non unique pad dimension: dequantization isn't propagated
namespace testCasesForConstantModeWithNonZeroValues {
const std::vector<PadTransformationTestValues> testValuesForConstantMode2 = {
{
{
LayerTransformation::createParamsI8I8(),
{
ov::element::i8,
@@ -470,17 +531,17 @@ INSTANTIATE_TEST_SUITE_P(
PadTransformation,
::testing::Combine(
::testing::ValuesIn(inputShapes),
::testing::Values(padsBySpatialDimensions),
::testing::Values(ngraph::op::PadMode::CONSTANT),
::testing::ValuesIn(padsBySpatialDimensions),
::testing::Values(ov::op::PadMode::CONSTANT),
::testing::Values(1.f),
::testing::ValuesIn(testValuesForConstantMode2)),
PadTransformation::getTestCaseName);
} // namespace testCasesForConstantModeWithNonZeroValues
namespace testCasesForConstantModeAndUniquePadDimension {
const std::pair<std::vector<uint64_t>, std::vector<uint64_t>> padsByUniqueDimension = {
{0, 0, 2, 0},
{0, 0, 1, 0}
namespace positive {
const std::pair<std::vector<int64_t>, std::vector<int64_t>> padsPositiveByUniqueDimension = {
{0, 0, 2, 0}, {0, 0, 1, 0}
};
const std::vector<PadTransformationTestValues> testValuesForConstantMode = {
@@ -504,7 +565,8 @@ const std::vector<PadTransformationTestValues> testValuesForConstantMode = {
{{1.f, 1.f, 3.f, 3.f, 3.f, 2.f, 2.f, 2.f, 1.f}, ov::element::f32, {1, 1, 9, 1}}
}
}
},
}
,
{
LayerTransformation::createParamsI8I8(),
{
@@ -533,15 +595,121 @@ INSTANTIATE_TEST_SUITE_P(
PadTransformation,
::testing::Combine(
::testing::ValuesIn(inputShapes),
::testing::Values(padsByUniqueDimension),
::testing::Values(ngraph::op::PadMode::CONSTANT),
::testing::Values(padsPositiveByUniqueDimension),
::testing::Values(ov::op::PadMode::CONSTANT),
::testing::Values(0.f),
::testing::ValuesIn(testValuesForConstantMode)),
PadTransformation::getTestCaseName);
} // namespace positive
namespace negative {
const std::pair<std::vector<int64_t>, std::vector<int64_t>> padsNegativeByUniqueDimension = {
{0, 0, -2, 0}, {0, 0, -1, 0}
};
const std::vector<PadTransformationTestValues> testValuesForConstantMode = {
{
LayerTransformation::createParamsI8I8(),
{
ov::element::i8,
{
{ov::element::f32},
{{64.f, 64.f, 64.f, 32.f, 32.f, 32.f}, ov::element::f32, {1, 1, 6, 1}},
{{3.f, 3.f, 3.f, 2.f, 2.f, 2.f}, ov::element::f32, {1, 1, 6, 1}}
}
},
{
ov::element::i8,
{},
ov::element::i8,
{
{ov::element::f32},
{{64.f, 32.f, 32.f}, ov::element::f32, {1, 1, 3, 1}},
{{3.f, 2.f, 2.f}, ov::element::f32, {1, 1, 3, 1}}
}
}
}
,
{
LayerTransformation::createParamsI8I8(),
{
ov::element::i8,
{
{ov::element::f32},
{64.f},
{3.f}
}
},
{
ov::element::i8,
{},
ov::element::i8,
{
{ov::element::f32},
{64.f},
{3.f}
}
}
},
};
INSTANTIATE_TEST_SUITE_P(
smoke_LPT,
PadTransformation,
::testing::Combine(
::testing::ValuesIn(inputShapes),
::testing::Values(padsNegativeByUniqueDimension),
::testing::Values(ov::op::PadMode::CONSTANT),
::testing::Values(0.f),
::testing::ValuesIn(testValuesForConstantMode)),
PadTransformation::getTestCaseName);
} // namespace negative
namespace mixed {
const std::pair<std::vector<int64_t>, std::vector<int64_t>> padsMixedByUniqueDimension = {
{0, 0, 2, 0}, {0, 0, -1, 0}
};
const std::vector<PadTransformationTestValues> testValuesForConstantMode = {
{
LayerTransformation::createParamsI8I8(),
{
ov::element::i8,
{
{ov::element::f32},
{{64.f, 64.f, 64.f, 32.f, 32.f, 32.f}, ov::element::f32, {1, 1, 6, 1}},
{{3.f, 3.f, 3.f, 2.f, 2.f, 2.f}, ov::element::f32, {1, 1, 6, 1}}
}
},
{
ov::element::i8,
{},
ov::element::i8,
{
{ov::element::f32},
{{0.f, 0.f, 64.f, 64.f, 64.f, 32.f, 32.f}, ov::element::f32, {1, 1, 7, 1}},
{{1.f, 1.f, 3.f, 3.f, 3.f, 2.f, 2.f}, ov::element::f32, {1, 1, 7, 1}}
}
}
}
};
INSTANTIATE_TEST_SUITE_P(
smoke_LPT,
PadTransformation,
::testing::Combine(
::testing::ValuesIn(inputShapes),
::testing::Values(padsMixedByUniqueDimension),
::testing::Values(ov::op::PadMode::CONSTANT),
::testing::Values(0.f),
::testing::ValuesIn(testValuesForConstantMode)),
PadTransformation::getTestCaseName);
} // namespace mixed
} // namespace testCasesForConstantModeAndUniquePadDimension
namespace testCasesForNonZeroConstantModeAndUniquePadDimension {
const std::pair<std::vector<uint64_t>, std::vector<uint64_t>> padsByUniqueDimension = {
const std::pair<std::vector<int64_t>, std::vector<int64_t>> padsByUniqueDimension = {
{0, 0, 2, 0},
{0, 0, 1, 0}
};
@@ -597,13 +765,13 @@ INSTANTIATE_TEST_SUITE_P(
::testing::Combine(
::testing::ValuesIn(inputShapes),
::testing::Values(padsByUniqueDimension),
::testing::Values(ngraph::op::PadMode::CONSTANT),
::testing::Values(ov::op::PadMode::CONSTANT),
::testing::Values(2.f),
::testing::ValuesIn(testValuesForConstantMode)),
PadTransformation::getTestCaseName);
} // namespace testCasesForNonZeroConstantModeAndUniquePadDimension
namespace testCasesForEdgeMode {
namespace testCasesForEdgeModePostitive {
const std::vector<PadTransformationTestValues> testValuesForEdgeMode = {
{
LayerTransformation::createParamsI8I8(),
@@ -633,12 +801,86 @@ INSTANTIATE_TEST_SUITE_P(
PadTransformation,
::testing::Combine(
::testing::ValuesIn(inputShapes),
::testing::Values(padsBySpatialDimensions),
::testing::Values(ngraph::op::PadMode::EDGE),
::testing::Values(padsPositiveBySpatialDimensions),
::testing::Values(ov::op::PadMode::EDGE),
::testing::Values(0.f),
::testing::ValuesIn(testValuesForEdgeMode)),
PadTransformation::getTestCaseName);
} // namespace testCasesForEdgeMode
} // namespace testCasesForEdgeModePostitive
namespace testCasesForEdgeModeNegative {
const std::vector<PadTransformationTestValues> testValuesForEdgeMode = {
{
LayerTransformation::createParamsI8I8(),
{
ov::element::i8,
{
{ov::element::f32},
{{1.f, 2.f, 3.f, 4.f, 5.f, 6.f}, ov::element::f32, {1, 1, 6, 1}},
{{1.f, 2.f, 3.f, 4.f, 5.f, 6.f}, ov::element::f32, {1, 1, 6, 1}}
}
},
{
ov::element::i8,
{{}, {}, {}},
ov::element::i8,
{
{ov::element::f32},
{{3.f, 4.f, 5.f}, ov::element::f32, {1, 1, 3, 1}},
{{3.f, 4.f, 5.f}, ov::element::f32, {1, 1, 3, 1}}
}
}
},
};
INSTANTIATE_TEST_SUITE_P(
smoke_LPT,
PadTransformation,
::testing::Combine(
::testing::ValuesIn(inputShapes),
::testing::Values(padsNegativeBySpatialDimensions),
::testing::Values(ov::op::PadMode::EDGE),
::testing::Values(0.f),
::testing::ValuesIn(testValuesForEdgeMode)),
PadTransformation::getTestCaseName);
} // namespace testCasesForEdgeModeNegative
namespace testCasesForEdgeModeMixed {
const std::vector<PadTransformationTestValues> testValuesForEdgeMode = {
{
LayerTransformation::createParamsI8I8(),
{
ov::element::i8,
{
{ov::element::f32},
{{1.f, 2.f, 3.f, 4.f, 5.f, 6.f}, ov::element::f32, {1, 1, 6, 1}},
{{1.f, 2.f, 3.f, 4.f, 5.f, 6.f}, ov::element::f32, {1, 1, 6, 1}}
}
},
{
ov::element::i8,
{{}, {}, {}},
ov::element::i8,
{
{ov::element::f32},
{{1.f, 1.f, 1.f, 2.f, 3.f, 4.f, 5.f}, ov::element::f32, {1, 1, 7, 1}},
{{1.f, 1.f, 1.f, 2.f, 3.f, 4.f, 5.f}, ov::element::f32, {1, 1, 7, 1}}
}
}
},
};
INSTANTIATE_TEST_SUITE_P(
smoke_LPT,
PadTransformation,
::testing::Combine(
::testing::ValuesIn(inputShapes),
::testing::Values(padsMixedBySpatialDimensions),
::testing::Values(ov::op::PadMode::EDGE),
::testing::Values(0.f),
::testing::ValuesIn(testValuesForEdgeMode)),
PadTransformation::getTestCaseName);
} // namespace testCasesForEdgeModeMixed
namespace testCasesForReflectMode {
const std::vector<PadTransformationTestValues> testValuesForReflectMode = {
@@ -670,14 +912,15 @@ INSTANTIATE_TEST_SUITE_P(
PadTransformation,
::testing::Combine(
::testing::ValuesIn(inputShapes),
::testing::Values(padsBySpatialDimensions),
::testing::Values(ngraph::op::PadMode::REFLECT),
::testing::ValuesIn(padsBySpatialDimensions),
::testing::Values(ov::op::PadMode::REFLECT),
::testing::Values(0.f),
::testing::ValuesIn(testValuesForReflectMode)),
PadTransformation::getTestCaseName);
} // namespace testCasesForReflectMode
namespace testCasesForSymetricMode {
namespace testCasesForSymetricModePositive {
const std::vector<PadTransformationTestValues> testValuesForSymetricMode = {
{
LayerTransformation::createParamsI8I8(),
@@ -689,6 +932,7 @@ const std::vector<PadTransformationTestValues> testValuesForSymetricMode = {
{{1.f, 2.f, 3.f, 4.f, 5.f, 6.f}, ov::element::f32, {1, 1, 6, 1}}
}
},
{
ov::element::i8,
{{}, {}, {}},
@@ -707,23 +951,99 @@ INSTANTIATE_TEST_SUITE_P(
PadTransformation,
::testing::Combine(
::testing::ValuesIn(inputShapes),
::testing::Values(padsBySpatialDimensions),
::testing::Values(ngraph::op::PadMode::SYMMETRIC),
::testing::Values(padsPositiveBySpatialDimensions),
::testing::Values(ov::op::PadMode::SYMMETRIC),
::testing::Values(0.f),
::testing::ValuesIn(testValuesForSymetricMode)),
PadTransformation::getTestCaseName);
} // namespace testCasesForSymetricMode
} // namespace testCasesForSymetricModePositive
namespace testCasesForSymetricModeNegative {
const std::vector<PadTransformationTestValues> testValuesForSymetricMode = {
{
LayerTransformation::createParamsI8I8(),
{
ov::element::i8,
{
{ov::element::f32},
{{1.f, 2.f, 3.f, 4.f, 5.f, 6.f}, ov::element::f32, {1, 1, 6, 1}},
{{1.f, 2.f, 3.f, 4.f, 5.f, 6.f}, ov::element::f32, {1, 1, 6, 1}}
}
},
{
ov::element::i8,
{{}, {}, {}},
ov::element::i8,
{
{ov::element::f32},
{{3.f, 4.f, 5.f}, ov::element::f32, {1, 1, 3, 1}},
{{3.f, 4.f, 5.f}, ov::element::f32, {1, 1, 3, 1}}
}
}
},
};
INSTANTIATE_TEST_SUITE_P(
smoke_LPT,
PadTransformation,
::testing::Combine(
::testing::ValuesIn(inputShapes),
::testing::Values(padsNegativeBySpatialDimensions),
::testing::Values(ov::op::PadMode::SYMMETRIC),
::testing::Values(0.f),
::testing::ValuesIn(testValuesForSymetricMode)),
PadTransformation::getTestCaseName);
} // namespace testCasesForSymetricModeNegative
namespace testCasesForSymetricModeMixed {
const std::vector<PadTransformationTestValues> testValuesForSymetricMode = {
{
LayerTransformation::createParamsI8I8(),
{
ov::element::i8,
{
{ov::element::f32},
{{1.f, 2.f, 3.f, 4.f, 5.f, 6.f}, ov::element::f32, {1, 1, 6, 1}},
{{1.f, 2.f, 3.f, 4.f, 5.f, 6.f}, ov::element::f32, {1, 1, 6, 1}}
}
},
{
ov::element::i8,
{{}, {}, {}},
ov::element::i8,
{
{ov::element::f32},
{{2.f, 1.f, 1.f, 2.f, 3.f, 4.f, 5.f}, ov::element::f32, {1, 1, 7, 1}},
{{2.f, 1.f, 1.f, 2.f, 3.f, 4.f, 5.f}, ov::element::f32, {1, 1, 7, 1}}
}
}
},
};
INSTANTIATE_TEST_SUITE_P(
smoke_LPT,
PadTransformation,
::testing::Combine(
::testing::ValuesIn(inputShapes),
::testing::Values(padsMixedBySpatialDimensions),
::testing::Values(ov::op::PadMode::SYMMETRIC),
::testing::Values(0.f),
::testing::ValuesIn(testValuesForSymetricMode)),
PadTransformation::getTestCaseName);
} // namespace testCasesForSymetricModeMixed
namespace testCasesWithDynamicRank {
const std::vector<ov::PartialShape> inputShapesWithDynamicRank = {
ov::PartialShape::dynamic()
};
std::vector<ngraph::op::PadMode> allModes = {
ngraph::op::PadMode::EDGE,
ngraph::op::PadMode::REFLECT,
ngraph::op::PadMode::SYMMETRIC,
ngraph::op::PadMode::CONSTANT,
std::vector<ov::op::PadMode> allModes = {
ov::op::PadMode::EDGE,
ov::op::PadMode::REFLECT,
ov::op::PadMode::SYMMETRIC,
ov::op::PadMode::CONSTANT,
};
const std::vector<PadTransformationTestValues> testValuesForDynamicRank = {
@@ -760,7 +1080,7 @@ INSTANTIATE_TEST_SUITE_P(
PadTransformation,
::testing::Combine(
::testing::ValuesIn(inputShapesWithDynamicRank),
::testing::Values(padsBySpatialDimensions),
::testing::ValuesIn(padsBySpatialDimensions),
::testing::ValuesIn(allModes),
::testing::Values(0.f),
::testing::ValuesIn(testValuesForDynamicRank)),