From 56a799be6e81270122e69033931ee0a8a1ee53e5 Mon Sep 17 00:00:00 2001 From: liubo-intel Date: Thu, 24 Oct 2024 15:43:32 +0800 Subject: [PATCH] use 1D TensorInfo method to fix acl_convert UNKNOWN DataLayout accuracy issues while keep opt impl --- .../src/nodes/executors/acl/acl_convert.cpp | 18 +++-------- .../single_layer_tests/classes/conversion.cpp | 32 +++++++++---------- .../single_layer_tests/classes/conversion.hpp | 4 +-- .../instances/arm/conversion.cpp | 4 +-- 4 files changed, 25 insertions(+), 33 deletions(-) diff --git a/src/plugins/intel_cpu/src/nodes/executors/acl/acl_convert.cpp b/src/plugins/intel_cpu/src/nodes/executors/acl/acl_convert.cpp index c803ceec7188c2..1bc0585930387f 100644 --- a/src/plugins/intel_cpu/src/nodes/executors/acl/acl_convert.cpp +++ b/src/plugins/intel_cpu/src/nodes/executors/acl/acl_convert.cpp @@ -27,12 +27,11 @@ bool ACLConvertExecutor::init(const ConvertParams& convertParams, if (!isCopyOp && dstPrecision == DataType::S8) { dstPrecision = DataType::QASYMM8_SIGNED; } - auto srcDims = srcDesc->getShape().getStaticDims(); - auto dstDims = dstDesc->getShape().getStaticDims(); - auto srcDataLayout = getAclDataLayoutByMemoryDesc(srcDesc); - auto dstDataLayout = getAclDataLayoutByMemoryDesc(dstDesc); - auto srcTensorInfo = TensorInfo(shapeCast(collapse_dims_to_max_rank(srcDims)), 1, srcPrecision, srcDataLayout); - auto dstTensorInfo = TensorInfo(shapeCast(collapse_dims_to_max_rank(dstDims)), 1, dstPrecision, dstDataLayout); + // Use 1D TensorInfo, since UNKNOWN DataLayout may have accuracy issues + auto srcDims1D = convertParams.size; + auto dstDims1D = convertParams.size; + auto srcTensorInfo = TensorInfo(TensorShape(srcDims1D), 1, srcPrecision); + auto dstTensorInfo = TensorInfo(TensorShape(dstDims1D), 1, dstPrecision); if (isCopyOp) { Status s = NECopy::validate(&srcTensorInfo, &dstTensorInfo); if (!s) { @@ -92,13 +91,6 @@ bool ACLConvertExecutorBuilder::isSupported(const ConvertParams& convertParams, DEBUG_LOG("NECopy does not support source precision: ", convertParams.srcPrc.to_string()); return false; } - // currenlty not support UNKNOWN DataLayout to avoid accuracy issues - auto srcDataLayout = getAclDataLayoutByMemoryDesc(srcDesc); - auto dstDataLayout = getAclDataLayoutByMemoryDesc(dstDesc); - if (srcDataLayout == DataLayout::UNKNOWN || dstDataLayout == DataLayout::UNKNOWN) { - DEBUG_LOG("NECopy does not support source or destination layout"); - return false; - } if ((convertParams.srcPrc == ov::element::i8 && !one_of(convertParams.dstPrc, ov::element::i16, ov::element::i32, diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/conversion.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/conversion.cpp index 56be9ddd5bd0fa..4989fb3a0f04b7 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/conversion.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/conversion.cpp @@ -187,12 +187,12 @@ const std::vector& inShapes_4D_static() { return inShapes_4D_static; } -const std::vector& inShapes_5D_static() { - static const std::vector inShapes_5D_static = { - {{1, 2, 3, 4, 5}, {{1, 2, 3, 4, 5}}}, - {{1, 1, 1, 1080, 1920}, {{1, 1, 1, 1080, 1920}}}, +const std::vector& inShapes_7D_static() { + static const std::vector inShapes_7D_static = { + {{1, 2, 3, 4, 5, 6, 7}, {{1, 2, 3, 4, 5, 6, 7}}}, + {{1, 1, 1, 1, 1, 1080, 1920}, {{1, 1, 1, 1, 1, 1080, 1920}}}, }; - return inShapes_5D_static; + return inShapes_7D_static; } const std::vector& inShapes_4D_dynamic() { @@ -221,30 +221,30 @@ const std::vector& inShapes_4D_dynamic() { return inShapes_4D_dynamic; } -const std::vector& inShapes_5D_dynamic() { - static const std::vector inShapes_5D_dynamic = { +const std::vector& inShapes_7D_dynamic() { + static const std::vector inShapes_7D_dynamic = { { // dynamic - {{-1, -1, -1, -1, -1}}, + {{-1, -1, -1, -1, -1, -1, -1}}, // target { - {2, 4, 4, 4, 3}, - {2, 17, 5, 4, 3}, - {1, 2, 3, 4, 5} + {2, 4, 4, 4, 3, 3, 1}, + {2, 17, 5, 4, 3, 2, 1}, + {1, 2, 3, 4, 5, 6, 7} } }, { // dynamic - {{{1, 5}, {2, 22}, {2, 9}, {1, 4}, {1, 4}}}, + {{{1, 5}, {2, 22}, {2, 9}, {1, 4}, {1, 4}, {1, 4}, {1, 4}}}, // target { - {2, 17, 5, 4, 3}, - {5, 2, 3, 2, 4}, - {1, 10, 4, 1, 4}, + {2, 17, 5, 4, 3, 1, 2}, + {5, 2, 3, 2, 4, 1, 3}, + {1, 10, 4, 1, 4, 2, 3}, } } }; - return inShapes_5D_dynamic; + return inShapes_7D_dynamic; } const std::vector& precisions() { diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/conversion.hpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/conversion.hpp index 513ca5f19c0fa1..a53f56f873151c 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/conversion.hpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/conversion.hpp @@ -39,8 +39,8 @@ class ConvertToBooleanCPULayerTest : public ConvertCPULayerTest { namespace Conversion { const std::vector& inShapes_4D_static(); const std::vector& inShapes_4D_dynamic(); -const std::vector& inShapes_5D_static(); -const std::vector& inShapes_5D_dynamic(); +const std::vector& inShapes_7D_static(); +const std::vector& inShapes_7D_dynamic(); const std::vector& precisions(); } // namespace Conversion } // namespace test diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/arm/conversion.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/arm/conversion.cpp index b0e021aba6e479..11e0440b2e3618 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/arm/conversion.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/arm/conversion.cpp @@ -13,7 +13,7 @@ namespace Conversion { INSTANTIATE_TEST_SUITE_P(smoke_ConvertCPULayerTest_7D_Dynamic, ConvertCPULayerTest, ::testing::Combine( - ::testing::ValuesIn(inShapes_5D_dynamic()), + ::testing::ValuesIn(inShapes_7D_dynamic()), ::testing::ValuesIn(precisions()), ::testing::ValuesIn(precisions()), ::testing::Values(CPUSpecificParams({}, {}, {}, {}))), @@ -21,7 +21,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_ConvertCPULayerTest_7D_Dynamic, ConvertCPULayerTe INSTANTIATE_TEST_SUITE_P(smoke_ConvertCPULayerTest_7D_Static, ConvertCPULayerTest, ::testing::Combine( - ::testing::ValuesIn(inShapes_5D_static()), + ::testing::ValuesIn(inShapes_7D_static()), ::testing::ValuesIn(precisions()), ::testing::ValuesIn(precisions()), ::testing::Values(CPUSpecificParams({}, {}, {}, {}))),