From 7ad408bd84e324f49f90c3a4ad01ee5f7ce9f1ba Mon Sep 17 00:00:00 2001 From: Dwight Lidman Date: Tue, 11 Aug 2020 11:55:22 +0200 Subject: MLBEDSW-2586: Null check before accessing tensor resampling mode This commit amends a mistake where the resample_mode attribute of a tensor would be accessed without checking if the tensor in question was actually there first. Signed-off-by: Dwight Lidman Change-Id: Id2ceb1d6e38133611fcecfc2ac97150c927ceee2 --- ethosu/vela/shared_buffer_allocation.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ethosu/vela/shared_buffer_allocation.py b/ethosu/vela/shared_buffer_allocation.py index 7268d9f9..c9686194 100644 --- a/ethosu/vela/shared_buffer_allocation.py +++ b/ethosu/vela/shared_buffer_allocation.py @@ -23,6 +23,7 @@ from .architecture_features import Kernel from .architecture_features import SharedBufferArea from .architecture_features import SHRAMElements from .errors import VelaError +from .ethos_u55_regs.ethos_u55_regs import resampling_mode from .operation import NpuBlockType @@ -67,9 +68,11 @@ class SharedBufferAllocation: else: self.use_ifm_element = SHRAMElements.IFM8 + self.ifm_resampling_mode = resampling_mode.NONE self.ifm_bits = 0 self.ifm_depth = 0 if ifm_tensor: + self.ifm_resampling_mode = ifm_tensor.resampling_mode self.ifm_bits = ifm_tensor.dtype.size_in_bits() if ifm_tensor.shape == [] and is_elementwise: # Elementwise operator with scalar in ifm, use ifm2 depth @@ -87,7 +90,6 @@ class SharedBufferAllocation: else: assert self.ifm_bits == 8, "Unexpected IFM bitdepth" - self.ifm_resampling_mode = ifm_tensor.resampling_mode self.ifm_block_depth = arch.calc_ifm_block_depth(self.ifm_depth, self.ifm_bits) self.ofm_tensor = ofm_tensor -- cgit v1.2.1