From 73e843f76dd71e4ab5e07a7616c2c4806ca6ac25 Mon Sep 17 00:00:00 2001 From: Tim Hall Date: Thu, 4 Feb 2021 22:47:46 +0000 Subject: 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 Change-Id: Ic0dbfa349eb0215eabefb4f4e2cf99f12d83699c --- ethosu/vela/npu_performance.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'ethosu/vela/npu_performance.py') diff --git a/ethosu/vela/npu_performance.py b/ethosu/vela/npu_performance.py index 3acd5e6c..5bba3b65 100644 --- a/ethosu/vela/npu_performance.py +++ b/ethosu/vela/npu_performance.py @@ -444,8 +444,8 @@ def performance_metrics_for_pass(arch, ps, block_config=None, rewrite_list=None, npu_block_type = primary_op.type.npu_block_type ifm_tensor, _, weight_tensor, ofm_tensor = ps.get_primary_op_ifm_ifm2_weights_ofm() - ifm_tensor_shape = ps.primary_op.ifm_shapes[0].clone() - ofm_tensor_shape = ps.primary_op.ofm_shapes[0].clone() + ifm_tensor_shape = ps.primary_op.ifm_shapes[0] + ofm_tensor_shape = ps.primary_op.ofm_shapes[0] ofm_block.width = min(ofm_block.width, ofm_tensor_shape.width) ofm_block.height = min(ofm_block.height, ofm_tensor_shape.height) ofm_block.depth = min(ofm_block.depth, ofm_tensor_shape.depth) @@ -480,9 +480,10 @@ def performance_metrics_for_pass(arch, ps, block_config=None, rewrite_list=None, batch_size = ifm_tensor_shape.batch - # add in padding - ifm_tensor_shape.height += explicit_padding[0] + explicit_padding[2] # height += top and bottom - ifm_tensor_shape.width += explicit_padding[1] + explicit_padding[3] # width += left and right + # add in padding, height += top and bottom, width += left and right + ifm_tensor_shape = ifm_tensor_shape.add( + 0, explicit_padding[0] + explicit_padding[2], explicit_padding[1] + explicit_padding[3], 0 + ) if npu_block_type != NpuBlockType.Pooling: if npu_block_type == NpuBlockType.ReduceSum: -- cgit v1.2.1