aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Ward <james.ward@arm.com>2023-02-02 14:56:33 +0000
committerEric Kunze <eric.kunze@arm.com>2023-02-22 16:28:39 +0000
commit30124a8d9ab659f2661f3bb5962ae074d9ac4fa3 (patch)
tree305d31c047dd4704f8496e37026bd40a7b4c9f99
parentc5d759328fbfe9772fba56e63c81d196b3a7620f (diff)
downloadreference_model-30124a8d9ab659f2661f3bb5962ae074d9ac4fa3.tar.gz
Bug fixes for max-batch-size/ofm-depth
* Conformance regen required for tosa-bi: conv2d conv3d depthwise_conv2d transpose_conv2d * Include bug fix for testGen.makeShape() * Include json changes to limit size of tests which now have ofm_depth > 1 Signed-off-by: James Ward <james.ward@arm.com> Change-Id: Ic8221b9a742f5737df523997bee7260f4dfcdef3
-rw-r--r--verif/conformance/tosa_base_profile_ops_info.json26
-rw-r--r--verif/generator/tosa_arg_gen.py39
-rw-r--r--verif/generator/tosa_test_gen.py5
-rw-r--r--verif/generator/tosa_verif_build_tests.py12
4 files changed, 44 insertions, 38 deletions
diff --git a/verif/conformance/tosa_base_profile_ops_info.json b/verif/conformance/tosa_base_profile_ops_info.json
index ff88293..0395567 100644
--- a/verif/conformance/tosa_base_profile_ops_info.json
+++ b/verif/conformance/tosa_base_profile_ops_info.json
@@ -203,7 +203,7 @@
"--target-shape",
"1,49,42,28",
"--target-shape",
- "3,11,44,3",
+ "1,11,44,3",
"--allow-pooling-and-conv-oversizes"
],
[
@@ -752,11 +752,13 @@
"--target-dtype",
"int8",
"--target-shape",
- "1,65535,4,1",
+ "1,65535,3,1",
"--target-shape",
- "1,5,65536,1",
+ "1,2,65536,1",
"--max-conv-dilation",
"1",
+ "--tensor-dim-range",
+ "1,8",
"--allow-pooling-and-conv-oversizes"
]
],
@@ -801,11 +803,13 @@
"--target-dtype",
"int8",
"--target-shape",
- "1,1,65535,3,1",
+ "1,1,65535,2,1",
"--target-shape",
- "1,1,3,65536,1",
+ "1,1,2,65536,1",
"--max-conv-dilation",
"1",
+ "--tensor-dim-range",
+ "1,4",
"--allow-pooling-and-conv-oversizes"
]
],
@@ -856,6 +860,8 @@
"1,4,65537,1",
"--max-conv-dilation",
"1",
+ "--tensor-dim-range",
+ "1,16",
"--allow-pooling-and-conv-oversizes"
]
],
@@ -1568,7 +1574,7 @@
"--target-shape",
"1,4,75,3",
"--target-shape",
- "2,11,44,1",
+ "1,11,44,1",
"--allow-pooling-and-conv-oversizes"
],
[
@@ -1579,7 +1585,7 @@
"--target-shape",
"1,3,65537,1",
"--target-shape",
- "33333,3,2,1",
+ "1,3,2,1",
"--allow-pooling-and-conv-oversizes"
]
],
@@ -2514,7 +2520,9 @@
"--target-shape",
"1,49,33,1",
"--target-shape",
- "2,11,33,3",
+ "1,11,33,3",
+ "--tensor-dim-range",
+ "1,18",
"--allow-pooling-and-conv-oversizes"
],
[
@@ -2522,6 +2530,8 @@
"int8",
"--target-shape",
"1,65536,1,1",
+ "--tensor-dim-range",
+ "1,12",
"--max-conv-dilation",
"1"
]
diff --git a/verif/generator/tosa_arg_gen.py b/verif/generator/tosa_arg_gen.py
index 370570c..75ca634 100644
--- a/verif/generator/tosa_arg_gen.py
+++ b/verif/generator/tosa_arg_gen.py
@@ -192,10 +192,7 @@ class TosaTensorGen:
assert rank == 4
shape = testGen.makeShape(rank)
-
- # Constrict the batch size?
- if testGen.args.max_batch_size:
- shape[0] = (shape[0] % testGen.args.max_batch_size) + 1
+ shape = testGen.constrictBatchSize(shape)
# Constrict the overall size of the shape when creating ERROR_IF tests
if error_name and error_name != ErrorIf.MaxDimExceeded:
@@ -220,7 +217,7 @@ class TosaTensorGen:
# ignore max batch size if target shape is set
if testGen.args.max_batch_size and not testGen.args.target_shapes:
- values_in_shape[0] = (values_in_shape[0] % testGen.args.max_batch_size) + 1
+ values_in_shape[0] = min(values_in_shape[0], testGen.args.max_batch_size)
W = testGen.randInt(
testGen.args.tensor_shape_range[0], testGen.args.tensor_shape_range[1]
@@ -282,10 +279,7 @@ class TosaTensorGen:
# IFM dimensions are NHWC
ifm_shape = testGen.makeShape(rank)
-
- # Constrict the batch size?
- if testGen.args.max_batch_size:
- ifm_shape[0] = (ifm_shape[0] % testGen.args.max_batch_size) + 1
+ ifm_shape = testGen.constrictBatchSize(ifm_shape)
# Constrict the overall size of the shape when creating ERROR_IF tests
if error_name:
@@ -297,7 +291,7 @@ class TosaTensorGen:
filter_hw = op["filter"]
# Generate a random OFM depth
- ofm_depth = testGen.makeShape(1)[0]
+ ofm_depth = testGen.makeDimension()
# The filter dimensions are OHWI
filter_shape = np.asarray([ofm_depth, filter_hw[0], filter_hw[1], ifm_shape[3]])
@@ -316,10 +310,7 @@ class TosaTensorGen:
# IFM dimensions are NDHWC
ifm_shape = testGen.makeShape(rank)
-
- # Constrict the batch size?
- if testGen.args.max_batch_size:
- ifm_shape[0] = (ifm_shape[0] % testGen.args.max_batch_size) + 1
+ ifm_shape = testGen.constrictBatchSize(ifm_shape)
# Constrict the overall size of the shape when creating ERROR_IF tests
if error_name:
@@ -331,7 +322,7 @@ class TosaTensorGen:
filter_dhw = op["filter"]
# Generate a random OFM channel
- ofm_channel = testGen.makeShape(1)[0]
+ ofm_channel = testGen.makeDimension()
# The filter dimensions are ODHWI
filter_shape = np.asarray(
@@ -352,10 +343,7 @@ class TosaTensorGen:
# IFM dimensions are NHWC
ifm_shape = testGen.makeShape(rank)
-
- # Constrict the batch size?
- if testGen.args.max_batch_size:
- ifm_shape[0] = (ifm_shape[0] % testGen.args.max_batch_size) + 1
+ ifm_shape = testGen.constrictBatchSize(ifm_shape)
# Constrict the overall size of the shape when creating ERROR_IF tests
if error_name:
@@ -367,7 +355,7 @@ class TosaTensorGen:
filter_hw = op["filter"]
# Generate a random OFM depth
- ofm_depth = testGen.makeShape(1)[0]
+ ofm_depth = testGen.makeDimension()
# The filter dimensions are OHWI
filter_shape = np.asarray([ofm_depth, filter_hw[0], filter_hw[1], ifm_shape[3]])
@@ -387,10 +375,7 @@ class TosaTensorGen:
# IFM dimensions are NHWC
ifm_shape = testGen.makeShape(rank)
-
- # Constrict the batch size?
- if testGen.args.max_batch_size:
- ifm_shape[0] = (ifm_shape[0] % testGen.args.max_batch_size) + 1
+ ifm_shape = testGen.constrictBatchSize(ifm_shape)
# Constrict the overall size of the shape when creating ERROR_IF tests
if error_name:
@@ -405,7 +390,7 @@ class TosaTensorGen:
# Generate a random OFM depth, but don't let it get too big because
# the output depth is M * C
filter_m = (
- testGen.makeShape(1)[0] % (testGen.args.tensor_shape_range[1] // 4)
+ testGen.makeDimension() % (testGen.args.tensor_shape_range[1] // 4)
) + 1
# The filter dimensions are HWCM
@@ -484,9 +469,7 @@ class TosaTensorGen:
ifm_shape[1] += selected_inc[0]
ifm_shape[2] += selected_inc[1]
- # Constrict the batch size
- if testGen.args.max_batch_size:
- ifm_shape[0] = (ifm_shape[0] % testGen.args.max_batch_size) + 1
+ ifm_shape = testGen.constrictBatchSize(ifm_shape)
return [ifm_shape]
diff --git a/verif/generator/tosa_test_gen.py b/verif/generator/tosa_test_gen.py
index b48810f..a768da0 100644
--- a/verif/generator/tosa_test_gen.py
+++ b/verif/generator/tosa_test_gen.py
@@ -219,6 +219,11 @@ class TosaTestGen:
shape[0] = min(shape[0], self.args.max_batch_size)
return shape
+ def makeDimension(self):
+ return self.randInt(
+ low=self.args.tensor_shape_range[0], high=self.args.tensor_shape_range[1]
+ )
+
# Argument generators
# Returns a list of tuples (stringDescriptor, [build_fcn_arg_list])
# Where the string descriptor is used to generate the test name and
diff --git a/verif/generator/tosa_verif_build_tests.py b/verif/generator/tosa_verif_build_tests.py
index bc1ec8e..68e44da 100644
--- a/verif/generator/tosa_verif_build_tests.py
+++ b/verif/generator/tosa_verif_build_tests.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2020-2022, ARM Limited.
+# Copyright (c) 2020-2023, ARM Limited.
# SPDX-License-Identifier: Apache-2.0
import argparse
import re
@@ -96,7 +96,7 @@ def parseArgs(argv):
"--max-batch-size",
dest="max_batch_size",
default=1,
- type=int,
+ type=positive_integer_type,
help="Maximum batch size for NHWC tests",
)
@@ -238,6 +238,14 @@ def parseArgs(argv):
return args
+def positive_integer_type(argv_str):
+ value = int(argv_str)
+ if value <= 0:
+ msg = f"{argv_str} is not a valid positive integer"
+ raise argparse.ArgumentTypeError(msg)
+ return value
+
+
def main(argv=None):
args = parseArgs(argv)