aboutsummaryrefslogtreecommitdiff
path: root/ethosu/vela/tflite_reader.py
diff options
context:
space:
mode:
authorLouis Verhaard <louis.verhaard@arm.com>2020-05-25 15:05:26 +0200
committerTim Hall <tim.hall@arm.com>2020-06-18 17:53:52 +0100
commit7db78969dc8ead72f3ded81b6d2a6a7ed798ea62 (patch)
tree011bcf579cc8e0f007f9564a98cc5c05df34322b /ethosu/vela/tflite_reader.py
parent78792223369fa34dacd0e69e189af035283da2ae (diff)
downloadethos-u-vela-7db78969dc8ead72f3ded81b6d2a6a7ed798ea62.tar.gz
MLBEDSW-2067: added custom exceptions
Added custom exceptions to handle different types of input errors. Also performed minor formatting changes using flake8/black. Change-Id: Ie5b05361507d5e569aff045757aec0a4a755ae98 Signed-off-by: Louis Verhaard <louis.verhaard@arm.com>
Diffstat (limited to 'ethosu/vela/tflite_reader.py')
-rw-r--r--ethosu/vela/tflite_reader.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/ethosu/vela/tflite_reader.py b/ethosu/vela/tflite_reader.py
index 7e158aac..850690f2 100644
--- a/ethosu/vela/tflite_reader.py
+++ b/ethosu/vela/tflite_reader.py
@@ -19,6 +19,7 @@ import os.path
import numpy as np
+from .errors import UnsupportedFeatureError
from .nn_graph import Graph
from .nn_graph import Subgraph
from .operation import Operation
@@ -147,18 +148,17 @@ class TFLiteSubgraph:
if op_type.startswith("ResizeBilinear"):
upscaled_shape = [op.inputs[0].shape[1] * 2, op.inputs[0].shape[2] * 2]
out_shape = op.outputs[0].shape[1:3]
- if not op.attrs['align_corners'] and out_shape == upscaled_shape:
+ if not op.attrs["align_corners"] and out_shape == upscaled_shape:
# this means the output is supposed to be a x2 upscale,
# so we need to do SAME padding
- op.attrs.update({'padding': b'SAME'})
- elif (op.attrs['align_corners']
- and out_shape == [upscaled_shape[0] - 1, upscaled_shape[1] - 1]):
+ op.attrs.update({"padding": b"SAME"})
+ elif op.attrs["align_corners"] and out_shape == [upscaled_shape[0] - 1, upscaled_shape[1] - 1]:
# here we can just run the avg pool without padding and
# produce a (M * 2 - 1, N * 2 - 1) sized output
- op.attrs.update({'padding': b'VALID'})
+ op.attrs.update({"padding": b"VALID"})
else:
- assert False, "Only 2x upscaling is supported"
- op.attrs.update({'filter_width': 2, 'filter_height': 2, 'stride_w': 1, 'stride_h': 1,})
+ raise UnsupportedFeatureError("ResizeBilinear: Only 2x upscaling is supported")
+ op.attrs.update({"filter_width": 2, "filter_height": 2, "stride_w": 1, "stride_h": 1})
if "stride_w" in op.attrs:
op.attrs["strides"] = (1, op.attrs["stride_h"], op.attrs["stride_w"], 1)