MLBEDSW-2663: Handle optional tensors
Includes a number of changes:
* Handle non-existing optional inputs
* Handle disabled optional inputs (-1 indexed)
* Added unit tests for parsing operators
* Add bias tensor to the different Convolutions + FullyConnected if
it's missing.
Signed-off-by: Jacob Bohlin <jacob.bohlin@arm.com>
Change-Id: Ib88d2b610314b1c886fc0aef4f9da87430ce6ae5
diff --git a/ethosu/vela/rewrite_graph.py b/ethosu/vela/rewrite_graph.py
index 4f0d010..e76e961 100644
--- a/ethosu/vela/rewrite_graph.py
+++ b/ethosu/vela/rewrite_graph.py
@@ -69,10 +69,11 @@
tens_visit_dict[tens] = res
tens_visit_dict[res] = res
- ops = res.ops
- res.ops = []
- for op in ops:
- res.ops.append(visit_op(op))
+ if res:
+ ops = res.ops
+ res.ops = []
+ for op in ops:
+ res.ops.append(visit_op(op))
return res
sg.output_tensors = [visit_tens(tens) for tens in sg.output_tensors]
@@ -142,6 +143,8 @@
op_visit_dict[op] = op
for tens in op.inputs:
+ if not tens:
+ continue
assert op in tens.consumers()
visit_tens(tens)