diff options
author | Tim Hall <tim.hall@arm.com> | 2021-02-04 22:47:46 +0000 |
---|---|---|
committer | Tim Hall <tim.hall@arm.com> | 2021-02-05 11:30:49 +0000 |
commit | 73e843f76dd71e4ab5e07a7616c2c4806ca6ac25 (patch) | |
tree | 73c35c5443e041441ba826cacfc12f21d5b30bac /ethosu/vela/graph_optimiser.py | |
parent | 133ba7e39c9517d43690c55197d71733ad0dc38c (diff) | |
download | ethos-u-vela-73e843f76dd71e4ab5e07a7616c2c4806ca6ac25.tar.gz |
vela: Change Shape4D mutability usage
- Removed requirement for cloning shapes when unique values required
by forcing top-level immutability. This alleviates issues with Shapes
being unintentionally shared and then mutated as if value-types.
- Shape4D fields can no longer be assigned without replication.
Signed-off-by: Tim Hall <tim.hall@arm.com>
Change-Id: Ic0dbfa349eb0215eabefb4f4e2cf99f12d83699c
Diffstat (limited to 'ethosu/vela/graph_optimiser.py')
-rw-r--r-- | ethosu/vela/graph_optimiser.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/ethosu/vela/graph_optimiser.py b/ethosu/vela/graph_optimiser.py index e84e11e9..1e3b1314 100644 --- a/ethosu/vela/graph_optimiser.py +++ b/ethosu/vela/graph_optimiser.py @@ -101,14 +101,14 @@ def rewrite_concat_ops(op, arch): new_op.outputs = [ofm] new_op.attrs["concat_axis"] = axis_4D new_op.attrs["concat_start"] = offset - offset += op.ifm_shapes[idx].get_dim(axis_4D) + offset += op.ifm_shapes[idx][axis_4D] new_op.attrs["concat_end"] = offset new_op.run_on_npu = True ofm.ops.append(new_op) DebugDatabase.add_optimised(op, new_op) - new_op.ifm_shapes.append(op.ifm_shapes[idx].clone()) - new_op.ofm_shapes.append(op.ofm_shapes[0].clone()) + new_op.ifm_shapes.append(op.ifm_shapes[idx]) + new_op.ofm_shapes.append(op.ofm_shapes[0]) assert ofm.shape[axis] == offset # If axis corresponds to C-dimension, NHCWB16 can only be used in the output if all the concat_start's are a @@ -159,7 +159,7 @@ def rewrite_split_ops(tens, arch, nng): ofm_shape_idx = idx break - offset_start[axis_4D] += split_op.ofm_shapes[idx].get_dim(axis_4D) + offset_start[axis_4D] += split_op.ofm_shapes[idx][axis_4D] # If start offset is not a multiple of 16 in the C-dimension, NHCWB16 need to be avoided in the input if (offset_start[-1] % 16) != 0: @@ -171,7 +171,7 @@ def rewrite_split_ops(tens, arch, nng): new_op.run_on_npu = True new_op.set_output_tensor(tens) new_op.ifm_shapes.append(Shape4D(inp.shape)) - new_op.ofm_shapes.append(split_op.ofm_shapes[ofm_shape_idx].clone()) + new_op.ofm_shapes.append(split_op.ofm_shapes[ofm_shape_idx]) DebugDatabase.add_optimised(split_op, new_op) return tens |