diff --git a/src/plugins/intel_cpu/src/nodes/reduce.cpp b/src/plugins/intel_cpu/src/nodes/reduce.cpp index d26dcec39f4b22..5b79cc8e1e2753 100644 --- a/src/plugins/intel_cpu/src/nodes/reduce.cpp +++ b/src/plugins/intel_cpu/src/nodes/reduce.cpp @@ -2030,22 +2030,7 @@ void Reduce::initSupportedPrimitiveDescriptors() { dstMemoryDescs.push_back(config.outConfs[i].getMemDesc()); } - auto attrs = reduceAttrs; - bool apply_ref = customImplPriorities.size() > 0 && customImplPriorities[0] == ref; - bool single_axis_only = one_of(algorithm, Algorithm::ReduceSum, Algorithm::ReduceMax, - Algorithm::ReduceMin, Algorithm::ReduceProd); - // For the case of empty input, transformations ConvertReduceProd(Min, Max, Sum) are disabled to avoid empty output. - // So these 4 reduce modes with empty input reducing more than one axis are not supported by acl executor. Then - // factory->isEmpty() returns true, supportedPrimitiveDescriptors is emtpy. Though we don't actually need these acl - // kernels in execution, here we pass a fake axis {1} to pass assertion of "!supportedPrimitiveDescriptors.empty()" - // in Node::filterSupportedPrimitiveDescriptors(). - if (!apply_ref && !isDynamicNode() && single_axis_only) { - const auto& src_shape = getInputShapeAtPort(REDUCE_DATA).getStaticDims(); - if (shape_size(src_shape) == 0) { - attrs.axes = {1}; - } - } - auto factory = std::make_shared(attrs, srcMemoryDescs, dstMemoryDescs, + auto factory = std::make_shared(reduceAttrs, srcMemoryDescs, dstMemoryDescs, std::make_shared(context, getImplPriority())); if (!factory->isEmpty()) { supportedPrimitiveDescriptors.push_back({config, impl_type, factory}); @@ -2057,16 +2042,22 @@ void Reduce::initSupportedPrimitiveDescriptors() { }; #if defined (OV_CPU_WITH_ACL) - reduceAttrs.operation = algorithm; - reduceAttrs.keepDims = keep_dims; - reduceAttrs.axes = raw_axes; - for (auto &axis : reduceAttrs.axes) { - if (axis < 0) - axis += static_cast(getInputShapeAtPort(REDUCE_DATA).getRank()); + // acl doesn't support empty input + if (!isDynamicNode() && shape_size(getInputShapeAtPort(REDUCE_DATA).getStaticDims()) == 0) { + canUseAclExecutor = false; + } else { + reduceAttrs.operation = algorithm; + reduceAttrs.keepDims = keep_dims; + reduceAttrs.axes = raw_axes; + for (auto &axis : reduceAttrs.axes) { + if (axis < 0) + axis += static_cast(getInputShapeAtPort(REDUCE_DATA).getRank()); + } + pushDesc(LayoutType::nspc, LayoutType::nspc, input_prec, output_prec, impl_desc_type::undef, true); + pushDesc(LayoutType::ncsp, LayoutType::ncsp, input_prec, output_prec, impl_desc_type::undef, true); + canUseAclExecutor = !supportedPrimitiveDescriptors.empty(); } - pushDesc(LayoutType::nspc, LayoutType::nspc, input_prec, output_prec, impl_desc_type::undef, true); - pushDesc(LayoutType::ncsp, LayoutType::ncsp, input_prec, output_prec, impl_desc_type::undef, true); - canUseAclExecutor = !supportedPrimitiveDescriptors.empty(); + if (canUseAclExecutor) return; #endif @@ -2114,7 +2105,7 @@ void Reduce::prepareParams() { auto dstMemPtr = getDstMemoryAtPort(0); const auto& src_shape = srcMemPtr->getStaticDims(); dst_size = dstMemPtr->getSize(); - empty_input = shape_size(src_shape) == 0 || srcMemPtr->getSize() == 0; + empty_input = shape_size(src_shape) == 0; #if defined (OV_CPU_WITH_ACL) if (canUseAclExecutor) { std::vector srcMemoryDescs; diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/arm/reduce.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/arm/reduce.cpp index 366fe9a0ad8b4a..45ecc774b5dbf9 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/arm/reduce.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/arm/reduce.cpp @@ -49,34 +49,6 @@ const auto params_MultiAxis_5D = testing::Combine( testing::Values(emptyFusingSpec), testing::ValuesIn(additionalConfig())); -const auto params_MultiAxis_5D_ZeroDim = testing::Combine( - testing::Combine( - testing::ValuesIn(axes5D), - testing::Values(ov::test::utils::OpType::VECTOR), - testing::Values(true), - testing::ValuesIn(reductionTypesArithmetic()), - testing::ValuesIn(inpOutPrc()), - testing::Values(ElementType::undefined), - testing::Values(ElementType::undefined), - testing::ValuesIn(inputShapes_5D_ZeroDim)), - testing::ValuesIn(filterCPUSpecificParams(cpuParams_5D)), - testing::Values(emptyFusingSpec), - testing::ValuesIn(additionalConfig())); - -const auto params_MultiAxis_5D_ZeroDim_Compare = testing::Combine( - testing::Combine( - testing::ValuesIn(axes5D), - testing::Values(ov::test::utils::OpType::VECTOR), - testing::Values(true), - testing::ValuesIn(reductionTypesCompare()), - testing::ValuesIn(inpOutPrc()), - testing::Values(ElementType::undefined), - testing::Values(ElementType::undefined), - testing::ValuesIn(inputShapes_5D_ZeroDim)), - testing::ValuesIn(filterCPUSpecificParams(cpuParams_5D)), - testing::Values(emptyFusingSpec), - testing::ValuesIn(additionalConfigFP32())); - const std::vector> axes5D_ref = { {0} }; @@ -103,6 +75,20 @@ const auto params_MultiAxis_5D_ref = testing::Combine( testing::Values(emptyFusingSpec), testing::ValuesIn(config_infer_prec_f32)); +const auto params_MultiAxis_5D_ZeroDim_ref = testing::Combine( + testing::Combine( + testing::ValuesIn(axes5D), + testing::Values(ov::test::utils::OpType::VECTOR), + testing::Values(true), + testing::ValuesIn(reductionTypes()), + testing::ValuesIn(inpOutPrc()), + testing::Values(ElementType::undefined), + testing::Values(ElementType::undefined), + testing::ValuesIn(inputShapes_5D_ZeroDim)), + testing::ValuesIn(filterCPUSpecificParams(cpuParams_5D_ref)), + testing::Values(emptyFusingSpec), + testing::ValuesIn(additionalConfigFP32())); + //There are dedicated instences of smoke_Reduce_MultiAxis_5D_CPU test in arm and x64 folders //because ACL does not support 0 as reduction axis INSTANTIATE_TEST_SUITE_P( @@ -112,25 +98,18 @@ INSTANTIATE_TEST_SUITE_P( ReduceCPULayerTest::getTestCaseName ); +// Reference implementation testing of ACL unsupported case INSTANTIATE_TEST_SUITE_P( - smoke_Reduce_MultiAxis_5D_ZeroDim_CPU, - ReduceCPULayerTest, - params_MultiAxis_5D_ZeroDim, - ReduceCPULayerTest::getTestCaseName -); - -INSTANTIATE_TEST_SUITE_P( - smoke_Reduce_MultiAxis_5D_ZeroDim_Compare_CPU, + smoke_Reduce_MultiAxis_5D_CPU_ref, ReduceCPULayerTest, - params_MultiAxis_5D_ZeroDim_Compare, + params_MultiAxis_5D_ref, ReduceCPULayerTest::getTestCaseName ); -// Reference implementation testing of ACL unsupported case INSTANTIATE_TEST_SUITE_P( - smoke_Reduce_MultiAxis_5D_CPU_ref, + smoke_Reduce_MultiAxis_5D_ZeroDim_CPU_ref, ReduceCPULayerTest, - params_MultiAxis_5D_ref, + params_MultiAxis_5D_ZeroDim_ref, ReduceCPULayerTest::getTestCaseName ); diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/reduce.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/reduce.cpp index 3f4e064c2bf733..af4319d66a6efe 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/reduce.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/reduce.cpp @@ -105,13 +105,6 @@ const std::vector> axesGather = { {3} }; -const std::vector> axesZeroDim { - {1, 3}, - {0, 1, 3}, - {1, 2, 3}, - {0, 1, 2, 3} -}; - const std::vector> axesZeroDimFusing = { {1, 3}, }; @@ -161,6 +154,17 @@ const auto fusingFakeQuantizeTranspose = fusingSpecificParams{std::make_shared

