aboutsummaryrefslogtreecommitdiff
path: root/ethosu/vela/tensor.py
diff options
context:
space:
mode:
authorRickard Bolin <rickard.bolin@arm.com>2022-07-04 16:19:16 +0000
committerRickard Bolin <rickard.bolin@arm.com>2022-09-23 09:13:20 +0000
commitfea1516f94cfcbd801124e3fdc4b5f5c4526e15b (patch)
tree92b991244ef535d652d0bb6e875e9e3a289257f5 /ethosu/vela/tensor.py
parentcc219be4ec175645e8457da80d5effbf4324943b (diff)
downloadethos-u-vela-fea1516f94cfcbd801124e3fdc4b5f5c4526e15b.tar.gz
MLBEDSW-6686: Resize bilinear HPC with tile padding
- Added support for Resize Bilinear with half pixel centers for int8 and uint8. - Utilizes the new "TILE" padding mode. - Utilizes ofm stride multipliers and modified tile base offsets to write OFMs interleaved. Signed-off-by: Rickard Bolin <rickard.bolin@arm.com> Change-Id: I37fa77c022a368f05fda0ead75d8696c9205f833
Diffstat (limited to 'ethosu/vela/tensor.py')
-rw-r--r--ethosu/vela/tensor.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/ethosu/vela/tensor.py b/ethosu/vela/tensor.py
index 99970317..9fbd454c 100644
--- a/ethosu/vela/tensor.py
+++ b/ethosu/vela/tensor.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2020-2021 Arm Limited or its affiliates. All rights reserved.
+# Copyright (C) 2020-2022 Arm Limited or its affiliates. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
@@ -213,6 +213,7 @@ class QuantizationParameters:
"max",
"num_bits",
"narrow_range",
+ "next_after",
"scale_f32",
"zero_point",
"quant_min",
@@ -233,6 +234,10 @@ class QuantizationParameters:
self.num_bits = num_bits
self.narrow_range = narrow_range
+ # Use the 'next after' float value of scale_f32 when converting to scale and shift. It can be combined with
+ # natural rounding to perform rounding away from zero. This only affects the ofm scale and bias tensor, it has
+ # no affect on global scaling i.e. the ofm_scale register
+ self.next_after = False
self.scale_f32: Union[float, np.ndarray, None] = None
self.zero_point: Union[int, np.ndarray, None] = None
self.quant_min: Optional[float] = None
@@ -240,12 +245,9 @@ class QuantizationParameters:
self.quant_dim: Optional[int] = None
def __str__(self):
- return "<nng.QuantizationParameters min=%s max=%s, num_bits=%s, scale=%s, zero_point=%s>" % (
- self.min,
- self.max,
- self.num_bits,
- self.scale_f32,
- self.zero_point,
+ return (
+ f"<nng.QuantizationParameters min={self.min}, max={self.max}, num_bits={self.num_bits}, "
+ f"scale={self.scale_f32}, zero_point={self.zero_point}, next={self.next_after}>"
)
__repr__ = __str__
@@ -258,6 +260,7 @@ class QuantizationParameters:
res.num_bits = self.num_bits
res.narrow_range = self.narrow_range
+ res.next_after = self.next_after
res.scale_f32 = self.scale_f32
res.zero_point = self.zero_point
res.quant_min = self.quant_min