Make MATMUL output shape random
* Currently when a target shape is specified, the W value of the input
tensor is always equal to N, this is not the case when no target shape
is defined.
* A random value for W is generated every time.
Signed-off-by: Matthew Haddon <matthew.haddon@arm.com>
Change-Id: I8f8ecb32308cef4a1ece1871f76ebbd5f0cf881f
diff --git a/verif/tosa_test_gen.py b/verif/tosa_test_gen.py
index 5138e3f..a3c6b05 100644
--- a/verif/tosa_test_gen.py
+++ b/verif/tosa_test_gen.py
@@ -325,9 +325,19 @@
assert pl == 2 and const == 0
a_shape = testGen.makeShape(rank)
- b_oc = testGen.makeShape(1)[0]
- b_shape = np.asarray([a_shape[0], a_shape[2], b_oc])
+ # Get a random number for b_oc even if target shape is defined
+ b_oc = np.int32(
+ testGen.rng.integers(
+ low=testGen.args.tensor_shape_range[0],
+ high=testGen.args.tensor_shape_range[1],
+ size=1,
+ )
+ )[0]
+ # If N or H is large let b_oc be 1 to reduce output tensor size
+ if max(a_shape) > 1000:
+ b_oc = 1
+ b_shape = np.asarray([a_shape[0], a_shape[2], b_oc])
return [a_shape, b_shape]
@staticmethod