MLBEDSW-3004: UnpackReshaped can't be serialised
This commit fixes a bug where a rewritten Unpack
operator is placed on the CPU and crashes Vela
during serialisation due to the type having
changed and there not being a mapping for the
modified op type.
The solution is to move the fixup_unpack_output
function to the graph optimisation pass B,
allowing the supported op check to run before it.
Signed-off-by: Dwight Lidman <dwight.lidman@arm.com>
Change-Id: Ic6bd4c70a478fd61adf377cb487f5b9253130314
diff --git a/ethosu/vela/graph_optimiser.py b/ethosu/vela/graph_optimiser.py
index d442352..f6209ed 100644
--- a/ethosu/vela/graph_optimiser.py
+++ b/ethosu/vela/graph_optimiser.py
@@ -421,7 +421,7 @@
def fixup_unpack_output(tens, arch, nng):
op = tens.ops[0]
- if op.type in set((Op.Unpack, Op.StridedSlice)):
+ if op.run_on_npu and op.type in set((Op.Unpack, Op.StridedSlice)):
# Unpack is also referred to as Unstack
# Requires the rewrite_split function to be called on the op afterwards
@@ -1061,7 +1061,7 @@
for idx, sg in enumerate(nng.subgraphs):
# rewrite graph pass
nng.subgraphs[idx] = rewrite_graph.rewrite_graph_pre_order(
- nng, sg, arch, [fixup_unpack_output], op_rewrite_list, rewrite_unsupported=False
+ nng, sg, arch, [], op_rewrite_list, rewrite_unsupported=False,
)
for idx, sg in enumerate(nng.subgraphs):
@@ -1081,7 +1081,9 @@
for idx, sg in enumerate(nng.subgraphs):
# combined rewrite graph pass
- nng.subgraphs[idx] = rewrite_graph.rewrite_graph_pre_order(nng, sg, arch, [rewrite_concat, rewrite_split], [])
+ nng.subgraphs[idx] = rewrite_graph.rewrite_graph_pre_order(
+ nng, sg, arch, [fixup_unpack_output, rewrite_concat, rewrite_split], []
+ )
if verbose_graph:
nng.print_graph()
diff --git a/ethosu/vela/operation.py b/ethosu/vela/operation.py
index 710511c..6e5b482 100644
--- a/ethosu/vela/operation.py
+++ b/ethosu/vela/operation.py
@@ -314,7 +314,7 @@
class Operation:
"""Class representing a Neural Network operation. Has a name, a type,
-input and output tensors, as well as an attribute dictionary."""
+ input and output tensors, as well as an attribute dictionary."""
__slots__ = (
"type",