Skip to content

Commit

Permalink
use 1D TensorInfo method to fix acl_convert UNKNOWN DataLayout accura…
Browse files Browse the repository at this point in the history
…cy issues while keep opt impl
  • Loading branch information
liubo-intel committed Oct 24, 2024
1 parent 216e8f8 commit 56a799b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 33 deletions.
18 changes: 5 additions & 13 deletions src/plugins/intel_cpu/src/nodes/executors/acl/acl_convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,12 @@ const std::vector<InputShape>& inShapes_4D_static() {
return inShapes_4D_static;
}

const std::vector<InputShape>& inShapes_5D_static() {
static const std::vector<InputShape> 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<InputShape>& inShapes_7D_static() {
static const std::vector<InputShape> 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<InputShape>& inShapes_4D_dynamic() {
Expand Down Expand Up @@ -221,30 +221,30 @@ const std::vector<InputShape>& inShapes_4D_dynamic() {
return inShapes_4D_dynamic;
}

const std::vector<InputShape>& inShapes_5D_dynamic() {
static const std::vector<InputShape> inShapes_5D_dynamic = {
const std::vector<InputShape>& inShapes_7D_dynamic() {
static const std::vector<InputShape> 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<ov::element::Type>& precisions() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class ConvertToBooleanCPULayerTest : public ConvertCPULayerTest {
namespace Conversion {
const std::vector<InputShape>& inShapes_4D_static();
const std::vector<InputShape>& inShapes_4D_dynamic();
const std::vector<InputShape>& inShapes_5D_static();
const std::vector<InputShape>& inShapes_5D_dynamic();
const std::vector<InputShape>& inShapes_7D_static();
const std::vector<InputShape>& inShapes_7D_dynamic();
const std::vector<ov::element::Type>& precisions();
} // namespace Conversion
} // namespace test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ 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({}, {}, {}, {}))),
ConvertCPULayerTest::getTestCaseName);

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({}, {}, {}, {}))),
Expand Down

0 comments on commit 56a799b

Please sign in to comment.