MLEMBED-1918: Issue with REDUCE_SUM on Ethos-U65-512
- Ethos-U65-512 requires the input to REDUCE_SUM to use NHWC format
- Updated the graph optimiser format check to cover this condition
- Added a exception check to the backend of the compiler to verify that
this condition is not been violated by the external api or Vela internals
Signed-off-by: Tim Hall <tim.hall@arm.com>
Change-Id: I2f1fabcbd264daf77d5822349d855a3a32b12c64
diff --git a/ethosu/vela/graph_optimiser_util.py b/ethosu/vela/graph_optimiser_util.py
index 57fd7db..5e7e112 100644
--- a/ethosu/vela/graph_optimiser_util.py
+++ b/ethosu/vela/graph_optimiser_util.py
@@ -20,6 +20,7 @@
import numpy as np
from . import lut
+from .architecture_features import Accelerator
from .data_type import DataType
from .debug_database import DebugDatabase
from .errors import UnsupportedFeatureError
@@ -111,7 +112,10 @@
return
for op in tens.consumer_list:
- if op.type == Op.ReduceSum and tens.dtype == DataType.int32:
+ if op.type == Op.ReduceSum and (
+ tens.dtype == DataType.int32 or arch.accelerator_config == Accelerator.Ethos_U65_512
+ ):
+ # ReduceSum requires NHWC input
return
if op.type == Op.Reshape:
# Using NHCWB16 format for a no-op reshape is only an option if subsequent