From cf131d954ab0e1ebf403ca9edf5fc9783b85c38a Mon Sep 17 00:00:00 2001 From: William Isaksson Date: Tue, 1 Apr 2025 17:45:54 +0200 Subject: [PATCH] MLBEDSW-10596: Disable non-identity rescale fusing for AvgPool - Disables rescale fusing onto AvgPool ofm. Change-Id: Idc8c5e2450c021684b241a99198f1f4d088c7270 Signed-off-by: William Isaksson --- .../ethosu55/ethos_u55_constraints.cpp | 16 +++++++++++++--- .../ethosu85/ethos_u85_constraints.cpp | 16 +++++++++++++--- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/ethosu/regor/architecture/ethosu55/ethos_u55_constraints.cpp b/ethosu/regor/architecture/ethosu55/ethos_u55_constraints.cpp index 76bde959..9d93197e 100644 --- a/ethosu/regor/architecture/ethosu55/ethos_u55_constraints.cpp +++ b/ethosu/regor/architecture/ethosu55/ethos_u55_constraints.cpp @@ -130,10 +130,20 @@ bool EthosU55Constraints::SupportsFusedRescale(OpType opType, TensorUsage tensor else if ( tensorUsage == TensorUsage::OFM ) { int fromBits = DataTypeSizeBits(opFromType); - if ( npuOp == EthosU55NpuOp::Convolution || npuOp == EthosU55NpuOp::Depthwise || - npuOp == EthosU55NpuOp::Pooling || npuOp == EthosU55NpuOp::VectorProduct ) + if ( npuOp == EthosU55NpuOp::Convolution || npuOp == EthosU55NpuOp::Depthwise || npuOp == EthosU55NpuOp::VectorProduct ) { - return opType != OpType::Rescale && !IsActivation(opType); + return true; + } + else if ( npuOp == EthosU55NpuOp::Pooling ) + { + if ( opType == OpType::AvgPool ) + { + return globalScale && isUnitScale; + } + else + { + return opType != OpType::Rescale && !IsActivation(opType); + } } else if ( npuOp == EthosU55NpuOp::Elementwise && globalScale ) { diff --git a/ethosu/regor/architecture/ethosu85/ethos_u85_constraints.cpp b/ethosu/regor/architecture/ethosu85/ethos_u85_constraints.cpp index f43a8407..67270d9e 100644 --- a/ethosu/regor/architecture/ethosu85/ethos_u85_constraints.cpp +++ b/ethosu/regor/architecture/ethosu85/ethos_u85_constraints.cpp @@ -169,10 +169,20 @@ bool EthosU85Constraints::SupportsFusedRescale(OpType opType, TensorUsage tensor { int fromBits = DataTypeSizeBits(opFromType); int toBits = DataTypeSizeBits(rescaleToType); - if ( npuOp == EthosU85NpuOp::Convolution || npuOp == EthosU85NpuOp::Depthwise || - npuOp == EthosU85NpuOp::Pooling || npuOp == EthosU85NpuOp::VectorProduct ) + if ( npuOp == EthosU85NpuOp::Convolution || npuOp == EthosU85NpuOp::Depthwise || npuOp == EthosU85NpuOp::VectorProduct ) { - return opType != OpType::Rescale && !IsActivation(opType); + return true; + } + else if ( npuOp == EthosU85NpuOp::Pooling ) + { + if ( opType == OpType::AvgPool ) + { + return globalScale && isUnitScale; + } + else + { + return opType != OpType::Rescale && !IsActivation(opType); + } } else if ( npuOp == EthosU85NpuOp::Resize && globalScale ) { -- GitLab