MLBEDSW-3902: Fixes invalid op when cloning LeakyReLU operator
When running specific networks containing LeakyReLU operators, Vela would crash when cloning an ofm of a LeakyReLU operator.
In this procedure a deepcopy usage would try to copy an OperatorInfo object, which caused an error.
This was fixed by replacing the deepcopy usage with a copy and then manually referencing new instances of sensitive variables.
Signed-off-by: erik.andersson@arm.com <erik.andersson@arm.com>
Change-Id: I46917858896fbdf52245dac6c6d9c18bc7ecdd0d
diff --git a/ethosu/vela/tensor.py b/ethosu/vela/tensor.py
index ef8a28f..b7d4307 100644
--- a/ethosu/vela/tensor.py
+++ b/ethosu/vela/tensor.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2020 Arm Limited or its affiliates. All rights reserved.
+# Copyright (C) 2020-2021 Arm Limited or its affiliates. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
@@ -437,15 +437,13 @@
# Depending on set_unique, the copy is shallow, or deep
# For set_unique==True, a new equivalence_id will be set
def clone(self, suffix="_clone", set_unique: bool = False) -> "Tensor":
+ res = copy.copy(self)
if set_unique:
- res = copy.deepcopy(self)
res.equivalence_id = uuid.uuid4()
- else:
- res = copy.copy(self)
- res.storage_shape = list(self.storage_shape)
- res.bandwidth_shape = list(self.bandwidth_shape)
- if self.quantization is not None:
- res.quantization = self.quantization.clone()
+ res.storage_shape = list(self.storage_shape)
+ res.bandwidth_shape = list(self.bandwidth_shape)
+ if self.quantization is not None:
+ res.quantization = self.quantization.clone()
res.name = res.name + suffix
res.ops = []