aboutsummaryrefslogtreecommitdiff
path: root/verif/frameworks/tosa_verif_framework_generator.py
diff options
context:
space:
mode:
authorTatWai Chong <tatwai.chong@arm.com>2024-01-12 13:13:22 -0800
committerEric Kunze <eric.kunze@arm.com>2024-01-23 22:05:26 +0000
commit6a46b251062dcd42bc9fa2bc9effad407747f64f (patch)
treeea4d74e6bfa643aa9d18f74491a59940dbc3b281 /verif/frameworks/tosa_verif_framework_generator.py
parent64e4bfe627ded0ba44ff60b23db28c1ff5d73d13 (diff)
downloadreference_model-6a46b251062dcd42bc9fa2bc9effad407747f64f.tar.gz
Shape infer dynamic model to static model prior to execution.
Dynamic shape model cannot directly run on the refenence model as the concrete size of tensor is unknown therefore the volume of tensor is not able to be allocated. Furthemore, the operators also expect the input model is static-shaped. This change turns dynamic model to static model prior to execution. - Add `ifm_dynamic` field into json description to indicate whether the model has dynamic shape or not. - Add the shape inference pass into the compilation pipeline, firstly legalize the dynamic tf/tfl model to dynamic tosa model with unknown shapes, and then run the shape inference pass with static shapes input argument to resolve unknown dimensions. Change-Id: I5d2ffd452becc562dc30546789705bd01dd7a0b0 Signed-off-by: TatWai Chong <tatwai.chong@arm.com>
Diffstat (limited to 'verif/frameworks/tosa_verif_framework_generator.py')
-rwxr-xr-xverif/frameworks/tosa_verif_framework_generator.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/verif/frameworks/tosa_verif_framework_generator.py b/verif/frameworks/tosa_verif_framework_generator.py
index 3a9c0ca..538f314 100755
--- a/verif/frameworks/tosa_verif_framework_generator.py
+++ b/verif/frameworks/tosa_verif_framework_generator.py
@@ -826,9 +826,9 @@ TF_OP_LIST = {
},
# number of operands of tuples which spcifies which dim to set to None
# In this case, we have 1 input. So we have 1 tuple
- # We're setting the first input's third dim to None
+ # We're setting the first input's first (batch) dim to None
"dynamic_shape_dim": [
- (3,),
+ (0,),
],
},
"depth_to_space": {
@@ -849,9 +849,9 @@ TF_OP_LIST = {
},
# number of operands of tuples which spcifies which dim to set to None
# In this case, we have 1 input. So we have 1 tuple
- # We're setting the first input's third dim to None
+ # We're setting the first input's first (batch) dim to None
"dynamic_shape_dim": [
- (3,),
+ (0,),
],
},
"one_hot": {
@@ -1166,6 +1166,7 @@ def run_unit_test(
placeholder_signatures = ()
placeholder_npy_filenames = []
placeholder_shapes = []
+ placeholder_dynamic = False
for idx, (name, val) in enumerate(placeholders):
input_shape = tuple(val.shape)
@@ -1176,6 +1177,8 @@ def run_unit_test(
dim = dim_tuple[0]
input_shape = list(input_shape)
input_shape[dim] = None
+ # When any dimension size is unknown, mark the placeholder as dynamic type.
+ placeholder_dynamic = True
addl_args.append(tuple(input_shape))
except KeyError:
@@ -1432,6 +1435,7 @@ def run_unit_test(
ifm_name=placeholder_names,
ifm_file=placeholder_npy_filenames,
ifm_shape=placeholder_shapes,
+ ifm_dynamic=placeholder_dynamic,
framework_exclusions=excluded_framework_list,
quantized=is_quantized,
test_name=test_name,