MLBEDSW-1538: Output diff for elementwise min/max
This commit adds a quantization restriction check
for supported operators, so that operators with
different quantization between its IFM (1/2) and
OFM tensors that do not support it, are correctly
placed on the CPU.
The quantization between two tensors is compared
using a new equality function implemented for
the QuantizationParameters class.
Signed-off-by: Dwight Lidman <dwight.lidman@arm.com>
Change-Id: I70ff36b4ab4955f328d6e6e699f00dbc43c0404a
diff --git a/ethosu/vela/tensor.py b/ethosu/vela/tensor.py
index 5e97cfe..42ba853 100644
--- a/ethosu/vela/tensor.py
+++ b/ethosu/vela/tensor.py
@@ -181,6 +181,19 @@
__repr__ = __str__
+ def __eq__(self, other):
+ if other is None:
+ return False
+ if not isinstance(other, QuantizationParameters):
+ return False
+
+ pairs = ((getattr(self, s), getattr(other, s)) for s in QuantizationParameters.__slots__)
+
+ return all(np.array_equal(a, b) for a, b in pairs)
+
+ def __ne__(self, other):
+ return not self == other
+
def clone(self):
res = QuantizationParameters()
res.min = self.min