aboutsummaryrefslogtreecommitdiff
path: root/ethosu/vela/tflite_reader.py
diff options
context:
space:
mode:
authorDwight Lidman <dwight.lidman@arm.com>2020-05-13 12:00:08 +0200
committerTim Hall <tim.hall@arm.com>2020-06-18 17:53:52 +0100
commita9390f7fbd35dca75e80710835f67bb1d75d7c93 (patch)
treedf3606c28425e3a3504b29fe79ac8ddd0e2b8661 /ethosu/vela/tflite_reader.py
parent388e9c230898385df59e6175aa45012e5864c09a (diff)
downloadethos-u-vela-a9390f7fbd35dca75e80710835f67bb1d75d7c93.tar.gz
MLBEDSW-1971: Verify ifm block size calculation against specification
This commit ensures the IFM block size calculation in architecture_features.py matches the specification by correctly setting the ifm upscaling factor based on the upscaling mode. This requires adding an attribute to the Tensor object which stores the upscaling mode for that specific tensor and making sure that information is correctly carried over to shared_buffer_allocation.py. Signed-off-by: Dwight Lidman <dwight.lidman@arm.com> Change-Id: I4ab56086f4c694d3bf759bbad30cdb969b4a26db
Diffstat (limited to 'ethosu/vela/tflite_reader.py')
-rw-r--r--ethosu/vela/tflite_reader.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/ethosu/vela/tflite_reader.py b/ethosu/vela/tflite_reader.py
index 850690f2..4ee39634 100644
--- a/ethosu/vela/tflite_reader.py
+++ b/ethosu/vela/tflite_reader.py
@@ -20,6 +20,7 @@ import os.path
import numpy as np
from .errors import UnsupportedFeatureError
+from .ethos_u55_regs.ethos_u55_regs import resampling_mode
from .nn_graph import Graph
from .nn_graph import Subgraph
from .operation import Operation
@@ -146,7 +147,8 @@ class TFLiteSubgraph:
op.attrs = opt_serializer.deserialize(op_data.BuiltinOptions(), op_data.CustomOptionsAsNumpy())
if op_type.startswith("ResizeBilinear"):
- upscaled_shape = [op.inputs[0].shape[1] * 2, op.inputs[0].shape[2] * 2]
+ input_tensor = op.inputs[0]
+ upscaled_shape = [input_tensor.shape[1] * 2, input_tensor.shape[2] * 2]
out_shape = op.outputs[0].shape[1:3]
if not op.attrs["align_corners"] and out_shape == upscaled_shape:
# this means the output is supposed to be a x2 upscale,
@@ -160,6 +162,8 @@ class TFLiteSubgraph:
raise UnsupportedFeatureError("ResizeBilinear: Only 2x upscaling is supported")
op.attrs.update({"filter_width": 2, "filter_height": 2, "stride_w": 1, "stride_h": 1})
+ input_tensor.resampling_mode = resampling_mode.NEAREST
+
if "stride_w" in op.attrs:
op.attrs["strides"] = (1, op.attrs["stride_h"], op.attrs["stride_w"], 1)
if "filter_width" in op.attrs: