aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ethosu/vela/extract_npu_subgraphs.py3
-rw-r--r--ethosu/vela/pass_packing.py17
2 files changed, 9 insertions, 11 deletions
diff --git a/ethosu/vela/extract_npu_subgraphs.py b/ethosu/vela/extract_npu_subgraphs.py
index d802b513..f46f031a 100644
--- a/ethosu/vela/extract_npu_subgraphs.py
+++ b/ethosu/vela/extract_npu_subgraphs.py
@@ -98,6 +98,9 @@ def rewrite_tensor_cpu_producer_npu_consumers(
# Deal with output tensors for the NPU graph. These are special.
npu_subgraph.output_tensors = [new_tens if tens == orig_tens else tens for tens in npu_subgraph.output_tensors]
+ for tens in npu_subgraph.output_tensors:
+ # Enforce output tensor from NPU graph to use normal NHWC output
+ tens.needs_linear_format = True
def rewrite_tensor_npu_producer_cpu_consumers(
diff --git a/ethosu/vela/pass_packing.py b/ethosu/vela/pass_packing.py
index b84e4559..1fefdf42 100644
--- a/ethosu/vela/pass_packing.py
+++ b/ethosu/vela/pass_packing.py
@@ -179,7 +179,7 @@ for (operation_set, incompatible_pack_flags, flags_to_set, flags_to_clear) in te
def pack_into_passes(nng, arch, verbose_packing=False):
- def visit_op(op, multiple_ops=None):
+ def visit_op(op, ignored):
visit_op_refcount[op] += 1
if visit_op_refcount[op] == 1: # First-time visit, go and fix up unused output tensors
@@ -187,6 +187,7 @@ def pack_into_passes(nng, arch, verbose_packing=False):
if len(tens.consumers()) == 0:
visit_op_refcount[op] += 1
+ assert visit_op_refcount[op] <= len(op.outputs)
if visit_op_refcount[op] == len(op.outputs):
if op.type in startup_init_ops:
@@ -197,9 +198,9 @@ def pack_into_passes(nng, arch, verbose_packing=False):
ofm_tensor = op.outputs[0]
ofm_shape = op.ofm_shapes[0] if op.run_on_npu else None
- build_pass((op,), ofm_tensor, ofm_shape, multiple_ops)
+ build_pass((op,), ofm_tensor, ofm_shape)
- def build_pass(start_ops_to_process, ofm_tensor=None, ofm_shape=None, multiple_ops=None):
+ def build_pass(start_ops_to_process, ofm_tensor=None, ofm_shape=None):
reverse_ops_list = []
curr_flags = PassFlags.Empty
npu_block_type = NpuBlockType.Default
@@ -372,10 +373,6 @@ def pack_into_passes(nng, arch, verbose_packing=False):
reverse_pass_list.append(ps)
- if multiple_ops:
- multiple_op_next = multiple_ops.pop(0)
- visit_op(multiple_op_next, multiple_ops)
-
for inp, refcount in input_refcounts.items():
for _ in range(refcount):
visit_tensor(inp)
@@ -386,10 +383,8 @@ def pack_into_passes(nng, arch, verbose_packing=False):
visit_tensor_refcount[tens] += 1
assert visit_tensor_refcount[tens] <= len(tens.consumers())
if visit_tensor_refcount[tens] == len(tens.consumers()):
- if tens.ops:
- op = tens.ops[0]
- multiple_ops = [o for o in tens.ops if o != op]
- visit_op(op, multiple_ops)
+ for op in reversed(tens.ops):
+ visit_op(op, tens)
def create_primary_op(op_list):
if any(op.type in (npu_post_ops | npu_post_fuse_limited_ops) and op.run_on_npu for op in op_list):