fusingParamsFullSet { + emptyFusingSpec, + /* activations */ + fusingSwish, + /* FQ */ + fusingFakeQuantizePerChannelRelu, + fusingFakeQuantizePerTensorRelu, + /* another patterns */ + fusingScaleShift +}; + const std::vector fusingParamsSet { /* activations */ fusingSwish, @@ -342,34 +346,6 @@ const auto params_SingleBatch = testing::Combine( testing::Values(emptyFusingSpec), testing::ValuesIn(additionalConfig())); -const auto params_DimZero_Arithmetic = testing::Combine( - testing::Combine( - testing::ValuesIn(axesZeroDim), - testing::Values(ov::test::utils::OpType::VECTOR), - testing::ValuesIn(keepDims()), - testing::ValuesIn(reductionTypesArithmetic()), - testing::ValuesIn(inpOutPrc()), - testing::Values(ElementType::undefined), - testing::Values(ElementType::undefined), - testing::ValuesIn(inputShapes_Dynmic_ZeroDim)), - testing::Values(emptyCPUSpec), - testing::Values(emptyFusingSpec), - testing::ValuesIn(additionalConfig())); - -const auto params_DimZero_Compare = testing::Combine( - testing::Combine( - testing::ValuesIn(axesZeroDim), - testing::Values(ov::test::utils::OpType::VECTOR), - testing::ValuesIn(keepDims()), - testing::ValuesIn(reductionTypesCompare()), - testing::ValuesIn(inpOutPrc()), - testing::Values(ElementType::undefined), - testing::Values(ElementType::undefined), - testing::ValuesIn(inputShapes_Dynmic_ZeroDim)), - testing::Values(emptyCPUSpec), - testing::Values(emptyFusingSpec), - testing::ValuesIn(additionalConfigFP32())); - INSTANTIATE_TEST_SUITE_P( smoke_Reduce_OneAxis_CPU, ReduceCPULayerTest, @@ -447,20 +423,6 @@ INSTANTIATE_TEST_SUITE_P( ReduceCPULayerTest::getTestCaseName ); -INSTANTIATE_TEST_SUITE_P( - smoke_Reduce_DimZero_Arithmetic_CPU, - ReduceCPULayerTest, - params_DimZero_Arithmetic, - ReduceCPULayerTest::getTestCaseName -); - -INSTANTIATE_TEST_SUITE_P( - smoke_Reduce_DimZero_Compare_CPU, - ReduceCPULayerTest, - params_DimZero_Compare, - ReduceCPULayerTest::getTestCaseName -); - /* ================================ 1.2 No fusion - Logical ================================ */ const auto params_OneAxis_Logical = testing::Combine( testing::Combine( @@ -670,7 +632,7 @@ const auto params_DimZero_Arithmetic_fusing = testing::Combine( testing::Values(ElementType::undefined), testing::ValuesIn(inputShapes_Dynmic_ZeroDim)), testing::Values(emptyCPUSpec), - testing::ValuesIn(fusingParamsSet), + testing::ValuesIn(fusingParamsFullSet), testing::ValuesIn(additionalConfig())); const auto params_DimZero_Compare_fusing = testing::Combine( @@ -684,7 +646,7 @@ const auto params_DimZero_Compare_fusing = testing::Combine( testing::Values(ElementType::undefined), testing::ValuesIn(inputShapes_Dynmic_ZeroDim)), testing::Values(emptyCPUSpec), - testing::ValuesIn(fusingParamsSet), + testing::ValuesIn(fusingParamsFullSet), testing::ValuesIn(additionalConfigFP32())); INSTANTIATE_TEST_SUITE_P( @@ -779,34 +741,6 @@ const auto params_MultiAxis_5D_Hybrid_fusing_KeepNoDims = testing::Combine( testing::ValuesIn(fusingParamsSet_KeepNoDims), testing::ValuesIn(additionalConfigFP32())); -const auto params_DimZero_Arithmetic_fusing_KeepNoDims = testing::Combine( - testing::Combine( - testing::ValuesIn(axesZeroDimFusing), - testing::Values(ov::test::utils::OpType::VECTOR), - testing::Values(false), - testing::ValuesIn(reductionTypesArithmetic()), - testing::ValuesIn(inpOutPrc()), - testing::Values(ElementType::undefined), - testing::Values(ElementType::undefined), - testing::ValuesIn(inputShapes_Dynmic_ZeroDim)), - testing::Values(emptyCPUSpec), - testing::ValuesIn(fusingParamsSet_KeepNoDims), - testing::ValuesIn(additionalConfig())); - -const auto params_DimZero_Compare_fusing_KeepNoDims = testing::Combine( - testing::Combine( - testing::ValuesIn(axesZeroDimFusing), - testing::Values(ov::test::utils::OpType::VECTOR), - testing::Values(false), - testing::ValuesIn(reductionTypesCompare()), - testing::ValuesIn(inpOutPrc()), - testing::Values(ElementType::undefined), - testing::Values(ElementType::undefined), - testing::ValuesIn(inputShapes_Dynmic_ZeroDim)), - testing::Values(emptyCPUSpec), - testing::ValuesIn(fusingParamsSet_KeepNoDims), - testing::ValuesIn(additionalConfigFP32())); - INSTANTIATE_TEST_SUITE_P( smoke_Reduce_OneAxis_fusing_KeepNoDims_CPU, ReduceCPULayerTest, @@ -828,20 +762,6 @@ INSTANTIATE_TEST_SUITE_P( ReduceCPULayerTest::getTestCaseName ); -INSTANTIATE_TEST_SUITE_P( - smoke_Reduce_DimZero_Arithmetic_fusing_KeepNoDims_CPU, - ReduceCPULayerTest, - params_DimZero_Arithmetic_fusing_KeepNoDims, - ReduceCPULayerTest::getTestCaseName -); - -INSTANTIATE_TEST_SUITE_P( - smoke_Reduce_DimZero_Comapre_fusing_KeepNoDims_CPU, - ReduceCPULayerTest, - params_DimZero_Arithmetic_fusing_KeepNoDims, - ReduceCPULayerTest::getTestCaseName -); - } // namespace } // namespace Reduce } // namespace test