aboutsummaryrefslogtreecommitdiff
path: root/ethosu/vela/tensor.py
diff options
context:
space:
mode:
authorTim Hall <tim.hall@arm.com>2022-03-03 17:43:16 +0000
committerTim Hall <tim.hall@arm.com>2022-04-04 14:25:01 +0100
commita3fe665803c0f72000f9dda249446d5a0d03240f (patch)
tree1de76663d1a1d5a39cf795eecbc99d5479382735 /ethosu/vela/tensor.py
parent68df8a1f5469daac53b7a418d92204f7026e4228 (diff)
downloadethos-u-vela-dev/mlbedsw-6271.tar.gz
vela: Minor refactordev/mlbedsw-6271
- Changed comments to docstring on QuantizationParams - Simplified op type to op name conversion Signed-off-by: Tim Hall <tim.hall@arm.com> Change-Id: I2fdf5922cc17944c9bd37917a85fdfe50a1e651d
Diffstat (limited to 'ethosu/vela/tensor.py')
-rw-r--r--ethosu/vela/tensor.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/ethosu/vela/tensor.py b/ethosu/vela/tensor.py
index 783f459e..38b0e430 100644
--- a/ethosu/vela/tensor.py
+++ b/ethosu/vela/tensor.py
@@ -269,9 +269,10 @@ class QuantizationParameters:
return np.subtract(values, self.zero_point) * self.scale_f32
def is_scaling_equal(self, other: Optional["QuantizationParameters"]) -> bool:
- # quantisation parameter scaling is not equal if 'other' is None because
- # it implies that the tensor it belongs to is not quantised. otherwise,
- # it depends upon whether the scale and zero point are equal
+ """
+ Returns True if the scale and zero point of self and other are equal. If other is None then the scaling is
+ not considered equal because the tensor is assumed to not be quantised and False will be returned
+ """
if not isinstance(other, QuantizationParameters):
return False
@@ -279,12 +280,13 @@ class QuantizationParameters:
return self.scale_f32 == other.scale_f32 and self.zero_point == other.zero_point
def is_valid(self) -> bool:
- # quantisation parameters are consider valid if they have a scale and zero point
+ """Return True if the quantisation parameters have a scale and zero point"""
return self.scale_f32 is not None and self.zero_point is not None
def is_per_axis(self) -> bool:
"""Returns True if either the scale, zero point, minimum or maximum values have more than one value"""
+
for attr in ("scale_f32", "zero_point", "min", "max"):
if np.size(getattr(self, attr)) > 1:
return True