diff --git a/src/plugins/intel_cpu/src/nodes/mkldnn_fake_quantize_node.cpp b/src/plugins/intel_cpu/src/nodes/mkldnn_fake_quantize_node.cpp index 4b3a4c3aee1..dec1a18f5a9 100644 --- a/src/plugins/intel_cpu/src/nodes/mkldnn_fake_quantize_node.cpp +++ b/src/plugins/intel_cpu/src/nodes/mkldnn_fake_quantize_node.cpp @@ -23,6 +23,7 @@ #include "memory_desc/dnnl_blocked_memory_desc.h" #include "utils/ngraph_utils.hpp" #include "common/cpu_memcpy.h" +#include // Quantization ranges validation is switched off by default in order to avoid regressions on user side // #define VALIDATE_QUANTIZATION_RANGES @@ -885,6 +886,31 @@ bool MKLDNNFakeQuantizeNode::isSupportedOperation(const std::shared_ptr& op, const mkldnn::engine& eng, MKLDNNWeightsSharing::Ptr &cache) : MKLDNNNode(op, eng, cache) { std::string errorMessage; @@ -1363,27 +1389,28 @@ void MKLDNNFakeQuantizeNode::prepareParams() { IE_THROW() << "CPU quantize node with name '" << getName() << "' doesn't have primitive descriptors."; if (selectedPrimitiveDescriptor->getImplementationType() != impl_desc_type::ref) { const auto& config = getSelectedPrimitiveDescriptor()->getConfig(); - const auto& inDims = getParentEdgesAtPort(0)[0]->getMemory().getStaticDims(); - - jit_quantize_params jqp = {}; - jqp.c = inDims.size() > 1 ? inDims[1] : 1; - - jqp.src_prc = config.inConfs[0].desc->getPrecision(); - jqp.wei_prc = Precision::FP32; - jqp.dst_prc = config.outConfs[0].desc->getPrecision(); + //Form FakeQuanKey + FakeQuantKey key = {}; + key.jqp.c = inDims.size() > 1 ? inDims[1] : 1; + key.jqp.src_prc = config.inConfs[0].desc->getPrecision(); + key.jqp.wei_prc = Precision::FP32; + key.jqp.dst_prc = config.outConfs[0].desc->getPrecision(); auto srcDesc = getParentEdgeAt(0)->getMemory().GetDescWithType(); - jqp.s_str = srcDesc->getStrides(); - + key.jqp.s_str = srcDesc->getStrides(); auto dstDesc = getChildEdgeAt(0)->getMemory().GetDescWithType(); - jqp.d_str = dstDesc->getStrides(); - jqp.is_planar = srcDesc->hasLayoutType(LayoutType::ncsp) && one_of(srcDesc->getShape().getRank(), 3, 4, 5); + key.jqp.d_str = dstDesc->getStrides(); + key.jqp.is_planar = srcDesc->hasLayoutType(LayoutType::ncsp) && one_of(srcDesc->getShape().getRank(), 3, 4, 5); + key.jqp.op_type = getAlgorithm(); - jqp.op_type = getAlgorithm(); - - execPtr = std::make_shared(jqp); + auto cache = getRuntimeCache(); + auto buildExecutor = [](const FakeQuantKey& key) { + return std::make_shared(key.jqp); + }; + auto result = cache->getOrCreate(key, buildExecutor); + execPtr = result.first; } } diff --git a/src/plugins/intel_cpu/src/nodes/mkldnn_pooling_node.cpp b/src/plugins/intel_cpu/src/nodes/mkldnn_pooling_node.cpp index 2de486d6f8d..afd8ad64312 100644 --- a/src/plugins/intel_cpu/src/nodes/mkldnn_pooling_node.cpp +++ b/src/plugins/intel_cpu/src/nodes/mkldnn_pooling_node.cpp @@ -15,11 +15,111 @@ #include #include #include "memory_desc/dnnl_blocked_memory_desc.h" +#include using namespace mkldnn; using namespace MKLDNNPlugin; using namespace InferenceEngine; +namespace { +struct PoolingKey { + DnnlMemoryDescCPtr inp; + DnnlMemoryDescCPtr out; + std::vector stride; + std::vector kernel; + /// Effective padding. Used to define correct output shape by MKLDNN + /// reshape formula: (iw - kernel + pad_l + pad_r) / strides[i - 2] + 1 + /// should be passed into pooling desc constructor. + std::vector effective_pad_begin; + std::vector effective_pad_end; + /// Effective dilation. Used to define correct dilation for OneDNN. + /// For OneDNN default dilation is vector of zero + std::vector effective_dilation; + std::vector data_pad_end; + mkldnn::primitive_attr attr; + algorithm alg; + impl_desc_type implType; + + size_t hash() const { + using namespace dnnl::impl; + using namespace dnnl::impl::primitive_hashing; + size_t seed = 0; + seed = hash_combine(seed, get_md_hash(inp->getDnnlDesc().data)); + seed = get_vector_hash(seed, stride); + seed = get_vector_hash(seed, kernel); + seed = get_vector_hash(seed, effective_pad_begin); + seed = get_vector_hash(seed, effective_pad_end); + seed = get_vector_hash(seed, effective_dilation); + seed = get_vector_hash(seed, data_pad_end); + seed = hash_combine(seed, get_md_hash(out->getDnnlDesc().data)); + seed = hash_combine(seed, get_attr_hash(*attr.get())); + seed = hash_combine(seed, alg); + seed = hash_combine(seed, implType); + return seed; + } + + bool operator==(const PoolingKey& rhs) const { + bool result = true; + if (inp != rhs.inp) { + result = result && inp && rhs.inp && (inp->getDnnlDesc() == rhs.inp->getDnnlDesc()); + } + + if (out != rhs.out) { + result = result && out && rhs.out && (out->getDnnlDesc() == rhs.out->getDnnlDesc()); + } + + result = result && stride == rhs.stride && kernel == rhs.kernel && + effective_pad_begin == rhs.effective_pad_begin && effective_pad_end == rhs.effective_pad_end && + effective_dilation == rhs.effective_dilation && data_pad_end == rhs.data_pad_end && + *attr.get() == *rhs.attr.get() && alg == rhs.alg && implType == rhs.implType; + return result; + } +}; + +std::shared_ptr createDescriptorHelper(const mkldnn::memory::desc& in_candidate, + const mkldnn::memory::desc& out_candidate, + const mkldnn::algorithm alg, + const std::vector& stride, + const std::vector& kernel, + const std::vector& effective_pad_begin, + const std::vector& effective_pad_end, + const std::vector& effective_dilation, + const std::vector& data_pad_end) { + if (alg == mkldnn::algorithm::undef) { + IE_THROW() << "Unsupported pooling type"; + } + + auto convert = [](std::vector orig_dims) { + return memory::dims(orig_dims.begin(), orig_dims.end()); + }; + std::shared_ptr desc_ptr(new pooling_v2_forward::desc(prop_kind::forward_scoring, + alg, + in_candidate, + out_candidate, + convert(stride), + convert(kernel), + convert(effective_dilation), + convert(effective_pad_begin), + convert(effective_pad_end))); + + if (alg == mkldnn::algorithm::pooling_avg_include_padding) { + // In case of AVG including paddings the norm coeff should be calculated + // with tacking into account original pads. So we need to restore + // original values for end paddings. + // + // WA. Because mkldnn uses different formula to calculate AVG norm coeff + // in compare with Caffe. In mkldnn coeff is always 1/(KH*KW) + for (int i = 0; i < data_pad_end.size(); i++) { + if (data_pad_end[i] != effective_pad_end[i]) + desc_ptr->data.padding[1][i] = static_cast(data_pad_end[i]); + } + } + + return desc_ptr; +} + +} // namespace + bool MKLDNNPoolingNode::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { if (ov::is_type(op)) { @@ -239,9 +339,7 @@ void MKLDNNPoolingNode::prepareParams() { } auto inDesc = getParentEdgesAtPort(0)[0]->getMemory().GetDescWithType(); - const auto& in_candidate = inDesc->getDnnlDesc(); auto outDesc = getChildEdgesAtPort(0)[0]->getMemory().GetDescWithType(); - const auto& out_candidate = outDesc->getDnnlDesc(); if (isDynamicNode()) { if (auto_pad) { @@ -251,22 +349,52 @@ void MKLDNNPoolingNode::prepareParams() { } mkldnn::algorithm alg = getPoolingAlgorithm(); - MKLDNNDescriptor desc{createDescriptorInternal(in_candidate, out_candidate, alg)}; - pooling_v2_forward::primitive_desc prim_desc; - primitive_desc_iterator itpd = desc.createPrimitiveDescriptorIterator(getEngine(), *attr); + PoolingKey key = {inDesc, + outDesc, + stride, + kernel, + effective_pad_begin, + effective_pad_end, + effective_dilation, + data_pad_end, + *attr, + alg, + selected_pd->getImplementationType()}; + auto engine = getEngine(); + auto builder = [&engine](const PoolingKey& key) -> std::shared_ptr { + auto desc_ptr = createDescriptorHelper(key.inp->getDnnlDesc(), + key.out->getDnnlDesc(), + key.alg, + key.stride, + key.kernel, + key.effective_pad_begin, + key.effective_pad_end, + key.effective_dilation, + key.data_pad_end); + MKLDNNDescriptor desc{desc_ptr}; + pooling_v2_forward::primitive_desc prim_desc; + primitive_desc_iterator itpd = desc.createPrimitiveDescriptorIterator(engine, key.attr); + while (static_cast(itpd)) { + impl_desc_type impl_type = parse_impl_name(itpd.impl_info_str()); - while (static_cast(itpd)) { - impl_desc_type impl_type = parse_impl_name(itpd.impl_info_str()); - - if (impl_type == selected_pd->getImplementationType()) { - prim_desc = itpd.get(); - break; + if (impl_type == key.implType) { + prim_desc = itpd.get(); + break; + } + if (!itpd.next_impl()) + return nullptr; } - if (!itpd.next_impl()) - IE_THROW() << "Primitive descriptor was not found for node " << getName() << "."; + return std::make_shared(prim_desc); + }; + + auto cache = getRuntimeCache(); + auto result = cache->getOrCreate(key, builder); + + if (!result.first) { + IE_THROW() << "Primitive descriptor was not found for node " << getName() << "."; } - prim.reset(new pooling_v2_forward(prim_desc)); + prim = result.first; auto src = getParentEdgesAtPort(0)[0]->getMemoryPtr()->GetPrimitive(); auto dst = getChildEdgesAtPort(0)[0]->getMemoryPtr()->GetPrimitive(); @@ -308,39 +436,19 @@ mkldnn::algorithm MKLDNNPoolingNode::getPoolingAlgorithm() const { } } -std::shared_ptr MKLDNNPoolingNode::createDescriptorInternal(const mkldnn::memory::desc& in_candidate, - const mkldnn::memory::desc& out_candidate, - const mkldnn::algorithm alg) const { - if (alg == mkldnn::algorithm::undef) { - IE_THROW() << "Unsupported pooling type"; - } - - auto convert = [] (std::vector orig_dims) { - return memory::dims(orig_dims.begin(), orig_dims.end()); - }; - std::shared_ptr desc_ptr( - new pooling_v2_forward::desc(prop_kind::forward_scoring, alg, - in_candidate, out_candidate, - convert(stride), - convert(kernel), - convert(effective_dilation), - convert(effective_pad_begin), - convert(effective_pad_end))); - - if (alg == mkldnn::algorithm::pooling_avg_include_padding) { - // In case of AVG including paddings the norm coeff should be calculated - // with tacking into account original pads. So we need to restore - // original values for end paddings. - // - // WA. Because mkldnn uses different formula to calculate AVG norm coeff - // in compare with Caffe. In mkldnn coeff is always 1/(KH*KW) - for (int i = 0; i < data_pad_end.size(); i++) { - if (data_pad_end[i] != effective_pad_end[i]) - desc_ptr->data.padding[1][i] = static_cast(data_pad_end[i]); - } - } - - return desc_ptr; +std::shared_ptr MKLDNNPoolingNode::createDescriptorInternal( + const mkldnn::memory::desc& in_candidate, + const mkldnn::memory::desc& out_candidate, + const mkldnn::algorithm alg) const { + return createDescriptorHelper(in_candidate, + out_candidate, + alg, + stride, + kernel, + effective_pad_begin, + effective_pad_end, + effective_dilation, + data_pad_end); } void MKLDNNPoolingNode::createDescriptor(const std::vector &inputDesc, diff --git a/src/tests/functional/plugin/cpu/single_layer_tests/fake_quantize.cpp b/src/tests/functional/plugin/cpu/single_layer_tests/fake_quantize.cpp index 0dff8a0af27..4f9873e30a0 100644 --- a/src/tests/functional/plugin/cpu/single_layer_tests/fake_quantize.cpp +++ b/src/tests/functional/plugin/cpu/single_layer_tests/fake_quantize.cpp @@ -1,427 +1,397 @@ -//// Copyright (C) 2018-2021 Intel Corporation -//// SPDX-License-Identifier: Apache-2.0 -//// -// -//#include "shared_test_classes/base/layer_test_utils.hpp" -//#include "test_utils/cpu_test_utils.hpp" -//#include "ngraph_functions/builders.hpp" -// -//using namespace InferenceEngine; -//using namespace ngraph; -//using namespace CPUTestUtils; -// -//namespace CPULayerTestsDefinitions { -// -//using inputShapes = std::tuple, // dynamic input shapes -// std::vector, // target input shapes -// std::vector>; // range input shapes -// -//using fqSpecificParams = std::tuple, // output low -// std::vector, // output high -// size_t>; // levels -// -//using fqLayerTestParamsSet = std::tuple, std::vector>, // il and ih values -// bool, // should be decomposed -// CPUSpecificParams>; -// -//class FakeQuantizeLayerCPUTest : public testing::WithParamInterface, -// virtual public LayerTestsUtils::LayerTestsCommon, public CPUTestsBase { -//public: -// static std::string getTestCaseName(testing::TestParamInfo obj) { -// fqSpecificParams fqParams; -// inputShapes testShapes; -// Precision inPrec; -// std::pair, std::vector> inputRangesValues; -// bool shouldBeDecomposed; -// CPUSpecificParams cpuParams; -// std::tie(fqParams, testShapes, inPrec, inputRangesValues, shouldBeDecomposed, cpuParams) = obj.param; -// -// std::vector dynamicShapes; -// std::vector targetShapes; -// std::vector ranges; -// std::tie(dynamicShapes, targetShapes, ranges) = testShapes; -// -// int64_t inDataLowBounds, inDataHighBounds; -// std::vector inputLow, inputHigh, outputLow, outputHigh; -// size_t levels; -// inputLow = inputRangesValues.first; -// inputHigh = inputRangesValues.second; -// std::tie(inDataLowBounds, inDataHighBounds, outputLow, outputHigh, levels) = fqParams; -// -// std::ostringstream result; -// if (!dynamicShapes.empty()) { -// result << "IS=" << CommonTestUtils::partialShape2str(dynamicShapes) << "_"; -// } -// result << "TS="; -// for (const auto& shape : targetShapes) { -// result << "(" << CommonTestUtils::vec2str(shape) << ")_"; -// } -// result << "RS="; -// for (const auto& data : ranges) { -// result << "(" << CommonTestUtils::vec2str(data) << ")_"; -// } -// result << "inPrec=" << inPrec.name() << "_"; -// -// result << "LOW_BOUNDS=" << inDataLowBounds << "_"; -// result << "HIGH_BOUNDS=" << inDataHighBounds << "_"; -// result << "IL=" << CommonTestUtils::vec2str(inputLow) << "_"; -// result << "IH=" << CommonTestUtils::vec2str(inputHigh) << "_"; -// result << "OL=" << CommonTestUtils::vec2str(outputLow) << "_"; -// result << "OH=" << CommonTestUtils::vec2str(outputHigh) << "_"; -// result << "LEVELS=" << levels; -// -// result << CPUTestsBase::getTestCaseName(cpuParams); -// -// return result.str(); -// } -// -// void Infer() override { -// inferRequest = executableNetwork.CreateInferRequest(); -// inputs.clear(); -// -// const InputsDataMap &inDataMap = cnnNetwork.getInputsInfo(); -// auto input = inDataMap.begin(); -// -// const auto td = input->second->getTensorDesc(); -// Blob::Ptr blob = FuncTestUtils::createAndFillBlob(InferenceEngine::TensorDesc(td.getPrecision(), targetStaticShapes[index][0], td.getLayout()), -// inDataHighBounds - inDataLowBounds, inDataLowBounds); -// inferRequest.SetBlob(input->second->name(), blob); -// inputs.push_back(blob); -// -// inferRequest.Infer(); -// } -// -//protected: -// std::string layerName; -// -// void SetUp() override { -// targetDevice = CommonTestUtils::DEVICE_CPU; -// fqSpecificParams fqParams; -// inputShapes testShapes; -// Precision inPrec; -// std::pair, std::vector> inputRangesValues; -// bool shouldBeDecomposed; -// CPUSpecificParams cpuParams; -// std::tie(fqParams, testShapes, inPrec, inputRangesValues, shouldBeDecomposed, cpuParams) = this->GetParam(); -// -// std::tie(inFmts, outFmts, priority, selectedType) = cpuParams; -// -// std::vector targetShapes; -// std::vector ranges; -// std::tie(inputDynamicShapes, targetShapes, ranges) = testShapes; -// -// for (size_t i = 0; i < targetShapes.size(); i++) { -// targetStaticShapes.push_back(std::vector{targetShapes}); -// } -// -// size_t levels; -// std::vector> rangesBounds(RANGES_INPUT_NUMBER); -// rangesBounds[0] = inputRangesValues.first; -// rangesBounds[1] = inputRangesValues.second; -// std::tie(inDataLowBounds, inDataHighBounds, rangesBounds[2], rangesBounds[3], levels) = fqParams; -// -// auto ngInPrec = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(inPrec); -// ParameterVector params = builder::makeParams(ngInPrec, {targetStaticShapes[0][0]}); -// auto paramOuts = helpers::convert2OutputVector(helpers::castOps2Nodes(params)); -// -// auto il = builder::makeConstant(ngInPrec, ranges[0], rangesBounds[0], rangesBounds[0].empty()); -// auto ih = builder::makeConstant(ngInPrec, ranges[1], rangesBounds[1], rangesBounds[1].empty()); -// auto ol = builder::makeConstant(ngInPrec, ranges[2], rangesBounds[2], rangesBounds[2].empty()); -// auto oh = builder::makeConstant(ngInPrec, ranges[3], rangesBounds[3], rangesBounds[3].empty()); -// auto fq = std::make_shared(paramOuts[0], il, ih, ol, oh, levels); -// -// layerName = shouldBeDecomposed ? "" : "FakeQuantize"; -// -// if (selectedType.empty()) { -// selectedType = getPrimitiveType() + "_" + inPrec.name(); -// } -// -// function = makeNgraphFunction(ngInPrec, params, fq, "FakeQuantizeCPU"); -// } -// -//private: -// const size_t RANGES_INPUT_NUMBER = 4; -// -// int64_t inDataLowBounds, inDataHighBounds; -//}; -// -//TEST_P(FakeQuantizeLayerCPUTest, CompareWithRefs) { -// SKIP_IF_CURRENT_TEST_IS_DISABLED() -// Run(); -// -// CheckPluginRelatedResults(executableNetwork, layerName); -//} -// -// -//const std::vector levels = {16, 255, 256}; -// -//int64_t dataLowBounds{-10}, dataHighBounds{10}; -// -//const std::vector, std::vector>> input_ranges = { -// {{0.0f}, {5.f}}, -// {{-10.0f}, {-5.f}} -//}; -// -//const std::vector outputLow{5.0f}, outputHigh{25.0f}; -// -//const auto specificParams = ::testing::Combine(::testing::Values(dataLowBounds), -// ::testing::Values(dataHighBounds), -// ::testing::Values(outputLow), -// ::testing::Values(outputHigh), -// ::testing::ValuesIn(levels)); -// -//namespace fqImpl { -// -//std::vector memForm4D_jit = { -// CPUSpecificParams({nchw}, {nchw}, {}, {}), -// CPUSpecificParams({nhwc}, {nhwc}, {}, {}), -// CPUSpecificParams({nChw16c}, {nChw16c}, {}, {}) -//}; -// -//std::vector rangesShapes4D_jit = { -// inputShapes{ -// {}, -// {{4, 5, 6, 7}}, -// {{1, 5, 1, 1}, {1, 5, 1, 1}, {1, 5, 1, 1}, {1, 5, 1, 1}} -// }, -// inputShapes{ -// {}, -// {{4, 5, 6, 7}}, -// {{1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}} -// }, -// inputShapes{ -// {{-1, -1, -1, -1}}, -// {{4, 5, 6, 7}, {1, 12, 1, 1}, {4, 1, 8, 2}, {1, 16, 6, 1}}, -// {{1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}} -// }, -// inputShapes{ -// {{-1, -1, -1, -1}}, -// {{4, 16, 6, 7}, {1, 16, 1, 1}, {7, 16, 1, 2}, {1, 16, 6, 1}}, -// {{1, 16, 1, 1}, {1, 16, 1, 1}, {1, 16, 1, 1}, {1, 16, 1, 1}} -// }, -//}; -// -//const auto testParams4D_jit = ::testing::Combine(specificParams, -// ::testing::ValuesIn(rangesShapes4D_jit), -// ::testing::Values(Precision::FP32), -// ::testing::ValuesIn(input_ranges), -// ::testing::Values(false), -// ::testing::ValuesIn(filterCPUSpecificParams(memForm4D_jit))); -//INSTANTIATE_TEST_SUITE_P(smoke_FakeQuantizeLayerCPUTest_4D_jit, FakeQuantizeLayerCPUTest, testParams4D_jit, FakeQuantizeLayerCPUTest::getTestCaseName); -// -// -//std::vector memForm4D_ref = { -// CPUSpecificParams({nchw}, {nchw}, {"ref_FP32"}, {"ref_FP32"}) -//}; -// -//std::vector rangesShapes4D_ref = { -// inputShapes{ -// {}, -// {{4, 5, 6, 7}}, -// {{4, 1, 1, 1}, {4, 1, 1, 1}, {4, 1, 1, 1}, {4, 1, 1, 1}} -// }, -// inputShapes{ -// {{-1, -1, -1, -1}}, -// {{4, 16, 6, 7}, {4, 1, 1, 1}, {4, 16, 1, 2}, {4, 16, 6, 1}}, -// {{4, 1, 1, 1}, {4, 1, 1, 1}, {4, 1, 1, 1}, {4, 1, 1, 1}} -// }, -//}; -// -//const auto testParams4D_ref = ::testing::Combine(specificParams, -// ::testing::ValuesIn(rangesShapes4D_ref), -// ::testing::Values(Precision::FP32), -// ::testing::ValuesIn(input_ranges), -// ::testing::Values(false), -// ::testing::ValuesIn(memForm4D_ref)); -//INSTANTIATE_TEST_SUITE_P(smoke_FakeQuantizeLayerCPUTest_4D_ref, FakeQuantizeLayerCPUTest, testParams4D_ref, FakeQuantizeLayerCPUTest::getTestCaseName); -// -// -//std::vector memForm5D_jit = { -// CPUSpecificParams({ncdhw}, {ncdhw}, {}, {}), -// CPUSpecificParams({ndhwc}, {ndhwc}, {}, {}), -// CPUSpecificParams({nCdhw16c}, {nCdhw16c}, {}, {}) -//}; -// -//std::vector rangesShapes5D_jit = { -// inputShapes{ -// {}, -// {{3, 4, 5, 6, 7}}, -// {{1, 4, 1, 1, 1}, {1, 4, 1, 1, 1}, {1, 4, 1, 1, 1}, {1, 4, 1, 1, 1}} -// }, -// inputShapes{ -// {}, -// {{3, 4, 5, 6, 7}}, -// {{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}} -// }, -// inputShapes{ -// {{-1, -1, -1, -1, -1}}, -// {{3, 4, 5, 6, 7}, {1, 12, 1, 1, 1}, {4, 1, 8, 2, 7}, {1, 16, 6, 5, 1}}, -// {{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}} -// }, -// inputShapes{ -// {{-1, -1, -1, -1, -1}}, -// {{4, 16, 6, 7, 8}, {1, 16, 1, 1, 1}, {7, 16, 1, 2, 5}, {1, 16, 6, 1, 7}}, -// {{1, 16, 1, 1, 1}, {1, 16, 1, 1, 1}, {1, 16, 1, 1, 1}, {1, 16, 1, 1, 1}} -// }, -//}; -// -//const auto testParams5D_jit = ::testing::Combine(specificParams, -// ::testing::ValuesIn(rangesShapes5D_jit), -// ::testing::Values(Precision::FP32), -// ::testing::ValuesIn(input_ranges), -// ::testing::Values(false), -// ::testing::ValuesIn(filterCPUSpecificParams(memForm5D_jit))); -// -//INSTANTIATE_TEST_SUITE_P(smoke_FakeQuantizeLayerCPUTest_5D_jit, FakeQuantizeLayerCPUTest, testParams5D_jit, FakeQuantizeLayerCPUTest::getTestCaseName); -// -// -//std::vector memForm5D_ref = { -// CPUSpecificParams({ncdhw}, {ncdhw}, {"ref_FP32"}, {"ref_FP32"}) -//}; -// -//std::vector rangesShapes5D_ref = { -// inputShapes{ -// {}, -// {{3, 4, 5, 6, 7}}, -// {{3, 1, 1, 1, 1}, {3, 1, 1, 1, 1}, {3, 1, 1, 1, 1}, {3, 1, 1, 1, 1}} -// }, -// inputShapes{ -// {{-1, -1, -1, -1, -1}}, -// {{3, 16, 6, 7, 8}, {3, 16, 1, 1, 1}, {3, 16, 1, 2, 5}, {3, 16, 6, 1, 7}}, -// {{3, 1, 1, 1, 1}, {3, 1, 1, 1, 1}, {3, 1, 1, 1, 1}, {3, 1, 1, 1, 1}} -// }, -//}; -// -//const auto testParams5D_ref = ::testing::Combine(specificParams, -// ::testing::ValuesIn(rangesShapes5D_ref), -// ::testing::Values(Precision::FP32), -// ::testing::ValuesIn(input_ranges), -// ::testing::Values(false), -// ::testing::ValuesIn(memForm5D_ref)); -// -//INSTANTIATE_TEST_SUITE_P(smoke_FakeQuantizeLayerCPUTest_5D_ref, FakeQuantizeLayerCPUTest, testParams5D_ref, FakeQuantizeLayerCPUTest::getTestCaseName); -// -//const auto specificParamsBin = ::testing::Combine(::testing::Values(dataLowBounds), -// ::testing::Values(dataHighBounds), -// ::testing::Values(std::vector{0.0f}), -// ::testing::Values(std::vector{1.0f}), -// ::testing::Values(2)); -// -//const auto testParamsBin4D = ::testing::Combine(specificParamsBin, -// ::testing::ValuesIn(rangesShapes4D_jit), -// ::testing::Values(Precision::FP32), -// ::testing::Values(std::pair, std::vector>{{3.0f}, {3.f}}), -// ::testing::Values(false), -// ::testing::Values(CPUSpecificParams())); -// -//INSTANTIATE_TEST_SUITE_P(smoke_FakeQuantizeLayerCPUTest_4D_bin, FakeQuantizeLayerCPUTest, testParamsBin4D, FakeQuantizeLayerCPUTest::getTestCaseName); -// -//} // namespace fqImpl -// -//namespace fqDecompos { -// -//std::vector decomposeShapes = { -// inputShapes{ -// {}, -// {{4, 5, 6, 7}}, -// {{4, 5, 6, 7}, {4, 5, 6, 7}, {4, 5, 6, 7}, {4, 5, 6, 7}} -// }, -// inputShapes{ -// {}, -// {{4, 5, 6, 7}}, -// {{1, 5, 1, 1}, {1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 6, 7}} -// }, -// inputShapes{ -// {}, -// {{4, 5, 6, 7}}, -// {{1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 6, 7}} -// }, -// inputShapes{ -// {}, -// {{4, 5, 6, 7}}, -// {{1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 1, 1}, {1, 1, 1, 1}} -// }, -// inputShapes{ -// {}, -// {{4, 5, 6, 7}}, -// {{1, 1, 6, 1}, {1, 5, 6, 7}, {1, 1, 6, 1}, {1, 1, 6, 1}} -// }, -// inputShapes{ -// {}, -// {{3, 4, 5, 6, 7}}, -// {{4, 5, 6, 7}, {4, 5, 6, 7}, {4, 5, 6, 7}, {4, 5, 6, 7}} -// }, -// inputShapes{ -// {}, -// {{3, 4, 5, 6, 7}}, -// {{1, 5, 1, 1}, {1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 6, 7}} -// }, -// inputShapes{ -// {}, -// {{3, 4, 5, 6, 7}}, -// {{1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 6, 7}} -// }, -// inputShapes{ -// {}, -// {{3, 4, 5, 6, 7}}, -// {{1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 1, 1}, {1, 1, 1, 1}} -// }, -// inputShapes{ -// {}, -// {{3, 4, 5, 6, 7}}, -// {{1, 1, 6, 1}, {1, 5, 6, 7}, {1, 1, 6, 1}, {1, 1, 6, 1}} -// }, -// inputShapes{ -// {}, -// {{2, 3, 4, 5, 6, 7}}, -// {{4, 5, 6, 7}, {4, 5, 6, 7}, {4, 5, 6, 7}, {4, 5, 6, 7}} -// }, -// inputShapes{ -// {}, -// {{2, 3, 4, 5, 6, 7}}, -// {{1, 5, 1, 1}, {1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 6, 7}} -// }, -// inputShapes{ -// {}, -// {{2, 3, 4, 5, 6, 7}}, -// {{1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 6, 7}} -// }, -// inputShapes{ -// {}, -// {{2, 3, 4, 5, 6, 7}}, -// {{1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 1, 1}, {1, 1, 1, 1}} -// }, -// inputShapes{ -// {}, -// {{2, 3, 4, 5, 6, 7}}, -// {{1, 1, 6, 1}, {1, 5, 6, 7}, {1, 1, 6, 1}, {1, 1, 6, 1}} -// }, -// inputShapes{ -// {{-1, -1, -1, -1}}, -// {{4, 5, 6, 7}, {1, 5, 6, 7}, {7, 5, 6, 7}}, -// {{1, 1, 6, 1}, {1, 5, 6, 7}, {1, 1, 6, 1}, {1, 1, 6, 1}} -// }, -// inputShapes{ -// {{-1, -1, -1, -1, -1}}, -// {{8, 4, 5, 6, 7}, {1, 1, 5, 6, 7}, {1, 1, 1, 6, 7}}, -// {{1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 1, 1}, {1, 1, 1, 1}} -// }, -//}; -// -//const auto testParams = ::testing::Combine(specificParams, -// ::testing::ValuesIn(decomposeShapes), -// ::testing::Values(Precision::FP32), -// ::testing::ValuesIn(input_ranges), -// ::testing::Values(true), -// ::testing::Values(CPUSpecificParams{})); -// -//INSTANTIATE_TEST_SUITE_P(smoke_FakeQuantizeLayerCPUTest_Decompos, FakeQuantizeLayerCPUTest, testParams, FakeQuantizeLayerCPUTest::getTestCaseName); -// -//} // namespace fqDecompos -// -//} // namespace CPULayerTestsDefinitions +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "test_utils/cpu_test_utils.hpp" +#include "ngraph_functions/builders.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" +#include + +using namespace InferenceEngine; +using namespace ngraph; +using namespace CPUTestUtils; +using namespace ov::test; + +namespace CPULayerTestsDefinitions { +using inputShapes = std::tuple>; // range input shapes + +using fqSpecificParams = std::tuple, // output low + std::vector, // output high + size_t>; // levels + +using fqLayerTestParamsSet = std::tuple, std::vector>, // il and ih values + bool, // should be decomposed + CPUSpecificParams>; + +class FakeQuantizeLayerCPUTest : public testing::WithParamInterface, + virtual public SubgraphBaseTest, public CPUTestsBase { +public: + static std::string getTestCaseName(testing::TestParamInfo obj) { + fqSpecificParams fqParams; + inputShapes testShapes; + Precision inPrec; + std::pair, std::vector> inputRangesValues; + bool shouldBeDecomposed; + CPUSpecificParams cpuParams; + std::tie(fqParams, testShapes, inPrec, inputRangesValues, shouldBeDecomposed, cpuParams) = obj.param; + + InputShape shapes; + std::vector ranges; + std::tie(shapes, ranges) = testShapes; + + int64_t inDataLowBounds, inDataHighBounds; + std::vector inputLow, inputHigh, outputLow, outputHigh; + size_t levels; + inputLow = inputRangesValues.first; + inputHigh = inputRangesValues.second; + std::tie(inDataLowBounds, inDataHighBounds, outputLow, outputHigh, levels) = fqParams; + + std::ostringstream result; + + result << "IS=" << CommonTestUtils::partialShape2str({shapes.first}) << "_"; + result << "TS="; + for (const auto& shape : shapes.second) { + result << "(" << CommonTestUtils::vec2str(shape) << ")_"; + } + result << "RS="; + for (const auto& data : ranges) { + result << "(" << CommonTestUtils::vec2str(data) << ")_"; + } + result << "inPrec=" << inPrec.name() << "_"; + + result << "LOW_BOUNDS=" << inDataLowBounds << "_"; + result << "HIGH_BOUNDS=" << inDataHighBounds << "_"; + result << "IL=" << CommonTestUtils::vec2str(inputLow) << "_"; + result << "IH=" << CommonTestUtils::vec2str(inputHigh) << "_"; + result << "OL=" << CommonTestUtils::vec2str(outputLow) << "_"; + result << "OH=" << CommonTestUtils::vec2str(outputHigh) << "_"; + result << "LEVELS=" << levels; + + result << CPUTestsBase::getTestCaseName(cpuParams); + + return result.str(); + } + + + +protected: + std::string layerName; + + void SetUp() override { + targetDevice = CommonTestUtils::DEVICE_CPU; + fqSpecificParams fqParams; + inputShapes testShapes; + Precision inPrec; + std::pair, std::vector> inputRangesValues; + bool shouldBeDecomposed; + CPUSpecificParams cpuParams; + std::tie(fqParams, testShapes, inPrec, inputRangesValues, shouldBeDecomposed, cpuParams) = this->GetParam(); + + std::tie(inFmts, outFmts, priority, selectedType) = cpuParams; + + InputShape shapes; + std::vector ranges; + std::tie(shapes, ranges) = testShapes; + + inputDynamicShapes.push_back(shapes.first); + for (size_t i = 0; i < shapes.second.size(); i++) { + targetStaticShapes.push_back(std::vector{shapes.second[i]}); + } + + size_t levels; + std::vector> rangesBounds(RANGES_INPUT_NUMBER); + rangesBounds[0] = inputRangesValues.first; + rangesBounds[1] = inputRangesValues.second; + std::tie(inDataLowBounds, inDataHighBounds, rangesBounds[2], rangesBounds[3], levels) = fqParams; + + auto ngInPrec = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(inPrec); + ParameterVector params = builder::makeDynamicParams(ngInPrec, inputDynamicShapes); + auto paramOuts = helpers::convert2OutputVector(helpers::castOps2Nodes(params)); + + auto il = builder::makeConstant(ngInPrec, ranges[0], rangesBounds[0], rangesBounds[0].empty()); + auto ih = builder::makeConstant(ngInPrec, ranges[1], rangesBounds[1], rangesBounds[1].empty()); + auto ol = builder::makeConstant(ngInPrec, ranges[2], rangesBounds[2], rangesBounds[2].empty()); + auto oh = builder::makeConstant(ngInPrec, ranges[3], rangesBounds[3], rangesBounds[3].empty()); + auto fq = std::make_shared(paramOuts[0], il, ih, ol, oh, levels); + + layerName = shouldBeDecomposed ? "" : "FakeQuantize"; + + if (selectedType.empty()) { + selectedType = getPrimitiveType() + "_" + inPrec.name(); + } + + function = makeNgraphFunction(ngInPrec, params, fq, "FakeQuantizeCPU"); + } + + void generate_inputs(const std::vector& targetInputStaticShapes) override { + inputs.clear(); + const auto& funcInputs = function->inputs(); + ASSERT_EQ(funcInputs.size(), 1); + const auto& funcInput = funcInputs[0]; + ov::runtime::Tensor tensor; + tensor = ov::test::utils::create_and_fill_tensor(funcInput.get_element_type(), + targetInputStaticShapes[0], + inDataHighBounds - inDataLowBounds, + inDataLowBounds); + inputs.insert({funcInput.get_node_shared_ptr(), tensor}); + } + +private: + const size_t RANGES_INPUT_NUMBER = 4; + + int64_t inDataLowBounds, inDataHighBounds; +}; + +TEST_P(FakeQuantizeLayerCPUTest, CompareWithRefs) { + SKIP_IF_CURRENT_TEST_IS_DISABLED() + run(); + + CheckPluginRelatedResults(executableNetwork, layerName); +} + + +const std::vector levels = {16, 255, 256}; + +int64_t dataLowBounds{-10}, dataHighBounds{10}; + +const std::vector, std::vector>> input_ranges = { + {{0.0f}, {5.f}}, + {{0.0f}, {}}, + {{-10.0f}, {-5.f}} +}; + +const std::vector outputLow{5.0f}, outputHigh{25.0f}; + +const auto specificParams = ::testing::Combine(::testing::Values(dataLowBounds), + ::testing::Values(dataHighBounds), + ::testing::Values(outputLow), + ::testing::Values(outputHigh), + ::testing::ValuesIn(levels)); + +namespace fqImpl { + +std::vector memForm4D_jit = { + CPUSpecificParams({nchw}, {nchw}, {}, {}), + CPUSpecificParams({nhwc}, {nhwc}, {}, {}), + CPUSpecificParams({nChw16c}, {nChw16c}, {}, {}) +}; + +std::vector rangesShapes4D_jit = { + inputShapes{ + InputShape{{{4, 5, 6, 7}}, {{4, 5, 6, 7}}}, + {{1, 5, 1, 1}, {1, 5, 1, 1}, {1, 5, 1, 1}, {1, 5, 1, 1}} + }, + inputShapes{ + InputShape{{{4, 5, 6, 7}}, {{4, 5, 6, 7}}}, + {{1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}} + }, + inputShapes{ + InputShape{{-1, -1, -1, -1}, {{4, 5, 6, 7}, {1, 12, 1, 1}, {4, 1, 8, 2}, {1, 16, 6, 1}, {4, 5, 6, 7}}}, + {{1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}} + }, + inputShapes{ + InputShape{{-1, -1, -1, -1}, {{4, 16, 6, 7}, {1, 16, 1, 1}, {7, 16, 1, 2}, {1, 16, 6, 1}, {4, 16, 6, 7}}}, + {{1, 16, 1, 1}, {1, 16, 1, 1}, {1, 16, 1, 1}, {1, 16, 1, 1}} + }, +}; + +const auto testParams4D_jit = ::testing::Combine(specificParams, + ::testing::ValuesIn(rangesShapes4D_jit), + ::testing::Values(Precision::FP32), + ::testing::ValuesIn(input_ranges), + ::testing::Values(false), + ::testing::ValuesIn(filterCPUSpecificParams(memForm4D_jit))); +INSTANTIATE_TEST_SUITE_P(smoke_FakeQuantizeLayerCPUTest_4D_jit, FakeQuantizeLayerCPUTest, testParams4D_jit, FakeQuantizeLayerCPUTest::getTestCaseName); + + +std::vector memForm4D_ref = { + CPUSpecificParams({nchw}, {nchw}, {"ref_FP32"}, {"ref_FP32"}) +}; + +std::vector rangesShapes4D_ref = { + inputShapes{ + InputShape{{{4, 5, 6, 7}}, {{4, 5, 6, 7}}}, + {{4, 1, 1, 1}, {4, 1, 1, 1}, {4, 1, 1, 1}, {4, 1, 1, 1}} + }, + inputShapes{ + InputShape{{-1, -1, -1, -1}, {{4, 16, 6, 7}, {4, 1, 1, 1}, {4, 16, 1, 2}, {4, 16, 6, 1}, {4, 16, 6, 7}}}, + {{4, 1, 1, 1}, {4, 1, 1, 1}, {4, 1, 1, 1}, {4, 1, 1, 1}} + }, +}; + +const auto testParams4D_ref = ::testing::Combine(specificParams, + ::testing::ValuesIn(rangesShapes4D_ref), + ::testing::Values(Precision::FP32), + ::testing::ValuesIn(input_ranges), + ::testing::Values(false), + ::testing::ValuesIn(memForm4D_ref)); +INSTANTIATE_TEST_SUITE_P(smoke_FakeQuantizeLayerCPUTest_4D_ref, FakeQuantizeLayerCPUTest, testParams4D_ref, FakeQuantizeLayerCPUTest::getTestCaseName); + + +std::vector memForm5D_jit = { + CPUSpecificParams({ncdhw}, {ncdhw}, {}, {}), + CPUSpecificParams({ndhwc}, {ndhwc}, {}, {}), + CPUSpecificParams({nCdhw16c}, {nCdhw16c}, {}, {}) +}; + +std::vector rangesShapes5D_jit = { + inputShapes{ + InputShape{{3, 4, 5, 6, 7}, {{3, 4, 5, 6, 7}}}, + {{1, 4, 1, 1, 1}, {1, 4, 1, 1, 1}, {1, 4, 1, 1, 1}, {1, 4, 1, 1, 1}} + }, + inputShapes{ + InputShape{{3, 4, 5, 6, 7}, {{3, 4, 5, 6, 7}}}, + {{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}} + }, + inputShapes{ + InputShape{{-1, -1, -1, -1, -1}, {{3, 4, 5, 6, 7}, {1, 12, 1, 1, 1}, {4, 1, 8, 2, 7}, {3, 4, 5, 6, 7}, {1, 16, 6, 5, 1}}}, + {{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}} + }, + inputShapes{ + InputShape{{-1, -1, -1, -1, -1}, {{4, 16, 6, 7, 8}, {1, 16, 1, 1, 1}, {7, 16, 1, 2, 5}, {4, 16, 6, 7, 8}, {1, 16, 6, 1, 7}}}, + {{1, 16, 1, 1, 1}, {1, 16, 1, 1, 1}, {1, 16, 1, 1, 1}, {1, 16, 1, 1, 1}} + }, +}; + +const auto testParams5D_jit = ::testing::Combine(specificParams, + ::testing::ValuesIn(rangesShapes5D_jit), + ::testing::Values(Precision::FP32), + ::testing::ValuesIn(input_ranges), + ::testing::Values(false), + ::testing::ValuesIn(filterCPUSpecificParams(memForm5D_jit))); + +INSTANTIATE_TEST_SUITE_P(smoke_FakeQuantizeLayerCPUTest_5D_jit, FakeQuantizeLayerCPUTest, testParams5D_jit, FakeQuantizeLayerCPUTest::getTestCaseName); + + +std::vector memForm5D_ref = { + CPUSpecificParams({ncdhw}, {ncdhw}, {"ref_FP32"}, {"ref_FP32"}) +}; + +std::vector rangesShapes5D_ref = { + inputShapes{ + InputShape{{3, 4, 5, 6, 7}, {{3, 4, 5, 6, 7}}}, + {{3, 1, 1, 1, 1}, {3, 1, 1, 1, 1}, {3, 1, 1, 1, 1}, {3, 1, 1, 1, 1}} + }, + inputShapes{ + InputShape{{-1, -1, -1, -1, -1}, {{3, 16, 6, 7, 8}, {3, 16, 1, 1, 1}, {3, 16, 1, 2, 5}, {3, 16, 6, 1, 7}, {3, 16, 6, 7, 8}}}, + {{3, 1, 1, 1, 1}, {3, 1, 1, 1, 1}, {3, 1, 1, 1, 1}, {3, 1, 1, 1, 1}} + }, +}; + +const auto testParams5D_ref = ::testing::Combine(specificParams, + ::testing::ValuesIn(rangesShapes5D_ref), + ::testing::Values(Precision::FP32), + ::testing::ValuesIn(input_ranges), + ::testing::Values(false), + ::testing::ValuesIn(memForm5D_ref)); + +INSTANTIATE_TEST_SUITE_P(smoke_FakeQuantizeLayerCPUTest_5D_ref, FakeQuantizeLayerCPUTest, testParams5D_ref, FakeQuantizeLayerCPUTest::getTestCaseName); + +const auto specificParamsBin = ::testing::Combine(::testing::Values(dataLowBounds), + ::testing::Values(dataHighBounds), + ::testing::Values(std::vector{0.0f}), + ::testing::Values(std::vector{1.0f}), + ::testing::Values(2)); + +const auto testParamsBin4D = ::testing::Combine(specificParamsBin, + ::testing::ValuesIn(rangesShapes4D_jit), + ::testing::Values(Precision::FP32), + ::testing::Values(std::pair, std::vector>{{3.0f}, {3.f}}), + ::testing::Values(false), + ::testing::Values(CPUSpecificParams())); + +INSTANTIATE_TEST_SUITE_P(smoke_FakeQuantizeLayerCPUTest_4D_bin, FakeQuantizeLayerCPUTest, testParamsBin4D, FakeQuantizeLayerCPUTest::getTestCaseName); + +} // namespace fqImpl + +namespace fqDecompos { + +std::vector decomposeShapes = { + inputShapes{ + InputShape{{4, 5, 6, 7}, {{4, 5, 6, 7}}}, + {{4, 5, 6, 7}, {4, 5, 6, 7}, {4, 5, 6, 7}, {4, 5, 6, 7}} + }, + inputShapes{ + InputShape{{4, 5, 6, 7}, {{4, 5, 6, 7}}}, + {{1, 5, 1, 1}, {1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 6, 7}} + }, + inputShapes{ + InputShape{{4, 5, 6, 7}, {{4, 5, 6, 7}}}, + {{1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 6, 7}} + }, + inputShapes{ + InputShape{{4, 5, 6, 7}, {{4, 5, 6, 7}}}, + {{1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 1, 1}, {1, 1, 1, 1}} + }, + inputShapes{ + InputShape{{4, 5, 6, 7}, {{4, 5, 6, 7}}}, + {{1, 1, 6, 1}, {1, 5, 6, 7}, {1, 1, 6, 1}, {1, 1, 6, 1}} + }, + inputShapes{ + InputShape{{3, 4, 5, 6, 7}, {{3, 4, 5, 6, 7}}}, + {{4, 5, 6, 7}, {4, 5, 6, 7}, {4, 5, 6, 7}, {4, 5, 6, 7}} + }, + inputShapes{ + InputShape{{3, 4, 5, 6, 7}, {{3, 4, 5, 6, 7}}}, + {{1, 5, 1, 1}, {1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 6, 7}} + }, + inputShapes{ + InputShape{{3, 4, 5, 6, 7}, {{3, 4, 5, 6, 7}}}, + {{1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 6, 7}} + }, + inputShapes{ + InputShape{{3, 4, 5, 6, 7}, {{3, 4, 5, 6, 7}}}, + {{1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 1, 1}, {1, 1, 1, 1}} + }, + inputShapes{ + InputShape{{3, 4, 5, 6, 7}, {{3, 4, 5, 6, 7}}}, + {{1, 1, 6, 1}, {1, 5, 6, 7}, {1, 1, 6, 1}, {1, 1, 6, 1}} + }, + inputShapes{ + InputShape{{2, 3, 4, 5, 6, 7}, {{2, 3, 4, 5, 6, 7}}}, + {{4, 5, 6, 7}, {4, 5, 6, 7}, {4, 5, 6, 7}, {4, 5, 6, 7}} + }, + inputShapes{ + InputShape{{2, 3, 4, 5, 6, 7}, {{2, 3, 4, 5, 6, 7}}}, + {{1, 5, 1, 1}, {1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 6, 7}} + }, + inputShapes{ + InputShape{{2, 3, 4, 5, 6, 7}, {{2, 3, 4, 5, 6, 7}}}, + {{1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 6, 7}} + }, + inputShapes{ + InputShape{{2, 3, 4, 5, 6, 7}, {{2, 3, 4, 5, 6, 7}}}, + {{1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 1, 1}, {1, 1, 1, 1}} + }, + inputShapes{ + InputShape{{2, 3, 4, 5, 6, 7}, {{2, 3, 4, 5, 6, 7}}}, + {{1, 1, 6, 1}, {1, 5, 6, 7}, {1, 1, 6, 1}, {1, 1, 6, 1}} + }, + inputShapes{ + InputShape{{-1, -1, -1, -1}, {{4, 5, 6, 7}, {1, 5, 6, 7}, {7, 5, 6, 7}, {4, 5, 6, 7}}}, + {{1, 1, 6, 1}, {1, 5, 6, 7}, {1, 1, 6, 1}, {1, 1, 6, 1}} + }, + inputShapes{ + InputShape{{-1, -1, -1, -1, -1}, {{8, 4, 5, 6, 7}, {1, 1, 5, 6, 7}, {1, 1, 1, 6, 7}, {8, 4, 5, 6, 7}}}, + {{1, 1, 6, 7}, {1, 1, 6, 7}, {1, 1, 1, 1}, {1, 1, 1, 1}} + }, +}; + +const auto testParams = ::testing::Combine(specificParams, + ::testing::ValuesIn(decomposeShapes), + ::testing::Values(Precision::FP32), + ::testing::ValuesIn(input_ranges), + ::testing::Values(true), + ::testing::Values(CPUSpecificParams{})); + +INSTANTIATE_TEST_SUITE_P(smoke_FakeQuantizeLayerCPUTest_Decompos, FakeQuantizeLayerCPUTest, testParams, FakeQuantizeLayerCPUTest::getTestCaseName); + +} // namespace fqDecompos + +} // namespace CPULayerTestsDefinitions diff --git a/src/tests/functional/plugin/cpu/single_layer_tests/pooling.cpp b/src/tests/functional/plugin/cpu/single_layer_tests/pooling.cpp index 22af383877a..b1003a31414 100644 --- a/src/tests/functional/plugin/cpu/single_layer_tests/pooling.cpp +++ b/src/tests/functional/plugin/cpu/single_layer_tests/pooling.cpp @@ -593,7 +593,8 @@ const std::vector inputShapes4D_int8 = { { {1, 32, 8, 8}, {1, 32, 8, 4}, - {2, 32, 8, 12} + {2, 32, 8, 12}, + {1, 32, 8, 8} } }, { @@ -603,7 +604,8 @@ const std::vector inputShapes4D_int8 = { { {3, 16, 32, 32}, {1, 16, 16, 12}, - {1, 16, 8, 8} + {1, 16, 8, 8}, + {3, 16, 32, 32}, } } }; @@ -631,7 +633,8 @@ const std::vector inputShapes5D_int8 = { { {2, 32, 8, 8, 8}, {1, 32, 16, 20, 8}, - {1, 32, 16, 16, 16} + {1, 32, 16, 16, 16}, + {2, 32, 8, 8, 8} } }, { @@ -641,7 +644,8 @@ const std::vector inputShapes5D_int8 = { { {1, 16, 16, 16, 16}, {1, 16, 16, 8, 12}, - {2, 16, 8, 8, 8} + {2, 16, 8, 8, 8}, + {1, 16, 16, 16, 16}, } } };