aboutsummaryrefslogtreecommitdiff
path: root/ethosu/vela/test/test_supported_operators.py
diff options
context:
space:
mode:
authorLouis Verhaard <louis.verhaard@arm.com>2021-01-08 11:17:33 +0100
committerLouis Verhaard <louis.verhaard@arm.com>2021-01-19 10:00:52 +0100
commit9a0cff1cd1334f4d3e7dfb542ad0be4f0e71a9de (patch)
treea855bfb699fabb2dda5c22b12673a06fed33edef /ethosu/vela/test/test_supported_operators.py
parent224e99bd70a443e345d3ea454aedc51bf46cf261 (diff)
downloadethos-u-vela-9a0cff1cd1334f4d3e7dfb542ad0be4f0e71a9de.tar.gz
MLBEDSW-3418: More operator checks for infinity
- Added operator check that OFM scale > smallest float32 number - Generalized the restriction that IFM/OFM scale must not be infinite Change-Id: I918f5ea3d8fdec6e8f6bd6780ed13a19d1234ed6 Signed-off-by: Louis Verhaard <louis.verhaard@arm.com>
Diffstat (limited to 'ethosu/vela/test/test_supported_operators.py')
-rw-r--r--ethosu/vela/test/test_supported_operators.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/ethosu/vela/test/test_supported_operators.py b/ethosu/vela/test/test_supported_operators.py
index f1e8f28f..d8fbb98f 100644
--- a/ethosu/vela/test/test_supported_operators.py
+++ b/ethosu/vela/test/test_supported_operators.py
@@ -93,7 +93,7 @@ def test_constraint_tens_quant_none_check():
def test_constraint_tens_quant_scale():
- # Quantization scale cannot be infinit
+ # Quantization scale cannot be infinite
qp = QuantizationParameters()
qp.zero_point = 0
qp.scale_f32 = np.inf
@@ -248,8 +248,19 @@ def test_constraint_batch_size():
def test_constraint_quant_scale_inf():
+ # Test handling IFM scale/OFM scale is infinite
op = testutil.create_op_with_quant_tensors(Op.Relu, [1, 8, 8, 8], [1, 8, 8, 8])
- op.ofm.quantization.scale_f32 = np.float32(1e-39)
+ op.ifm.quantization.scale_f32 = np.float32(1e9)
+ op.ofm.quantization.scale_f32 = np.float32(1e-35)
+ assert not support.is_operator_supported(op)
+
+
+def test_constraint_ofm_scale_too_small():
+ # Tests handling of OFM scale < 1e-38
+ shp = [1, 10, 20, 16]
+ op = testutil.create_elemwise_op(Op.Mul, "mul", shp, shp, shp, ofm_quant=testutil.default_quant_params(),)
+ assert support.is_operator_supported(op)
+ op.ofm.quantization.scale_f32 = 1e-43
assert not support.is_operator_supported(op)