aboutsummaryrefslogtreecommitdiff
path: root/verif/checker
diff options
context:
space:
mode:
authorJeremy Johnson <jeremy.johnson@arm.com>2023-09-27 16:10:59 +0100
committerEric Kunze <eric.kunze@arm.com>2023-09-28 18:27:41 +0000
commitf0348ea4206a7e02497515ffb6d88546e0121cc7 (patch)
tree35a003fdff5208864b6b85dff005ce0127ff649a /verif/checker
parentf9c0ceea99e197ab14f779eb51c5e1479dbeb4dd (diff)
downloadreference_model-f0348ea4206a7e02497515ffb6d88546e0121cc7.tar.gz
Refactor path arguments to tosa-tools
tosa_verif_conformance_generator - Move to using ref-model-path instead of ref-model-dir - Add schema-path and flatc-path - Add model_files module to locate default places for files convert2conformance - Remove default paths verifier - Switch to using exact path of verifier library tosa_verif_run_tests - Use conformance model_files to locate defaults Change-Id: Ieca3b164670e2a7dcb047743667cc4e8317daa97 Signed-off-by: Josef Malmström <josef.malmstrom@arm.com> Signed-off-by: Jeremy Johnson <jeremy.johnson@arm.com>
Diffstat (limited to 'verif/checker')
-rw-r--r--verif/checker/verifier.py44
1 files changed, 19 insertions, 25 deletions
diff --git a/verif/checker/verifier.py b/verif/checker/verifier.py
index 3a86bab..06ffcfb 100644
--- a/verif/checker/verifier.py
+++ b/verif/checker/verifier.py
@@ -4,20 +4,10 @@
import ctypes as ct
import json
from pathlib import Path
-from typing import Optional
import numpy as np
import schemavalidation.schemavalidation as sch
-
-# Default library info
-SCRIPT = Path(__file__).absolute()
-# NOTE: This REFMODEL_DIR default only works for the python developer environment
-# i.e. when using the scripts/py-dev-env.* scripts
-# otherwise use the command line option --ref-model-directory to specify path
-REFMODEL_DIR = SCRIPT.parents[2]
-LIBRARY = "libtosa_reference_verify_lib.so"
-
# Type conversion from numpy to tosa_datatype_t
# "type" matches enum - see include/types.h
# "size" is size in bytes per value of this datatype
@@ -55,18 +45,12 @@ class VerifierError(Exception):
class VerifierLibrary:
"""Python interface to the C verify library."""
- def __init__(self, path: Optional[Path] = None):
+ def __init__(self, verify_lib_path):
"""Find the library and set up the interface."""
- if path is None:
- path = REFMODEL_DIR
- lib_paths = sorted(path.glob(f"**/{LIBRARY}"))
-
- if len(lib_paths) < 1:
- raise VerifierError(
- f"Could not find {LIBRARY} - have you built the ref-model?"
- )
+ self.lib_path = verify_lib_path
+ if not self.lib_path.is_file():
+ raise VerifierError(f"Could not find verify library - {self.lib_path}")
- self.lib_path = lib_paths[0]
self.lib = ct.cdll.LoadLibrary(self.lib_path)
self.tvf_verify_data = self.lib.tvf_verify_data
@@ -122,14 +106,14 @@ class VerifierLibrary:
def main(argv=None):
"""Simple command line interface for the verifier library."""
import argparse
+ import conformance.model_files as cmf
parser = argparse.ArgumentParser()
+
parser.add_argument(
- "--ref-model-directory",
- dest="ref_model_dir",
- default=REFMODEL_DIR,
+ "--verify-lib-path",
type=Path,
- help="Path to pre-built reference model directory",
+ help="Path to TOSA verify lib",
)
parser.add_argument(
"--test-desc",
@@ -159,6 +143,16 @@ def main(argv=None):
)
args = parser.parse_args(argv)
+ if args.verify_lib_path is None:
+ # Try to work out ref model directory and find the verify library
+ # but this default only works for the python developer environment
+ # i.e. when using the scripts/py-dev-env.* scripts
+ # otherwise use the command line option --verify-lib-path to specify path
+ ref_model_dir = Path(__file__).absolute().parents[2]
+ args.verify_lib_path = cmf.find_tosa_file(
+ cmf.TosaFileType.VERIFY_LIBRARY, ref_model_dir, False
+ )
+
if args.test_desc:
json_path = args.test_desc
else:
@@ -192,7 +186,7 @@ def main(argv=None):
arrays[idx] = array
print("Load verifier library")
- vlib = VerifierLibrary(args.ref_model_dir)
+ vlib = VerifierLibrary(args.verify_lib_path)
print("Verify data")
if vlib.verify_data(output_name, test_desc["meta"]["compliance"], *arrays):