aboutsummaryrefslogtreecommitdiff
path: root/verif/runner
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/runner
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/runner')
-rw-r--r--verif/runner/run_command.py28
1 files changed, 20 insertions, 8 deletions
diff --git a/verif/runner/run_command.py b/verif/runner/run_command.py
index eef5a76..97d9837 100644
--- a/verif/runner/run_command.py
+++ b/verif/runner/run_command.py
@@ -1,5 +1,5 @@
"""Shell command runner function."""
-# Copyright (c) 2020-2022, ARM Limited.
+# Copyright (c) 2020-2024, ARM Limited.
# SPDX-License-Identifier: Apache-2.0
import shlex
import subprocess
@@ -33,18 +33,28 @@ class RunShCommandError(Exception):
def run_sh_command(full_cmd, verbose=False, capture_output=False):
"""Run an external shell command.
- full_cmd: array containing shell command and its arguments
+ full_cmd: string, or array containing shell command and its arguments
verbose: optional flag that enables verbose output
capture_output: optional flag to return captured stdout/stderr
"""
- # Quote the command line for printing
- full_cmd_esc = [shlex.quote(x) for x in full_cmd]
+
+ is_str = True if isinstance(full_cmd, str) else False
+ is_list = True if isinstance(full_cmd, list) else False
+
+ if is_list:
+ # Quote the command line for printing
+ full_cmd_esc = [shlex.quote(x) for x in full_cmd]
if verbose:
- print("### Running {}".format(" ".join(full_cmd_esc)))
+ if is_list:
+ print("### Running {}".format(" ".join(full_cmd_esc)))
+ if is_str:
+ print("### Running {}".format(full_cmd))
if capture_output:
- rc = subprocess.run(full_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ rc = subprocess.run(
+ full_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=is_str
+ )
stdout = rc.stdout.decode("utf-8")
stderr = rc.stderr.decode("utf-8")
if verbose:
@@ -54,8 +64,10 @@ def run_sh_command(full_cmd, verbose=False, capture_output=False):
print(stderr, end="")
else:
stdout, stderr = None, None
- rc = subprocess.run(full_cmd)
+ rc = subprocess.run(full_cmd, shell=is_str)
if rc.returncode != 0:
- raise RunShCommandError(rc.returncode, full_cmd_esc, stderr, stdout)
+ raise RunShCommandError(
+ rc.returncode, full_cmd_esc if is_list else full_cmd, stderr, stdout
+ )
return (stdout, stderr)