aboutsummaryrefslogtreecommitdiff
path: root/ethosu/vela/tensor.py
diff options
context:
space:
mode:
authorTim Hall <tim.hall@arm.com>2022-11-03 12:25:33 +0000
committerTim Hall <tim.hall@arm.com>2022-11-03 12:25:33 +0000
commit92cd33b7adbb799b6593d49f1d29c13a85933e55 (patch)
tree56b9d7a858950022a08e4e7e10d70cc648769b12 /ethosu/vela/tensor.py
parentb9f8159af8bb4e1eeb522f26852d8cbf90cb87a3 (diff)
downloadethos-u-vela-92cd33b7adbb799b6593d49f1d29c13a85933e55.tar.gz
MLBEDSW-7082: Weight tensor shape is incorrect
- A bug was introduced by using the original_shape attribute that causes CPU CONV2D ops to fail to run due to an incorrect weight tensor shape - This was due to the original_shape not being modified when a transpose was performed on the weight tensor - The fix was to transpose the original_shape just like the current shape Signed-off-by: Tim Hall <tim.hall@arm.com> Change-Id: Ied72316463d26c502cf931b9dd5784041c42ab66
Diffstat (limited to 'ethosu/vela/tensor.py')
-rw-r--r--ethosu/vela/tensor.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/ethosu/vela/tensor.py b/ethosu/vela/tensor.py
index 673208ac..8e553e82 100644
--- a/ethosu/vela/tensor.py
+++ b/ethosu/vela/tensor.py
@@ -484,6 +484,17 @@ class Tensor:
res.src_tensor = self
return res
+ def as_1D(self):
+ self.shape = [np.prod(self.shape)]
+ if self.values is not None:
+ self.values = self.values.reshape(self.shape)
+
+ def transpose(self, reorder):
+ self.shape = [self.shape[idx] for idx in reorder]
+ self._original_shape = [self._original_shape[idx] for idx in reorder]
+ if self.values is not None:
+ self.values = self.values.transpose(reorder)
+
def copy_compressed_weight_info(self, src_tens: "Tensor"):
# Copies compressed values + all related weight compression info from the given tensor
self.equivalence_id = src_tens.equivalence_id